[PATCH] WineD3D: Only read back offscreen targets on a target =
Stefan Doesinger
stefan at codeweavers.com
Thu Jun 12 21:18:46 CDT 2008
change=0A=
=0A=
This avoids calling PreLoad needlessly on a thread change during =
offscreen rendering and breaks up the endless=0A=
recursion due to lastTID !=3D newTID.=0A=
---=0A=
dlls/wined3d/context.c | 29 ++++++++++++++++++++++++++++-=0A=
1 files changed, 28 insertions(+), 1 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c=0A=
index 203152b..382f96d 100644=0A=
--- a/dlls/wined3d/context.c=0A=
+++ b/dlls/wined3d/context.c=0A=
@@ -951,7 +951,34 @@ static inline WineD3DContext =
*FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf=0A=
Context_MarkStateDirty(context, STATE_FRONTFACE, =
StateTable);=0A=
}=0A=
}=0A=
- if (readTexture) {=0A=
+=0A=
+ /* When switching away from an offscreen render target, and we're =
not using FBOs,=0A=
+ * we have to read the drawable into the texture. This is done via =
PreLoad(and=0A=
+ * SFLAG_INDRAWABLE set on the surface). There are some things that =
need care though.=0A=
+ * PreLoad needs a GL context, and FindContext is called before the =
context is activated.=0A=
+ * It also has to be called with the old rendertarget active, =
otherwise a wrong drawable=0A=
+ * is read. This leads to these possible situations:=0A=
+ *=0A=
+ * 0) lastActiveRenderTarget =3D=3D target && oldTid =3D=3D newTid:=0A=
+ * Nothing to do, we don't even reach this code in this case...=0A=
+ *=0A=
+ * 1) lastActiveRenderTarget !=3D target && oldTid =3D=3D newTid:=0A=
+ * The currently active context is OK for readback. Call =
PreLoad, and it=0A=
+ * performs the read=0A=
+ *=0A=
+ * 2) lastActiveRenderTarget =3D=3D target && oldTid !=3D newTid:=0A=
+ * Nothing to do - the drawable is unchanged=0A=
+ *=0A=
+ * 3) lastActiveRenderTarget !=3D target && oldTid !=3D newTid:=0A=
+ * This is tricky. We have to get a context with the old =
drawable from somewhere=0A=
+ * before we can switch to the new context. In this case, =
PreLoad calls=0A=
+ * ActivateContext(lastActiveRenderTarget) from the new(current) =
thread. This=0A=
+ * is case (2) then. The old drawable is activated for the new =
thread, and the=0A=
+ * readback can be done. The recursed ActivateContext does *not* =
call PreLoad again.=0A=
+ * After that, the outer ActivateContext(which calls PreLoad) =
can activate the new=0A=
+ * target for the new thread=0A=
+ */=0A=
+ if (readTexture && This->lastActiveRenderTarget !=3D target) {=0A=
BOOL oldInDraw =3D This->isInDraw;=0A=
=0A=
/* PreLoad requires a context to load the texture, thus it will =
call ActivateContext.=0A=
-- =0A=
1.5.3.7=0A=
=0A=
------=_NextPart_000_0006_01C8CCD2.BA92A3F0--
More information about the wine-patches
mailing list