MRT efficiency to avoid useless rendering

my app uses 1 FBO with 2 color attachments.

the main loop alogorithm is basic :
bind the mrt
render the scene
render the scene (to GL_BACK).

Unfortunatelly, I have a performance issue. A single render pass is very expensive and I would like to avoid one pass.

The best solution would be to have a MRT with 3 attachments : GL_BACK and 2 GL_COLOR_ATTACHMENT.
AFAIK, this is not possible : in glsl gl_FragData could only be used to write into a color_attachement and we can’t use gl_FragData and gl_FragColor in the same time.

Am I right ?

If I am wrong
PLEASE tell me how to do!!!
else :

So I can render my scene into 3 color attachements, and then copy the content of one fbo texture into GL_BACK.

My goal is then to find the most efficient way to copy.

The GL_EXT_framebuffer_blit extension provide the fastest copy from one fbo to another. Does a similar method exist to copy/swap a fbo texture to the back buffer ?

The only way I know to do that would be to use a quad and use a texture on it.

Is there a better solution ?


GL_EXT_framebuffer_blit also allows you to blit between an application created FBO and the window provided framebuffer.
Just set GL_DRAW_FRAMEBUFFER_EXT to 0 if you want it to write to the window provided framebuffer.

Great ! Thanks a lot!

Is it possible to specify the color_attachement like that ?

BlitFramebufferEXT(0, 0, 640, 480,
0, 0, 640, 480,

According to the spec this should be possible.