Here's my second attempt at this, this time merging FBO draw buffer selection into ActivateContext. Could you please review it? Hopefully I'm going in the right direction. The first patch moves the call to ActivateContext before the GL calls that setup the blit. This is needed so the second patch doesn't break stretch_rect_fbo.
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].
With these patches, the visual tests in ddraw/d3d8/d3d9 mostly succeed with FBO offscreen rendering. The newly added alpha blending test still fails in ddraw, but it still does better than without the patches.
- Allan