Jump to content
  • Advertisement
Sign in to follow this  
hiya83

Early stencil test/cull before pixel shader

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

Advertisement

 

I am writing to SV_Depth in the pixel shader so earlydepthstencil is not an option.

Depth and stencil testing happen at the same time - so either both early or both late.
If you need late depth testing then you're out of luck.

 

That's unfortunate, I guess I'll try a manual stencil test at start of pixel shader. It'll probably complain about divergence I am guessing.

 

I wonder if it works for stencil too; like if I enable that for depth will it do the stencil test at the same time it does the early z... I can give it a test, thanks

Share this post


Link to post
Share on other sites

 

 

I am writing to SV_Depth in the pixel shader so earlydepthstencil is not an option.

Depth and stencil testing happen at the same time - so either both early or both late.
If you need late depth testing then you're out of luck.

 

That's unfortunate, I guess I'll try a manual stencil test at start of pixel shader. It'll probably complain about divergence I am guessing.

 

I wonder if it works for stencil too; like if I enable that for depth will it do the stencil test at the same time it does the early z... I can give it a test, thanks

 

Um look at what you quoted from Hodgman... according to him stencil happens at the same time as depth.

Share this post


Link to post
Share on other sites
I actually don't know if anything changes about that statement once you start using conservative depth though, so I'm interested to hear the result too :D

BTW, the "depth bounds test" is also a thing -- it's a non-standard extension, which rejects pixels based on whether the existing value in the depth buffer (not the depth value of your new pixel!) lies within a particular depth range. Commonly used when doing things like applying lights in a deferred renderer, where you can define the depth range that it should apply to, etc.

Share this post


Link to post
Share on other sites

Conservative depth will allow early depth to remain enabled if the constraint is set up such a way that it won't invalidate the early depth test. Typically this requires that the conservative depth constraint is "opposite" of your depth test function. So for example if you're using D3D11_COMPARISON_LESS for your depth test, you can safely use SV_DepthGreaterEqual without disabling early depth testing. This is because your pixel shader can only increase the depth, and so a pixel that fails the early depth test for having depth >= the depth buffer will continue to fail the depth test no matter what value is output by the pixel shader.

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!