Jump to content
  • Advertisement
Sign in to follow this  
kazemi

Resolving a Depth/Stencil buffer?

This topic is 2615 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

I'm trying to implement a deferred rendering engine with Direct3D 11, now somewhere in my code I have to resolve a MS Depth buffer so that I can bind it for use in the forward rendering pass where it should be single sampled. I use ResolveSubresource like this:

pD3DDeviceContext->ResolveSubresource(destTexture, 0, srcTexture, 0, DXGI_FORMAT_D24_UNORM_S8_UINT);

But it doesn't seem to do anything at all! Can you think of anything that I'm doing wrong?

Thanks

Share this post


Link to post
Share on other sites
Advertisement

I'm trying to implement a deferred rendering engine with Direct3D 11, now somewhere in my code I have to resolve a MS Depth buffer so that I can bind it for use in the forward rendering pass where it should be single sampled. I use ResolveSubresource like this:

pD3DDeviceContext->ResolveSubresource(destTexture, 0, srcTexture, 0, DXGI_FORMAT_D24_UNORM_S8_UINT);

But it doesn't seem to do anything at all! Can you think of anything that I'm doing wrong?

Thanks


DXGI_FORMAT_D24_UNORM_S8_UINT doesn't support MSAA resolve. This chart shows you which operations are supported for each format. Besides even if you could do that, it doesn't make much sense to average depth samples in that way (which also goes for anything else in a G-Buffer).

You'll need to access your depth buffer as a Texture2DMS in your shader if you want to sample it. If you want you can just grab the 0th subsample for each pixel, but ideally if you're implementing MSAA then you should detect pixels where a triangle didn't cover all subsamples and then light each subsample individually.

Share this post


Link to post
Share on other sites
MJP, Thanks for your answer. I'm trying to bind the buffer again as a depth buffer in another pass. I assume it's not possible to bind a ms depth buffer along with single sampled render targets at the same time. Is there any solution for that?

Share this post


Link to post
Share on other sites
Yeah the number of MSAA samples needs to match for all render targets and depth-stencil buffers bound to the context at the same time. You'll need to create a non-MSAA depth-stencil buffer, and then perform a manual resolve using a pixel shader. Basically you just bind the non MSAA depth buffer as the depth-stencil buffer on the context and bind the MSAA depth buffer as a shader resource, and then render a full screen quad where the pixel shader samples one or more depth subsamples using a Texture2DMS and then writes out the resolved depth value to SV_Depth. To start out you can just sample and write out the 0th subsample, but you can also try experimenting with taking the min or max of all subsamples to get a more or less conservative bounds on the depth for a pixel.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!