I've been trying to implement Valve's VR checkerboard rendering technique (original document) and was wondering which way would be the best to proceed.

The thing is that I need to "abort" the execution of 2x2 blocks of fragments in a checkerboard pattern considering how GPUs work in blocks of pixels.

I've thought of several approaches which are the following :

  • Discard fragments in the fragment shader using a condition like this one :
float mod2 = gl_FragCoord.x + gl_FragCoord.y;
float res = mod(mod2, 2.0f);
if (res == 0.0f)
  • Use the stencil buffer and write a checkerboard pattern on it using an image or such.

  • Use some kind of clipping method where I have several quads in front of the camera forming a checkerboard pattern.

The first approach seems to be the worse because I have to branch and after, discard fragments. And considering the fact that GPUs work in blocks of 2x2 pixels, I need to find a way to abort block by block so that I don't get the fragment shader processed anyway (even with a discard). And I'm not even sure this would force a block to abort and skip the fragment shader.

The second method seems OK, but I'm not sure if there's a better way to do it. Would the fragment shader be processed anyway ?

The third seems to need to process more polygons which is not really a good idea I guess even though it does not require a lot of processing considering they would be simple quads.

What would be the most efficient method (listed here or not) for skipping these blocks ?

  • 1
    \$\begingroup\$ Can you olease add a link to the original resource? \$\endgroup\$
    – Bálint
    Commented Oct 12, 2016 at 9:51
  • \$\begingroup\$ @Bálint: Well I only checked used the first link I provided. But I'll try to find the original and edit my question. EDIT: Done. \$\endgroup\$
    – CpCd0y
    Commented Oct 12, 2016 at 10:04

1 Answer 1


The answer is in the source you linked:

Clip() 2x2 pixel quads as you render, or fill stencil or depth with a 2x2 checker pattern and render

and also

Skip rending a checker pattern of 2x2 pixel quads to match current GPU architectures

In other words, it should work, theoretically, but you better test there is an actual increase of performance. I'd also expect if + discard to work, but just like the other methods, I'd want to test and verify first if it actually results in a performance increase.

  • \$\begingroup\$ Well, I tried the if + discard, but I almost had worse performance because of the branching, I suppose. So, with the stencil method, would I have the guarantee that these fragments would be skipped ? Also, I'd try to avoid changing the depth buffer, to avoid not benefiting from early-z rejection :/ \$\endgroup\$
    – CpCd0y
    Commented Oct 12, 2016 at 11:31
  • \$\begingroup\$ @CpCd0y Branching "should" be completely irrelevant if the entire quad takes the same branch, and the card is moderately new. My understanding is that the stencil method is more likely to work if conditional discard doesn't, but I haven't done something like this before, that's why I unfortunately need to defer to "test and verify". \$\endgroup\$
    – Peter
    Commented Oct 12, 2016 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .