Is it possible to share a Depth or Stencil attachment between two differents FrameBuffers?

Hi, I would like to have two FrameBuffers with one color attachment each one, and share the Depth and the Stencil attachment between the two FrameBuffers.

I know that I could build a unique FrameBuffer with two colors attachments, but I want to draw in one of the color attachments only a few times, so for performance I don’t want to enable the two all the time.

Another option is to use the blit function to copy data, from a FrameBuffer to other, but maybe thinking in perormance is a bad idea to do it every frame.

You can just… do that. There’s nothing stopping you from attaching a texture to multiple FBOs.

1 Like

Yeah, avoiding needless blits is good. And goes without saying you don’t want to be reconfiguring FBOs at runtime.

So it boils down to the cost of FBO binds vs. the cost of setting DrawBuffers (for your drivers, with your use case). Bench it and see. Would suspect if there’s a difference the latter might be faster.