cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

ckotinko1
Journeyman III

Is it good idea to use 'discard' with conservative_depth?

Jump to solution

Hello.

I rely on conservative depth extention in my pixel shaders:

layout (depth_greater) out float gl_FragDepth;

Is this feature compatible with shaders with discard instruction?

Tags (3)
0 Likes
1 Solution

Accepted Solutions
gsellers
Staff
Staff

Re: Is it good idea to use 'discard' with conservative_depth?

Jump to solution

Hi,

Yes, you can use discard; with conservative depth. The conservative depth feature controls whether the hardware runs your shader at all whereas executing discard; in the shader prevents the depth write from occurring. In the example you gave, if the depth test hardware determines that if you only make gl_FragDepth greater than it would have been then it is safe to not run the shader if the depth test is set to LESS or LEQUAL. However, if your shader executes discard, the resulting value will not be written to the depth buffer and nor will any other output from the shader.

Thanks,

Graham

View solution in original post

0 Likes
1 Reply
gsellers
Staff
Staff

Re: Is it good idea to use 'discard' with conservative_depth?

Jump to solution

Hi,

Yes, you can use discard; with conservative depth. The conservative depth feature controls whether the hardware runs your shader at all whereas executing discard; in the shader prevents the depth write from occurring. In the example you gave, if the depth test hardware determines that if you only make gl_FragDepth greater than it would have been then it is safe to not run the shader if the depth test is set to LESS or LEQUAL. However, if your shader executes discard, the resulting value will not be written to the depth buffer and nor will any other output from the shader.

Thanks,

Graham

View solution in original post

0 Likes