This is a question that may have an answer that differs for vanilla desktop GL and GL ES 2.0 (and wishful thinking is that ES 3.0 would have the same answer as vanilla GL).
What I'm doing is rendering a cubemap with a FS quad and I'd like to know if there's a way to specify a constant depth value for an entire render call rather than to get involved at the fragment shader level, in hopes of chasing a little bit of performance as well as flexibility in that I can use the same shader for drawing to different const depth values.
As for why it might benefit performance, the note at the bottom here offers some ideas, such as early-z testing... I suppose realistically if I emit a constant distant fragment depth, then early-z can still happen while maintaining the flexibility of pixel-programmable depth in general (necessary for proper impostors as shown). In this case I may be splitting hairs unnecessarily at this point. However that note does mention that if I can avoid specifying gl_FragDepth, I should, but it'd be up to the driver whether it will do something smart if I e.g. set gl_FragDepth to a constant.
As an example I could render my 3D scene, then set depth draw value to maximum, keep depth test on, and then render a fullscreen quad for my cubemap skybox, and it would just do the right thing.
Otherwise, choices include:
- render skybox first with depth testing switched off, then render scene
- use a fragment shader for the skybox that specifies the requisite depth value (this may very well just be the answer)