🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

What could cause a draw call to show up in the RTV but not appear on screen?

Started by
6 comments, last by maxmax 3 years, 8 months ago

Hello there, I have a call to DrawInstanced() that does not show up on screen. However if I open PIX or renderdoc, if I go look at the render target texture, I can see it show up. What could cause this?

Some additional details:

  • This same PSO that I am using to draw works fine for other similar draw calls.
  • The debug layer is not returning any error.
  • The rasterizer state of the PSO has CULL_MODE_NONE set for the culling options.

I'm not sure what else to say because everything look correct when looking at the draw call in pix, it even shows up in the RTV. I hesitate to post the code since it's so much code, but the gist of what's happening is this:

  1. A compute shader uses an AppendStructuredBuffer to append some vertices to a resource.
  2. I create a vertex buffer view that points to the resource of the AppendStructuredBuffer.
  3. Draw using that VBV.

The compute shader:

struct bounding_box
{
    float3 position[8];
};
AppendStructuredBuffer<bounding_box> bounds : register(u3);

groupshared float3 v_min;
groupshared float3 v_max;

#define threads_count 1024
[numthreads(threads_count, 1, 1)]
void CS(uint3 thread_id : SV_DispatchThreadID)
{
    int index = thread_id.x;

	// Other stuff...

    // Calculate min/max vertices for the bounding box
    GroupMemoryBarrier();
    v_min = min(v_min, p.position);
    v_max = max(v_max, p.position);

    if (index == threads_count - 1)
    {
        // Generate positions from min/max
        bounding_box new_bounds;
        new_bounds.position[0] = v_min;
        new_bounds.position[1] = float3(v_min.x, v_max.y, v_min.z);
        new_bounds.position[2] = float3(v_min.x, v_min.y, v_max.z);
        new_bounds.position[3] = float3(v_min.x, v_max.y, v_max.z);
        new_bounds.position[4] = float3(v_max.x, v_min.y, v_min.z);
        new_bounds.position[5] = float3(v_max.x, v_max.y, v_min.z);
        new_bounds.position[6] = float3(v_max.x, v_min.y, v_max.z);
        new_bounds.position[7] = v_max;

        bounds.Append(new_bounds);
    }
}

The draw code:

// Dispatch the compute shader to fill particle_system_bounds_default with vertex data...

// Draw the vertices
main_cmdlist->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_LINELIST);
main_cmdlist->SetPipelineState(bounds_pso);

D3D12_VERTEX_BUFFER_VIEW vbv = {};
vbv.BufferLocation = particle_system_bounds_default->GetGPUVirtualAddress();
vbv.SizeInBytes = sizeof(XMFLOAT3) * 8;
vbv.StrideInBytes = sizeof(XMFLOAT3);
main_cmdlist->IASetVertexBuffers(0, 1, &vbv);

main_cmdlist->DrawInstanced(8, 1, 0, 0);

PIX capture (look at the RTV for the 2nd draw call): https://1drv.ms/u/s!AiGFMy6hVmtNgZlqleTWa98CGMnKrQ?e=QHvSbe

Advertisement

just a stab-question-in-the-dark…:

if u r rendering to a texture, where in your code do u set this RT as a texture ?

are you rendering a quad with this texture on it ? is the texture set or unset ?

you want to do this preferably before the next call to “your swap chain→present( … )”

Until then ?

(PS: i haven't looked at the pix yet)

PIX artificialy adds Begin/End Scene on frame draw calls, are you missing it in your code?

@johnnycode @ddlox I'm not sure exactly what Begin/End scene are because I'm using dx12. But the code used to set the RTV and present is the exact same as all my other drawing code, which is working fine. The only difference between the code that is drawing correctly and the code that is not, is that I am binding different data to the shaders. It's actually the same shaders, ran in the same order, but the shaders are operating on more data inside the resources. It really blows my mind that PIX shows that everything is going as expected, and even showing the correct result in the RTV, yet what is actually drawn is wrong. I am using the exact same code path that clears/set the RTV and present.

post the code where you call executecommmandlists

This code not work for me. I don't understand, What mistake I am doing. Now, to find a solution for this is really a headache for me. I can't search more on this topic and now I just need rest on Best Mattress For Back. Till then if someone has right code then reply to me.

JohnnyCode said:

post the code where you call executecommmandlists

The problem was that I was not passing a proper command UAV counter to ExecuteIndirect. It's not clear why pix was able to show me the correct result, maybe it's because the way pix executes indirect commands is more forgiving and the counter I was using before was good enough for pix but not for the app.

This topic is closed to new replies.

Advertisement