How to use glDiscardFramebufferEXT correctly

This question relates to the OpenGL ES 2.0 EXT_discard_framebuffer extension .

It is unclear which cases justify the use of this extension. If I call glDiscardFramebufferEXT () and it puts the specified attachment images in undefined state, it means either:
- I don't care about the content anymore, as it has already been used with glReadPixels (),
- I am no longer interested in content, as it has already been used with glCopyTexSubImage (),
- I should not have done the rendering in the first place.

Is it clear that only the first two cases make sense, or are there other cases where it is useful to use glDiscardFramebufferEXT ()? If so, what are these cases?

+4
source share
2 answers

glDiscardFramebufferEXT is a performance hint for the driver. Mobile GPUs use tile-based deferred rendering. In this context, setting any of your framebuffers to be discarded saves the work and memory of gpu, since there is no need to write them back to a single memory.

Usually you drop:

  • depth buffer because it is not displayed on the screen. It is just used when rendering on gpu.
  • msaa buffer as it is allowed for a smaller buffer for presentation to the screen.

In addition, any buffer that is used only for rendering on the GPU must be discarded so that it is not written back to the unified memory.

+6
source

The main situation when I saw DiscardFramebuffer is when you have a multi-disk rendering buffer that you just allowed the texture using BlitFramebuffer or ResolveMultisampleFramebufferAPPLE (on iOS), in which case you no longer care about the contents of the original buffer.

+2
source

All Articles