[dx56] d3d8/x11 locks fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

 With that patch, we can now play d3d8 games with sound (tested war3, mafia, 
ut2003)

Changelog:
 - dsound and d3d works better when x11drv locks/unlocks are corrects
 - more traces

Regards,
Raphael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+7ltTp7NA3AmQTU4RAjeQAJ4/pJ+yHlWuA1xEbdTLceJPnu6+6QCeLG3z
BrTLTH8j261uGavqi/nQaaA=
=U40o
-----END PGP SIGNATURE-----
Index: cubetexture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/cubetexture.c,v
retrieving revision 1.11
diff -u -r1.11 cubetexture.c
--- cubetexture.c	4 Jun 2003 23:05:46 -0000	1.11
+++ cubetexture.c	16 Jun 2003 23:56:48 -0000
@@ -136,6 +136,9 @@
     int j;
     ICOM_THIS(IDirect3DCubeTexture8Impl,iface);
     TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->Dirty);
+
+    ENTER_GL();
+
     for (i = 0; i < This->levels; i++) {
       if (i == 0 && This->surfaces[0][0]->textureName != 0 && This->Dirty == FALSE) {
 	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
@@ -185,6 +188,9 @@
 	This->Dirty = FALSE;
       }
     }
+
+    LEAVE_GL();
+
     return ;
 }
 
Index: d3d8_main.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/d3d8_main.c,v
retrieving revision 1.8
diff -u -r1.8 d3d8_main.c
--- d3d8_main.c	4 Jun 2003 22:45:57 -0000	1.8
+++ d3d8_main.c	16 Jun 2003 23:56:48 -0000
@@ -29,6 +29,7 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
 
+int num_lock = 0;
 void (*wine_tsx11_lock_ptr)(void) = NULL;
 void (*wine_tsx11_unlock_ptr)(void) = NULL;
 
Index: d3d8_private.h
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/d3d8_private.h,v
retrieving revision 1.37
diff -u -r1.37 d3d8_private.h
--- d3d8_private.h	13 Jun 2003 19:14:34 -0000	1.37
+++ d3d8_private.h	16 Jun 2003 23:56:55 -0000
@@ -49,8 +49,14 @@
 extern void (*wine_tsx11_unlock_ptr)(void);
 
 /* As GLX relies on X, this is needed */
+extern int num_lock;
+#if 0
+#define ENTER_GL() ++num_lock; TRACE("inc lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
+#define LEAVE_GL() if (num_lock > 2) TRACE("fucking locks: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
+#else
 #define ENTER_GL() wine_tsx11_lock_ptr()
 #define LEAVE_GL() wine_tsx11_unlock_ptr()
+#endif
 
 #include "d3d8.h"
 
Index: device.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/device.c,v
retrieving revision 1.72
diff -u -r1.72 device.c
--- device.c	13 Jun 2003 19:14:34 -0000	1.72
+++ device.c	16 Jun 2003 23:57:05 -0000
@@ -1567,6 +1567,8 @@
         return D3D_OK;
     }
 
+    ENTER_GL();
+
     TRACE("(%p) : x=%ld, y=%ld, wid=%ld, hei=%ld, minz=%f, maxz=%f\n", This,
           pViewport->X, pViewport->Y, pViewport->Width, pViewport->Height, pViewport->MinZ, pViewport->MaxZ);
 
@@ -1577,6 +1579,7 @@
                pViewport->Width, pViewport->Height);
     checkGLcall("glViewport");
 
+    LEAVE_GL();
 
     return D3D_OK;
 
@@ -1668,6 +1671,8 @@
         return D3D_OK;
     }
 
+    ENTER_GL();
+
     /* Diffuse: */
     colRGBA[0] = pLight->Diffuse.r;
     colRGBA[1] = pLight->Diffuse.g;
@@ -1780,6 +1785,8 @@
     /* Restore the modelview matrix */
     glPopMatrix();
 
+    LEAVE_GL();
+
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight) {
@@ -1812,7 +1819,8 @@
         TRACE("Recording... not performing anything\n");
         return D3D_OK;
     }
-
+    
+    ENTER_GL();
     if (Enable) {
         glEnable(GL_LIGHT0 + Index);
         checkGLcall("glEnable GL_LIGHT0+Index");
@@ -1820,6 +1828,8 @@
         glDisable(GL_LIGHT0 + Index);
         checkGLcall("glDisable GL_LIGHT0+Index");
     }
