I’m really struggling with something in my DX12 project and could use some help. I’ve set up a depth buffer, but for some reason, it’s showing completely white in RenderDoc, even though it looks like I’ve done everything right based on what I’ve seen in various tutorials and blog posts.
I’ve created the depth-stencil view and bound it properly in the pipeline, and I confirmed that the depth buffer resource is in the `D3D12_RESOURCE_STATE_DEPTH_WRITE` state. I even verified that the depth buffer texture is visible in RenderDoc, but it’s just this bright, solid white. It’s really frustrating, especially considering that my depth target and the settings in my graphics pipeline are all configured to support depth testing.
Here’s a quick rundown of my pipeline setup code for context:
“`cpp
psoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
psoDesc.RasterizerState.CullMode = D3D12_CULL_MODE_NONE;
psoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
psoDesc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT);
psoDesc.DSVFormat = DXGI_FORMAT_D32_FLOAT;
// Other pipeline state settings…
“`
And this is how I created the depth buffer resource:
“`cpp
D3D12_RESOURCE_DESC depthResourceDesc = {};
depthResourceDesc.Format = DXGI_FORMAT_D32_FLOAT; // Doing 32-bit float for depth
depthResourceDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
// Other resource setup…
“`
When I bind it in the command list, I’m calling:
“`cpp
_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, &dsvHandle);
_commandList->ClearDepthStencilView(dsvHandle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0.0f, 0, nullptr);
“`
I’ve checked that I’m matching the formats, sample counts, and other configurations, so I’m just at a loss here. There’s a ton of boilerplate code that I don’t want to overwhelm anyone with, but if you need to see more, my project is available on GitHub [here](https://github.com/eliasfuericht/artisDX/blob/main/src/Application.cpp).
If anyone has any ideas or has faced something similar, I’d greatly appreciate any guidance. I’m really hoping to get past this hurdle! Thanks!
Depth Buffer Showing White in RenderDoc
It sounds like you’re pretty close, but there are a few common pitfalls that could be causing your depth buffer to appear completely white in RenderDoc. Here are some things you might want to check:
where `barrier` is set properly for the transition.
If you haven’t already, try to visualize the values you’re writing to the depth buffer in your vertex or pixel shaders. Debugging the output can help you see if you’re writing valid depth values or not.
Lastly, it’s always a good idea to check any debug output provided by DirectX. Sometimes it can give you hints about what’s going wrong.
Good luck, and don’t hesitate to share more code or specific issues if you’re still stuck!
It sounds like you’re encountering an issue where the depth buffer appears completely white in RenderDoc, which can often indicate that it is being filled with maximum depth values (1.0 for a 32-bit float depth buffer). Since you mentioned that you’ve set the depth stencil view format correctly to `DXGI_FORMAT_D32_FLOAT` and confirmed that your depth buffer resource is in the `D3D12_RESOURCE_STATE_DEPTH_WRITE` state, the next step is to check the depth clear value and the depth testing configuration. In your call to `ClearDepthStencilView`, you are using the maximum depth value of 1.0f, which is correct for clearing, but if the depth values are not being written correctly afterward, they may still appear as white in RenderDoc. Ensure that your geometry is being rendered in such a way that depth values less than 1.0 are being written to the depth buffer.
Another common scenario that can cause the depth buffer to show as completely white is related to the pipeline state settings, particularly the depth-stencil state. Make sure that the depth testing is enabled and that the depth comparison function (often `D3D12_COMPARISON_FUNC_LESS`) is set correctly in your depth-stencil state description. If you haven’t modified these settings from the default, it might be worth double-checking or explicitly setting the values to ensure correct functionality. Lastly, since you mentioned all your formats and sample counts match, also verify that you are not inadvertently discarding depth writes from your shaders or that the depth values being written are indeed less than the clear value of 1.0f. If possible, try adding debug outputs or use a simple shader that just writes depth values for testing.