Module: wine
Branch: master
Commit: 7ed116da2e2bafef09b45cbeb80859edbd13d73c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7ed116da2e2bafef09b45cbeb…
Author: Henri Verbeet <hverbeet(a)codeweavers.com>
Date: Fri Aug 7 08:51:20 2009 +0200
wined3d: Merge the context->current_rt check for rendertarget readback with the code above.
Also update the comments.
---
dlls/wined3d/context.c | 81 +++++++++++++++++++----------------------------
1 files changed, 33 insertions(+), 48 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 0eb6cfd..cd791c8 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1862,59 +1862,44 @@ retry:
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), StateTable);
}
}
- }
- /* When switching away from an offscreen render target, and we're not using FBOs,
- * we have to read the drawable into the texture. This is done via PreLoad(and
- * SFLAG_INDRAWABLE set on the surface). There are some things that need care though.
- * PreLoad needs a GL context, and FindContext is called before the context is activated.
- * It also has to be called with the old rendertarget active, otherwise a wrong drawable
- * is read. This leads to these possible situations:
- *
- * 0) lastActiveRenderTarget == target && oldTid == newTid:
- * Nothing to do, we don't even reach this code in this case...
- *
- * 1) lastActiveRenderTarget != target && oldTid == newTid:
- * The currently active context is OK for readback. Call PreLoad, and it
- * performs the read
- *
- * 2) lastActiveRenderTarget == target && oldTid != newTid:
- * Nothing to do - the drawable is unchanged
- *
- * 3) lastActiveRenderTarget != target && oldTid != newTid:
- * This is tricky. We have to get a context with the old drawable from somewhere
- * before we can switch to the new context. In this case, PreLoad calls
- * ActivateContext(lastActiveRenderTarget) from the new(current) thread. This
- * is case (2) then. The old drawable is activated for the new thread, and the
- * readback can be done. The recursed ActivateContext does *not* call PreLoad again.
- * After that, the outer ActivateContext(which calls PreLoad) can activate the new
- * target for the new thread
- */
- if (wined3d_settings.offscreen_rendering_mode != ORM_FBO && old_render_offscreen
- && context->current_rt && context->current_rt != target)
- {
- BOOL oldInDraw = This->isInDraw;
+ /* When switching away from an offscreen render target, and we're not
+ * using FBOs, we have to read the drawable into the texture. This is
+ * done via PreLoad (and SFLAG_INDRAWABLE set on the surface). There
+ * are some things that need care though. PreLoad needs a GL context,
+ * and FindContext is called before the context is activated. It also
+ * has to be called with the old rendertarget active, otherwise a
+ * wrong drawable is read. */
+ if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
+ && old_render_offscreen && context->current_rt != target)
+ {
+ BOOL oldInDraw = This->isInDraw;
- /* PreLoad requires a context to load the texture, thus it will call ActivateContext.
- * Set the isInDraw to true to signal PreLoad that it has a context. Will be tricky
- * when using offscreen rendering with multithreading
- */
- This->isInDraw = TRUE;
+ /* surface_internal_preload() requires a context to load the
+ * texture, so it will call ActivateContext. Set isInDraw to true
+ * to signal surface_internal_preload() that it has a context. */
- /* Do that before switching the context:
- * Read the back buffer of the old drawable into the destination texture
- */
- if (((IWineD3DSurfaceImpl *)context->current_rt)->texture_name_srgb)
- {
- surface_internal_preload(context->current_rt, SRGB_BOTH);
- } else {
- surface_internal_preload(context->current_rt, SRGB_RGB);
- }
+ /* FIXME: This is just broken. There's no guarantee whatsoever
+ * that the currently active context, if any, is appropriate for
+ * reading back the render target. We should probably call
+ * context_set_current(context) here and then rely on
+ * ActivateContext() doing the right thing. */
+ This->isInDraw = TRUE;
+
+ /* Read the back buffer of the old drawable into the destination texture. */
+ if (((IWineD3DSurfaceImpl *)context->current_rt)->texture_name_srgb)
+ {
+ surface_internal_preload(context->current_rt, SRGB_BOTH);
+ }
+ else
+ {
+ surface_internal_preload(context->current_rt, SRGB_RGB);
+ }
- /* Assume that the drawable will be modified by some other things now */
- IWineD3DSurface_ModifyLocation(context->current_rt, SFLAG_INDRAWABLE, FALSE);
+ IWineD3DSurface_ModifyLocation(context->current_rt, SFLAG_INDRAWABLE, FALSE);
- This->isInDraw = oldInDraw;
+ This->isInDraw = oldInDraw;
+ }
}
context->draw_buffer_dirty = TRUE;