+    LEAVE_GL();
+
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL* pEnable) {
@@ -1859,6 +1869,8 @@
 
     /* Apply it */
 
+    ENTER_GL();
+
     /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
     glMatrixMode(GL_MODELVIEW);
     glPushMatrix();
@@ -1874,6 +1886,8 @@
     glPopMatrix();
     checkGLcall("glClipPlane");
 
+    LEAVE_GL();
+
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,float* pPlane) {
@@ -1907,6 +1921,8 @@
         return D3D_OK;
     }
 
+    ENTER_GL();
+
     switch (State) {
     case D3DRS_FILLMODE                  :
         switch ((D3DFILLMODE) Value) {
@@ -1987,6 +2003,8 @@
             break;
         case D3DSHADE_PHONG:
             FIXME("D3DSHADE_PHONG isnt supported?\n");
+
+	    LEAVE_GL();
             return D3DERR_INVALIDCALL;
         default:
             FIXME("Unrecognized/Unhandled D3DSHADEMODE value %ld\n", Value);
@@ -2668,6 +2686,8 @@
         FIXME("(%p)->(%d,%ld) unrecognized\n", This, State, Value);
     }
 
+    LEAVE_GL();
+
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD* pValue) {
@@ -2775,6 +2795,8 @@
         return D3D_OK;
     }
 
+    ENTER_GL();
+
     /* Make appropriate texture active */
     if (GL_SUPPORT(ARB_MULTITEXTURE)) {
 #if defined(GL_VERSION_1_3)
@@ -2850,7 +2872,9 @@
     if (reapplyStates) {
        setupTextureStates(iface, Stage);
     }
-       
+
+    LEAVE_GL();   
+
     return D3D_OK;
 }
 
@@ -2884,6 +2908,8 @@
         return D3D_OK;
     }
 
+    ENTER_GL();
+
     /* Make appropriate texture active */
     VTRACE(("Activating appropriate texture state %ld\n", Stage));
     if (GL_SUPPORT(ARB_MULTITEXTURE)) {
@@ -3284,6 +3310,9 @@
         /* Put back later: FIXME("(%p) : stub, Stage=%ld, Type=%d, Value =%ld\n", This, Stage, Type, Value); */
         TRACE("Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
     }
+
+    LEAVE_GL();
+
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses) {
@@ -3314,8 +3343,12 @@
     ICOM_THIS(IDirect3DDevice8Impl,iface);
     FIXME("(%p) : Setting to (%u)\n", This, PaletteNumber);
     This->currentPalette = PaletteNumber;
+
 #if defined(GL_EXT_paletted_texture)
     if (GL_SUPPORT(EXT_PALETTED_TEXTURE)) {
+
+      ENTER_GL();
+
       GL_EXTCALL(glColorTableEXT)(GL_TEXTURE_2D,    /* target */
 				  GL_RGBA,          /* internal format */
 				  256,              /* table size */
@@ -3323,6 +3356,9 @@
 				  GL_UNSIGNED_BYTE, /* table type */
 				  This->palettes[PaletteNumber]);
       checkGLcall("glColorTableEXT");
+
+      LEAVE_GL();
+
     } else {
       /* Delayed palette handling ... waiting for software emulation into preload code */
     }
@@ -3430,7 +3466,7 @@
     HRESULT res;
     UINT i;
 
-    TRACE_(d3d_shader)("(%p) : VertexShader not fully supported yet : Decl=%p, Func=%p\n", This, pDeclaration, pFunction);    
+    TRACE_(d3d_shader)("(%p) : VertexShader not fully supported yet : Decl=%p, Func=%p, Usage=%lu\n", This, pDeclaration, pFunction, Usage);
     if (NULL == pDeclaration || NULL == pHandle) { /* pFunction can be NULL see MSDN */
       return D3DERR_INVALIDCALL;
     }
@@ -3891,6 +3927,9 @@
 HRESULT WINAPI IDirect3DDevice8Impl_CleanRender(LPDIRECT3DDEVICE8 iface) {
   ICOM_THIS(IDirect3DDevice8Impl,iface);
 #if defined(GL_VERSION_1_3) /* @see comments on ActiveRender */
+
+  ENTER_GL();
+
 #if 0
   if (This->glCtx != This->render_ctx) {
     glXDestroyContext(This->display, This->render_ctx);
@@ -3901,6 +3940,9 @@
     glXDestroyPbuffer(This->display, This->drawable);
     This->drawable = This->win;
   }
+
+  LEAVE_GL();
+
 #endif
   return D3D_OK;
 }
@@ -3909,6 +3951,7 @@
 						IDirect3DSurface8* RenderSurface, 
 						IDirect3DSurface8* StencilSurface) {
 
+  HRESULT ret =  D3DERR_INVALIDCALL; 
   /**
    * Currently only active for GLX >= 1.3
    * for others versions we'll have to use GLXPixmaps
@@ -3918,7 +3961,6 @@
    * so only check OpenGL version
    */
 #if defined(GL_VERSION_1_3) 
-
   GLXFBConfig* cfgs = NULL;
   int nCfgs = 0;
   int attribs[256];
@@ -4022,6 +4064,8 @@
 
   PUSH1(None);
   
+  ENTER_GL();
+
   cfgs = glXChooseFBConfig(This->display, DefaultScreen(This->display), attribs, &nCfgs);
   if (NULL != cfgs) {
 #if 0
@@ -4096,7 +4140,7 @@
     if (NULL != This->stencilBufferTarget) IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->stencilBufferTarget);
     if (NULL != tmp) IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
 
-    return D3D_OK;
+    ret = D3D_OK;
 
   } else {
     ERR("cannot get valides GLXFBConfig for (%u,%s)/(%u,%s)\n", BackBufferFormat, debug_d3dformat(BackBufferFormat), StencilBufferFormat, debug_d3dformat(StencilBufferFormat));
@@ -4105,7 +4149,9 @@
 #undef PUSH1
 #undef PUSH2
 
+  LEAVE_GL();
+
 #endif
 
-  return D3DERR_INVALIDCALL;
+  return ret;
 }
