[1/4 try 3] wined3d: Activate GL context before making any GL calls in stretch_rect_fbo
stefandoesinger at gmx.at
Fri Dec 21 07:03:04 CST 2007
I think your patches are on the right track, but there are a few issues to
look at. I'll also need Henri's comments, as he wrote the fbo code.
Did you try your patches with the Deferred Shading sample from codesampler?
http://www.codesampler.com/usersrc/usersrc_7.htm . It uses multiple render
targets, so it is a quite interesting test.
drawprimitive() in drawprim.c calls apply_fbo_state before calling
ActivateContext as well. This causes a lot of problems with multithreading,
so this should be fixed too.
The first patch is OK. Calling ActivateContext before activating the fbo is
In patch 2, I was a bit confused by moving the "This->activeContext"
assignment inside Init3D, I first thought you would remove it. But otherwise
it looks good to me as well.
Patch 3 is ok too, keeping track of the currently bound fbo in the context is
good. Unrelated to this patch we should look if the glBindFramebufferEXT(...,
0) calls could be replaced with calling ActivateContext, and if that makes
sense(it's probably not a good idea everywhere).
In patch 4, you have to be aware that in CTXUSAGE_BLIT the fbo's depth and
color1+ attachments might be set to bad textures(e.g. different size). So
you'll have to set them to NULL or make sure that they are set properly.
I once discussed with Henri where we should have all the functions. I think we
could just move apply_fbo_state to context.c, make it static to make sure the
code that requires a drawable calls ActivateContext. I am not entirely sure
if that makes sense everywhere, e.g. the depth_blit code. Henri had some
arguments in that regard, but I have to check the irc logs and digg out the
Other good testing applications are Half Life 2(demo is ok), it uses color
buffers and depth buffers with different sizes. Battlefield 2(not 2142, no
idea if there is a demo) depends on the depth blitting. Bioshock(demo is ok)
is a case of an application that crashes due to multithreading issues because
apply_fbo_state is applied before calling ActivateContext.
Thank you for all your excellent work,
More information about the wine-patches