Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

askthedev.com Logo askthedev.com Logo
Sign InSign Up

askthedev.com

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Ubuntu
  • Python
  • JavaScript
  • Linux
  • Git
  • Windows
  • HTML
  • SQL
  • AWS
  • Docker
  • Kubernetes
Home/ Questions/Q 37834
In Process

askthedev.com Latest Questions

Asked: February 5, 20252025-02-05T06:14:17+05:30 2025-02-05T06:14:17+05:30

Why is my DX12 depth buffer completely white despite proper setup and visible buffer in RenderDoc?

anonymous user

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!

  • 0
  • 0
  • 2 2 Answers
  • 0 Followers
  • 0
Share
  • Facebook

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Continue with Google
    or use

    Forgot Password?

    Need An Account, Sign Up Here
    Continue with Google

    2 Answers

    • Voted
    • Oldest
    • Recent
    1. anonymous user
      2025-02-05T06:14:18+05:30Added an answer on February 5, 2025 at 6:14 am

      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:

      • Depth Buffer Initialization: Make sure your depth buffer is properly initialized. You need to ensure that the resource is created with the correct options. For example, when you create the depth-stencil view, you should use `D3D12_RESOURCE_DESC` to specify its size and mip levels correctly.
      • Resource Transitions: You mentioned that you’ve set the depth buffer state to `D3D12_RESOURCE_STATE_DEPTH_WRITE`. Make sure there are no resource state transition issues. Before you start rendering, check that the resource is in the correct state using transitions if you need to. For example:

        
        _commandList->ResourceBarrier(1, &barrier);
                    

        where `barrier` is set properly for the transition.

      • Depth Stencil View (DSV) Format: Ensure that the depth-stencil view is created with the correct format. You have `DXGI_FORMAT_D32_FLOAT`, which is fine, but double-check that the DSV creation code matches your resource settings.
      • Clear Depth Values: When clearing the depth buffer, you’re using `1.0f` for the depth. That should be fine, but make sure that your rendering code uses the values you expect, typically between `0.0f` (near) and `1.0f` (far).
      • Pipeline State: Your pipeline state looks good at a glance, but verify that you’re actually using the depth-stencil state in your render pass and that depth testing is enabled.

      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!

        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. anonymous user
      2025-02-05T06:14:19+05:30Added an answer on February 5, 2025 at 6:14 am

      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.

        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Sidebar

    Recent Answers

    1. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
    2. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
    3. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
    4. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
    5. anonymous user on How can I update the server about my hotbar changes in a FabricMC mod?
    • Home
    • Learn Something
    • Ask a Question
    • Answer Unanswered Questions
    • Privacy Policy
    • Terms & Conditions

    © askthedev ❤️ All Rights Reserved

    Explore

    • Ubuntu
    • Python
    • JavaScript
    • Linux
    • Git
    • Windows
    • HTML
    • SQL
    • AWS
    • Docker
    • Kubernetes

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.