Index: drawprim.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/drawprim.c,v
retrieving revision 1.1
diff -u -r1.1 drawprim.c
--- drawprim.c	13 Jun 2003 18:09:05 -0000	1.1
+++ drawprim.c	16 Jun 2003 23:57:08 -0000
@@ -1295,7 +1295,8 @@
         drawStridedSoftwareVS(iface, &dataLocations, PrimitiveType, NumPrimitives, 
                         idxData, idxSize, minIndex, StartIdx);            
 
-    } else if ((dataLocations.u.s.pSize.lpData        != NULL) || 
+    } else if (/*TRUE ||*/
+	       (dataLocations.u.s.pSize.lpData        != NULL) || 
                (dataLocations.u.s.diffuse.lpData      != NULL) || 
                (dataLocations.u.s.blendWeights.lpData != NULL)) {
 
Index: stateblock.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/stateblock.c,v
retrieving revision 1.7
diff -u -r1.7 stateblock.c
--- stateblock.c	4 Jun 2003 22:02:06 -0000	1.7
+++ stateblock.c	16 Jun 2003 23:57:10 -0000
@@ -198,6 +198,8 @@
        texture stage, but disable all stages by default. Hence if a stage is enabled
        then the default texture will kick in until replaced by a SetTexture call     */
 
+    ENTER_GL();
+
     for (i = 0; i < GL_LIMITS(textures); i++) {
         GLubyte white = 255;
 
@@ -234,6 +236,8 @@
         /* Reapply all the texture state information to this texture */
         setupTextureStates(iface, i);
     }
+
+    LEAVE_GL();
 
     /* defaulting palettes */
     for (i = 0; i < MAX_PALETTES; ++i) {
Index: surface.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/surface.c,v
retrieving revision 1.18
diff -u -r1.18 surface.c
--- surface.c	16 Jun 2003 20:20:25 -0000	1.18
+++ surface.c	16 Jun 2003 23:57:11 -0000
@@ -209,7 +209,9 @@
 
 	glReadBuffer(prev_read);
 	vcheckGLcall("glReadBuffer");
+
 	LEAVE_GL();
+
       } else {
 	FIXME("unsupported locking to Rendering surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
       }
@@ -341,6 +343,7 @@
 	vcheckGLcall("glDrawBuffer");
 	glRasterPos3iv(&prev_rasterpos[0]);
 	vcheckGLcall("glRasterPos3iv");
+
 	LEAVE_GL();
 
 	/** restore clean dirty state */
@@ -412,6 +415,8 @@
       else
 	*dst++ = 0xFF; 
     }
+
+    ENTER_GL();
     
     TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
 	  gl_target,
@@ -435,6 +440,8 @@
     checkGLcall("glTexImage2D");
     HeapFree(GetProcessHeap(), 0, surface);
 
+    LEAVE_GL();
+
     return D3D_OK;    
   }
 
@@ -452,6 +459,9 @@
 	    0, 
 	    This->myDesc.Size,
 	    This->allocatedMemory);
+      
+      ENTER_GL();
+
       glCompressedTexImage2DARB(gl_target, 
 				gl_level, 
 				D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
@@ -461,6 +471,8 @@
 				This->myDesc.Size,
 				This->allocatedMemory);
       checkGLcall("glCommpressedTexTexImage2D");
+
+      LEAVE_GL();
     }
 #endif
   } else {
@@ -474,6 +486,9 @@
 	  D3DFmt2GLFmt(This->Device, This->myDesc.Format), 
 	  D3DFmt2GLType(This->Device, This->myDesc.Format),
 	  This->allocatedMemory);
+
+    ENTER_GL();
+
     glTexImage2D(gl_target, 
 		 gl_level,
 		 D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
@@ -484,6 +499,8 @@
 		 D3DFmt2GLType(This->Device, This->myDesc.Format),
 		 This->allocatedMemory);
     checkGLcall("glTexImage2D");
+
+    LEAVE_GL();
 
 #if 0
     {
Index: texture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/texture.c,v
retrieving revision 1.11
diff -u -r1.11 texture.c
--- texture.c	4 Jun 2003 23:05:46 -0000	1.11
+++ texture.c	16 Jun 2003 23:57:12 -0000
@@ -110,6 +110,9 @@
     int i;
     ICOM_THIS(IDirect3DTexture8Impl,iface);
     TRACE("(%p) : About to load texture\n", This);
+
+    ENTER_GL();
+
     for (i = 0; i < This->levels; i++) {
       if (i == 0 && This->surfaces[i]->textureName != 0 && This->Dirty == FALSE) {
 	glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName);
@@ -139,6 +142,9 @@
 	This->Dirty = FALSE;
       }
     }
+
+    LEAVE_GL();
+
     return ;
 }
 D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
Index: utils.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/utils.c,v
retrieving revision 1.7
diff -u -r1.7 utils.c
--- utils.c	13 Jun 2003 19:14:34 -0000	1.7
+++ utils.c	16 Jun 2003 23:57:15 -0000
@@ -691,6 +691,8 @@
         TRACE("Alpha?(%d), Stage:%d Op(%d), a1(%ld), a2(%ld), a3(%ld)\n", isAlpha, Stage, op, arg1, arg2, arg3);
         if (op == D3DTOP_DISABLE) return;
 
+	ENTER_GL();
+
         /* Note: Operations usually involve two ars, src0 and src1 and are operations of
            the form (a1 <operation> a2). However, some of the more complex operations
            take 3 parameters. Instead of the (sensible) addition of a3, Microsoft added  
@@ -1005,6 +1007,8 @@
                default:
                    FIXME("Cant have COMBINE4 and COMBINE in efferct together, thisop=%d, otherop=%ld, isAlpha(%d)\n", 
                               op, op2, isAlpha);
+
+		   LEAVE_GL();
                    return;
                }
            }
@@ -1013,6 +1017,8 @@
            if (combineOK == TRUE) {
 	       glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE));
 	       checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE)");
+
+	       LEAVE_GL();
 	       return;
            }
         }
@@ -1253,9 +1259,13 @@
         if (Handled) {
 	    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
 	    checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
-            return;
+
+	    LEAVE_GL();
+	    return;
         }
 #endif /* GL_NV_texture_env_combine4 */
+
+	LEAVE_GL();
 
         /* After all the extensions, if still unhandled, report fixme */
         FIXME("Unhandled texture operation %d\n", op);
Index: volumetexture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/volumetexture.c,v
retrieving revision 1.11
diff -u -r1.11 volumetexture.c
--- volumetexture.c	4 Jun 2003 23:05:46 -0000	1.11
+++ volumetexture.c	16 Jun 2003 23:57:15 -0000
@@ -114,6 +114,9 @@
     int i;
     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
     TRACE("(%p) : About to load texture\n", This);
+
+    ENTER_GL();
+
     for (i = 0; i < This->levels; i++) {
       if (i == 0 && This->volumes[i]->textureName != 0 && This->Dirty == FALSE) {
 	glBindTexture(GL_TEXTURE_3D, This->volumes[i]->textureName);
@@ -164,6 +167,9 @@
 	This->Dirty = FALSE;
       }
     }
+
+    LEAVE_GL();
+
     return ;
 }
 D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux