# OpenGL Regarding Frame/Buffer Caching

I have been trying to get myself refreshed on OpenGL ES. Whilst doing so, I had the following question in mind:

Does OpenGL have any "caching" mechanism?

For example:

Let's say we draw a stationary triangle with only 3 vertices on the screen; if there will be no transformation applied to the primitive, will OpenGL ES still go through the vertex and fragment shader, drawing the primitive anew every single frame?

Or, does it have any "caching" mechanism, which is smart enough to know that since there is no transformation, a "caching" buffer will display the primitive on the screen bypassing calculations within vertex and fragment shaders so that unnecessary calculations could be reduced/avoided in hopes to enhance frame rate and performance?

Thank you.

OpenGL doesn't specify this; individual implementations are allowed to cache data and/or results so long as the output is conformant with the specification.

Note that this kind of caching is probably not what you want.

Caching like this implies that you need some kind of storage for the cached output, as well as comparison between the previous frame and the current frame. An OpenGL implementation is not going to be able to make such a comparison until SwapBuffers is called, at which point it will need to do a full comparison between two frames. So it's actually going to be more efficient (not to mention having simpler code paths in the driver - and OpenGL drivers are already quite complex as-is) to just require the program to re-submit everything every frame.

It would also lead to inconsistent framerates with spikes, which are actually worse than consistent but (hypothetically) lower framerates.

Quake didn't need caching in 1996, it was efficient then, so you shouldn't be thinking that it's inefficient now.

• Can you elaborate a bit more on "individual implementations are allowed to cache data and/or results so long as the output is conformant with the specification"? How would on go about doing that (to cache data); and, is there a name for this method? Thanks a lot. – Unheilig Oct 11 '16 at 19:52
• OK, "implementation" == "OpenGL driver" (not always but it's a good working definition). This would be something that happens behind-the-scenes in driver code - if the driver did it, you wouldn't need to do anything - the driver would just do it, automatically and transparently. And you can be certain that if it was a worthwhile optimization, drivers would do it. – Maximus Minimus Oct 11 '16 at 20:09
• I see. I thought there might be useful if there existed functions such as glEnableCache.., which would tell GL to use the last frame buffer from now on bypassing both vertex and fragment shader; and when the developer decided that transformation(s) would be applied to primitives at certain point, she could call glDisableCache.., then glTranslate(....), glDraw(..). Those are just function names I made up to illustrate my idea/thought. Thanks again. – Unheilig Oct 11 '16 at 21:34
• Just a quick question, if you don't mind: would what I mentioned in my previous comment (e.g., glEnableCache..glDisableCache..`,etc.) be a desirable feature to have in modern graphics pipeline such as OpenGL? – Unheilig Oct 13 '16 at 6:34
• Probably not. You can achieve much the same with FBOs: Render unchanging parts of the scene to a texture and reuse that texture over subsequent frames. – Maximus Minimus Oct 13 '16 at 7:22