2

I understand that hardware can run early fragment tests (https://www.khronos.org/opengl/wiki/Early_Fragment_Test) In particular for depth test, this means that the depth buffer can be updated already during the interpolation of vertex-shader outputs and the fragment shader only will be invoked for fragments that don't fail the depth test.

Now, using discard in the fragment shader disables this optimization. I understand that the updating of the depth buffer can only happen after the fragment shader was executed if discard is used. But the actual early depth rejection (i.e. not even executing the fragment shader if the fragment will fail the depth test) should still be possible nevertheless.

So I'm interested in what's happening on current hardware in this case (in particular I'm interested in snapdragon/adreno hardware)

If a shader contains the discard keyword (but does NOT change gl_Fragdepth), will the fragment shader be invoked even for fragments that will fail the depth test or do they still get the early z rejection treatment?

matthias_buehlmann
  • 4,641
  • 6
  • 34
  • 76

1 Answers1

0

If a shader contains the discard keyword (but does NOT change gl_Fragdepth), will the fragment shader be invoked even for fragments that will fail the depth test or do they still get the early z rejection treatment?

According to page 32-34 of the slides, Whether earlyZ is enabled/disabled depends on DepthWrite=OFF/ON

If DepthWrite=OFF, (namely, earlyZ is enabled), fragment shader will be invoked if any pixel of 2x2 quad passes the depth test

carnot
  • 71
  • 1
  • 3