So the order between them is important?Or the order just depends on hardware?I have no idea which one needs to come first.

  • \$\begingroup\$ Can you give an example where the order in which these are performed would result in an observable difference in the output? \$\endgroup\$
    – DMGregory
    Mar 31, 2020 at 15:31

1 Answer 1


The OpenGL specification defines these as happening in the following order:

  • Alpha test
  • Stencil test
  • Depth test

However, this order may not be strictly applied by all hardware or APIs. One example is if using an API that does not have alpha test, you would need to emulate it with discard instructions in your pixel shader. In that case it would still come first, but it would happen at a different (and earlier) pipeline stage - potentially before other operations that come between.

Another, more common, example is early depth testing. Depending on the combination of other states, modern hardware can often do a depth test before the pixel shader stage rather than after it, which can be a significant performance win. In that case the depth test comes much earlier - before the others you're interested in - but if the result would be the same as if it had run later, this is OK.


You must log in to answer this question.

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