[PATCH] WineD3D: Keep track of the last used device=0A=

Stefan Doesinger stefan at codeweavers.com
Thu Jul 31 13:29:50 CDT 2008


=0A=
This makes apps work that use two direct3d devices at the same time=0A=
---=0A=
 dlls/wined3d/context.c |   15 ++++++++++++++-=0A=
 1 files changed, 14 insertions(+), 1 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c=0A=
index 4440848..ccd1b68 100644=0A=
--- a/dlls/wined3d/context.c=0A=
+++ b/dlls/wined3d/context.c=0A=
@@ -29,6 +29,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);=0A=
 =0A=
 #define GLINFO_LOCATION This->adapter->gl_info=0A=
 =0A=
+/* The last used device.=0A=
+ *=0A=
+ * If the application creates multiple devices multiple devices and =
switches=0A=
+ * between them, ActivateContext has to change the opengl context. This =
flag=0A=
+ * allows to keep track which device is active=0A=
+ */=0A=
+IWineD3DDeviceImpl *last_device;=0A=
+=0A=
 =
/************************************************************************=
*****=0A=
  * Context_MarkStateDirty=0A=
  *=0A=
@@ -562,6 +570,8 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl =
*This, IWineD3DSurfaceImpl *tar=0A=
      */=0A=
     if(oldDrawable && oldCtx) {=0A=
         pwglMakeCurrent(oldDrawable, oldCtx);=0A=
+    } else {=0A=
+        last_device =3D This;=0A=
     }=0A=
     This->frag_pipe->enable_extension((IWineD3DDevice *) This, TRUE);=0A=
 =0A=
@@ -627,6 +637,8 @@ void DestroyContext(IWineD3DDeviceImpl *This, =
WineD3DContext *context) {=0A=
     TRACE("Destroying ctx %p\n", context);=0A=
     if(pwglGetCurrentContext() =3D=3D context->glCtx){=0A=
         pwglMakeCurrent(NULL, NULL);=0A=
+    } else {=0A=
+        last_device =3D NULL;=0A=
     }=0A=
 =0A=
     if(context->isPBuffer) {=0A=
@@ -1125,7 +1137,7 @@ void ActivateContext(IWineD3DDeviceImpl *This, =
IWineD3DSurface *target, ContextU=0A=
     }=0A=
 =0A=
     /* Activate the opengl context */=0A=
-    if(context !=3D This->activeContext) {=0A=
+    if(last_device !=3D This || context !=3D This->activeContext) {=0A=
         BOOL ret;=0A=
 =0A=
         /* Prevent an unneeded context switch as those are expensive */=0A=
@@ -1152,6 +1164,7 @@ void ActivateContext(IWineD3DDeviceImpl *This, =
IWineD3DSurface *target, ContextU=0A=
                    sizeof(*This->activeContext->pshader_const_dirty) * =
GL_LIMITS(pshader_constantsF));=0A=
         }=0A=
         This->activeContext =3D context;=0A=
+        last_device =3D This;=0A=
     }=0A=
 =0A=
     /* We only need ENTER_GL for the gl calls made below and for the =
helper functions which make GL calls */=0A=
-- =0A=
1.5.4.5=0A=
=0A=

------=_NextPart_000_000D_01C901F1.8F1BA6F0--




More information about the wine-patches mailing list