How to do Early-Z testing in stride

hi all

I have a heavy pixel shader that outputs a circular image. I do not want to process pixels outside this circle. I already tried discarding fragments when UV is outside the radius, but I see no performance improvement. I want to implement early-z testing so that the fragments are not computer at all.

I have multiple questions:

  • how to set up the depth buffer with stride nodes
  • where do I set the depth value of the fragment, that determines if it is computed or not
  • do I have to take the depthbuffer and feed it via framedelay into my shader

It would be great if SB could post a small example of how to set up the depth buffer in stride.

Since dx11 does not allow to write into the stencil itself in shader code, I have to use a combination of stencil settings with multiple render passes. Do I get this right?

I set the stencil state in the first pass and discard all pixels outside the radius, thus creating the mask. But how do I use this mask in the next pass to not execute fragment shaders in the red areas?

Depth testing is done before the pixel shader, so you need to output the appropriate depth value from the vertex or geometry shader. Otherwise, the pixel shader will be called.

Thanks!

I set pos.w in VS using a higher tessellated mesh. Now the pixel shader does not execute in the outer areas; I can see the grids created by mesh resolution.

Is this already the integrated early-Z testing? I thought had to use a stencil to be able to do that. Best performance when using both: setting depth and discard in PS.

Can I think of the stencil as a hardware-implemented feature like the blend state? Basically it is always running in the background, the node can just reconfigure it?