On 17/12/2007, Allan Tong actong88@gmail.com wrote:
The second patch moves FBO draw buffer selection to ActivateContext. For onscreen rendering, not much changes except binding framebuffer 0. For offscreen rendering, the behavior depends on the specified context usage. For BLIT and RESOURCE_LOAD, the target surface is attached to dst_fbo and used as the draw buffer. For DRAWPRIM and CLEAR, I simply call apply_fbo_state. This assumes that DRAWPRIM and CLEAR will always be used with device->render_targets[0].
There is a problem with GL_COLOR_ATTACHMENT1_EXT and higher, and the depth attachment. You're only applying the first color attachment, but that can lead to incomplete fbos, if for example the render target and depth stencil are changed. If you're only reapplying the first color attachment, you can get a size mismatch, which makes the driver pretty angry and can slow everything down.
As far as I can tell, the only thing that's ever attached to device->dst_fbo is the first color attachment, so I wouldn't think there's any chance for a size mismatch. Do I still need to unset the depth attachment or the higher color attachments? I'm assuming there's no reason to have a depth attachment for a blit operation.
Currently src_fbo and dst_fbo are only used for doing blits between surfaces in stretch_rect_fbo() and a colorfill in color_fill_fbo(), so there will only ever be something attached to GL_COLOR_ATTACHMENT0_EXT.