• Advertisement
Sign in to follow this  

[D3D12] Depth reading issue

This topic is 737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

I am reading hardware depth buffer from the pixel shader and all the values are always equal to 1.0 when I step through the shader with VS graphics debugger.

 

If I check binded depth SRV, it seems to be valid on  the screen shot https://www.dropbox.com/s/5sjugwbb6bgnd26/DepthScreenShot.png?dl=0

 

Also, I tried to output depth values to RTV from the pixel shader and check RTV content from VS graphics debugger. Again, everything is equal to 1.0.

 

The depth buffer is created with DXGI_FORMAT_R32_TYPELESS, depth SRV with DXGI_FORMAT_R32_FLOAT and DSV with DXGI_FORMAT_D32_FLOAT format.

 

RTV has DXGI_FORMAT_R8G8B8A8_UNORM format.

 

I have also uploaded VS debugger capture in case you have a chance to check it. The issue occurs while executing the last command list before Present.

https://www.dropbox.com/s/wfj50p6lrca7yiy/DepthReadingIssue.7z?dl=0

 

Tx

Edited by _void_

Share this post


Link to post
Share on other sites
Advertisement

I've had a look at the capture and I don't think you're doing anything wrong. I think you're probably just being misled by VSGD.

 

Firstly, it appears that VSGD is misleadingly rounding your depth pixels to "1" when all the depth values that aren't the clear value are between 0.9999339 and 0.99999 when you mouse over them and it displays them below the image. There's quite clearly a depth image in there as you can see the boxes and yet VSGD reports 1 for the depth of each pixel. Assume that's a bug for now and I'll report it.

 

Secondly, when you debug the pixel shader right now you'll be debugging pixel (0,0) whether you want to or not. Since pixel (0,0) is not on a part of the image rendered to by your geometry the depth actually is 1.0f in this area of the screen.

 

To verify that you can actually read the depth image correctly I edited your shader to grab the depth from pixel (160,160) and verified it was not 1:

 

Eg6IIk7.png

 

With the following pixel shader I get this:

float hardwareDepth = DepthTexture.Load(int3(input.screenSpacePos.xy, 0)).r;
return (hardwareDepth > 0.99999);

 eofWmtQ.png

 

In conclusion, there's nothing wrong with reading the texture.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement