PATCH : texture -> device association + misc fixes

Christian Costa titan.costa at wanadoo.fr
Wed Oct 16 06:35:55 CDT 2002


Modified files :
dlls/ddraw/d3d_private.h
dlls/ddraw/d3dtexture.c
dlls/ddraw/d3ddevice/main.c
dlls/ddraw/d3ddevice/mesa.c

Changelog :
Associate texture to the device when GetHandle is called
and perform the appropriate AddRef/Release.
Fix 3_3_2 pixel format.
Move some ENTER_GL() calls to the right place.
Fix some FIXME/TRACE calls.

Christian Costa   titan.costa at wanadoo.fr

-------------- next part --------------
Index: d3d_private.h
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3d_private.h,v
retrieving revision 1.8
diff -u -r1.8 d3d_private.h
--- d3d_private.h	10 Oct 2002 22:47:02 -0000	1.8
+++ d3d_private.h	16 Oct 2002 11:01:40 -0000
@@ -358,6 +358,7 @@
 
     IDirect3DViewport2Impl*  viewport_list;
     IDirect3DViewport2Impl*  current_viewport;
+    IDirect3DTexture2Impl*   current_texture;
 
     void (*set_context)(IDirect3DDeviceImpl*);
     LPVOID		private;
@@ -377,6 +378,7 @@
 
     IDirect3DViewport2Impl* viewport_list;
     IDirect3DViewport2Impl* current_viewport;
+    IDirect3DTexture2Impl*  current_texture;
 
     void (*set_context)(IDirect3DDevice2Impl*);
     LPVOID		private;
Index: d3dtexture.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3dtexture.c,v
retrieving revision 1.14
diff -u -r1.14 d3dtexture.c
--- d3dtexture.c	25 Sep 2002 03:18:17 -0000	1.14
+++ d3dtexture.c	16 Oct 2002 11:01:43 -0000
@@ -298,13 +298,20 @@
     *lpHandle = (D3DTEXTUREHANDLE) This;
 
     /* Now, bind a new texture */
-    ENTER_GL();
     ilpD3DDevice->set_context(ilpD3DDevice);
     This->D3Ddevice = (void *) ilpD3DDevice;
+    ENTER_GL();
     if (dtpriv->tex_name == 0)
 	glGenTextures(1, &(dtpriv->tex_name));
     LEAVE_GL();
 
+    /* Associate the texture with the device and perform the appropriate AddRef/Release */
+    /* FIXME: Is there only one or several textures associated with the device ? */
+    if (ilpD3DDevice->current_texture)
+      IDirect3DTexture2Impl_Release((LPDIRECT3DTEXTURE2)ilpD3DDevice->current_texture);           
+    IDirect3DTexture2Impl_AddRef((LPDIRECT3DTEXTURE2)iface);
+    ilpD3DDevice->current_texture = (IDirect3DTexture2Impl*)iface;   
+
     TRACE("OpenGL texture handle is : %d\n", dtpriv->tex_name);
 
     return D3D_OK;
@@ -342,13 +349,20 @@
     *lpHandle = (D3DTEXTUREHANDLE) This;
 
     /* Now, bind a new texture */
-    ENTER_GL();
     ilpD3DDevice2->set_context(ilpD3DDevice2);
     This->D3Ddevice = (void *) ilpD3DDevice2;
+    ENTER_GL();
     if (dtpriv->tex_name == 0)
 	glGenTextures(1, &(dtpriv->tex_name));
     LEAVE_GL();
 
+    /* Associate the texture with the device and perform the appropriate AddRef/Release */
+    /* FIXME: Is there only one or several textures associated with the device ? */
+    if (ilpD3DDevice2->current_texture)
+      IDirect3DTexture2Impl_Release((LPDIRECT3DTEXTURE2)ilpD3DDevice2->current_texture);           
+    IDirect3DTexture2Impl_AddRef(iface);
+    ilpD3DDevice2->current_texture = (IDirect3DTexture2Impl*)iface;   
+
     TRACE("OpenGL texture handle is : %d\n", dtpriv->tex_name);
 
     return D3D_OK;
@@ -430,7 +444,7 @@
       /* ****************
 	 Paletted Texture
 	 **************** */
-      IDirectDrawPaletteImpl* pal = This->surface->palette;
+      IDirectDrawPaletteImpl* pal = ilpD3DTexture2->surface->palette;
       BYTE table[256][4];
       int i;
 
Index: d3ddevice/main.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3ddevice/main.c,v
retrieving revision 1.11
diff -u -r1.11 main.c
--- d3ddevice/main.c	30 Sep 2002 18:52:06 -0000	1.11
+++ d3ddevice/main.c	16 Oct 2002 11:01:44 -0000
@@ -58,9 +58,13 @@
 ULONG WINAPI IDirect3DDevice2Impl_Release(LPDIRECT3DDEVICE2 iface)
 {
     ICOM_THIS(IDirect3DDevice2Impl,iface);
-    FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
+    TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
 
     if (!--(This->ref)) {
+	/* Release texture associated with the device */ 
+	if (This->current_texture)
+	    IDirect3DTexture2Impl_Release((LPDIRECT3DTEXTURE2)This->current_texture);
+	    	  
 	HeapFree(GetProcessHeap(),0,This);
 	return 0;
     }
@@ -108,7 +112,7 @@
 ) {
     ICOM_THIS(IDirect3DDevice2Impl,iface);
     IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
-    FIXME("(%p)->(%p): stub\n", This, ilpvp);
+    TRACE("(%p)->(%p)\n", This, ilpvp);
 
     /* Adds this viewport to the viewport list */
     ilpvp->next = This->viewport_list;
@@ -123,7 +127,7 @@
     ICOM_THIS(IDirect3DDevice2Impl,iface);
     IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
     IDirect3DViewport2Impl *cur, *prev;
-    FIXME("(%p)->(%p): stub\n", This, lpvp);
+    TRACE("(%p)->(%p)\n", This, lpvp);
 
     /* Finds this viewport in the list */
     prev = NULL;
@@ -150,7 +154,7 @@
     ICOM_THIS(IDirect3DDevice2Impl,iface);
     IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
     IDirect3DViewport2Impl** ilplpvp=(IDirect3DViewport2Impl**)lplpvp;
-    FIXME("(%p)->(%p,%p,%08lx): stub\n", This, lpvp, lpvp, dwFlags);
+    TRACE("(%p)->(%p,%p,%08lx)\n", This, lpvp, lpvp, dwFlags);
 
     switch (dwFlags) {
     case D3DNEXT_NEXT:
@@ -204,7 +208,7 @@
     LPDIRECT3DDEVICE2 iface, LPDIRECT3D2 *lpd3d2
 ) {
     ICOM_THIS(IDirect3DDevice2Impl,iface);
-    TRACE("(%p)->(%p): stub\n", This, lpd3d2);
+    TRACE("(%p)->(%p)\n", This, lpd3d2);
     *lpd3d2 = (LPDIRECT3D2)This->d3d;
     return DD_OK;
 }
@@ -215,7 +219,7 @@
 ) {
     ICOM_THIS(IDirect3DDevice2Impl,iface);
     IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
-    FIXME("(%p)->(%p): stub\n", This, ilpvp);
+    TRACE("(%p)->(%p)\n", This, ilpvp);
 
     /* Should check if the viewport was added or not */
 
@@ -256,7 +260,7 @@
     LPDIRECT3DDEVICE2 iface, LPDIRECTDRAWSURFACE *lplpdds
 ) {
     ICOM_THIS(IDirect3DDevice2Impl,iface);
-    FIXME("(%p)->(%p): stub\n", This, lplpdds);
+    TRACE("(%p)->(%p)\n", This, lplpdds);
 
     /* Returns the current rendering target (the surface on wich we render) */
     *lplpdds = (LPDIRECTDRAWSURFACE)This->surface;
@@ -385,7 +389,7 @@
 ) {
   ICOM_THIS(IDirect3DDevice2Impl,iface);
 
-  TRACE("(%p)->(%d,%d,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, dwFlags);
+  FIXME("(%p)->(%d,%d,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, dwFlags);
 
   return D3D_OK;
 }
@@ -396,7 +400,7 @@
     DWORD dwFlags
 ) {
     ICOM_THIS(IDirect3DDevice2Impl,iface);
-    TRACE("(%p)->(%d,%d,%p,%ld,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, lpindexes, indexcount, dwFlags);
+    FIXME("(%p)->(%d,%d,%p,%ld,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, lpindexes, indexcount, dwFlags);
     return D3D_OK;
 }
 
@@ -440,9 +444,13 @@
 ULONG WINAPI IDirect3DDeviceImpl_Release(LPDIRECT3DDEVICE iface)
 {
     ICOM_THIS(IDirect3DDeviceImpl,iface);
-    FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
+    TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
 
     if (!--(This->ref)) {
+	/* Release texture associated with the device */ 
+	if (This->current_texture)
+	    IDirect3DTexture2Impl_Release((LPDIRECT3DTEXTURE2)This->current_texture);
+	    
 	HeapFree(GetProcessHeap(),0,This);
 	return 0;
     }
@@ -454,7 +462,7 @@
     LPD3DDEVICEDESC lpd3ddvdesc
 ) {
     ICOM_THIS(IDirect3DDeviceImpl,iface);
-    TRACE("(%p)->(%p,%p,%p): stub\n", This, lpd3d,lpGUID, lpd3ddvdesc);
+    FIXME("(%p)->(%p,%p,%p): stub\n", This, lpd3d,lpGUID, lpd3ddvdesc);
 
     return DDERR_ALREADYINITIALIZED;
 }
@@ -465,7 +473,7 @@
     LPD3DDEVICEDESC lpD3DSWDevDesc
 ) {
     ICOM_THIS(IDirect3DDeviceImpl,iface);
-    TRACE("(%p)->(%p,%p): stub\n", This, lpD3DHWDevDesc, lpD3DSWDevDesc);
+    FIXME("(%p)->(%p,%p): stub\n", This, lpD3DHWDevDesc, lpD3DSWDevDesc);
 
     return DD_OK;
 }
@@ -499,7 +507,7 @@
     LPDIRECT3DDEVICE iface, LPD3DSTATS lpD3DStats
 ) {
     ICOM_THIS(IDirect3DDeviceImpl,iface);
-    TRACE("(%p)->(%p): stub\n", This, lpD3DStats);
+    FIXME("(%p)->(%p): stub\n", This, lpD3DStats);
 
     return DD_OK;
 }
@@ -510,7 +518,7 @@
     LPDIRECT3DVIEWPORT lpDirect3DViewport, DWORD dwFlags
 ) {
     ICOM_THIS(IDirect3DDeviceImpl,iface);
-    TRACE("(%p)->(%p,%p,%08ld): stub\n", This, lpDirect3DExecuteBuffer, lpDirect3DViewport, dwFlags);
+    TRACE("(%p)->(%p,%p,%08ld)\n", This, lpDirect3DExecuteBuffer, lpDirect3DViewport, dwFlags);
 
     /* Put this as the default context */
 
@@ -525,7 +533,7 @@
 ) {
     ICOM_THIS(IDirect3DDeviceImpl,iface);
     IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
-    FIXME("(%p)->(%p): stub\n", This, ilpvp);
+    TRACE("(%p)->(%p)\n", This, ilpvp);
 
     /* Adds this viewport to the viewport list */
     ilpvp->next = This->viewport_list;
@@ -542,7 +550,7 @@
     ICOM_THIS(IDirect3DDeviceImpl,iface);
     IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
     IDirect3DViewport2Impl *cur, *prev;
-    FIXME("(%p)->(%p): stub\n", This, lpvp);
+    TRACE("(%p)->(%p)\n", This, lpvp);
 
     /* Finds this viewport in the list */
     prev = NULL;
@@ -569,7 +577,7 @@
     ICOM_THIS(IDirect3DDeviceImpl,iface);
     IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
     IDirect3DViewport2Impl** ilplpvp=(IDirect3DViewport2Impl**)lplpvp;
-    FIXME("(%p)->(%p,%p,%08lx): stub\n", This, ilpvp, ilplpvp, dwFlags);
+    TRACE("(%p)->(%p,%p,%08lx)\n", This, ilpvp, ilplpvp, dwFlags);
 
     switch (dwFlags) {
     case D3DNEXT_NEXT:
@@ -603,7 +611,7 @@
     LPDIRECT3DDEVICE iface, LPDWORD lpCount, LPD3DPICKRECORD lpD3DPickRec
 ) {
     ICOM_THIS(IDirect3DDeviceImpl,iface);
-    TRACE("(%p)->(%p,%p): stub\n", This, lpCount, lpD3DPickRec);
+    FIXME("(%p)->(%p,%p): stub\n", This, lpCount, lpD3DPickRec);
 
     return DD_OK;
 }
@@ -614,7 +622,7 @@
     LPVOID lpArg
 ) {
     ICOM_THIS(IDirect3DDeviceImpl,iface);
-    TRACE("(%p)->(%p,%p): stub\n", This, lpd3dEnumTextureProc, lpArg);
+    FIXME("(%p)->(%p,%p): stub\n", This, lpd3dEnumTextureProc, lpArg);
     return D3D_OK;
 }
 
@@ -687,7 +695,7 @@
     LPDIRECT3DDEVICE iface, LPDIRECT3D *lpDirect3D
 ) {
     ICOM_THIS(IDirect3DDeviceImpl,iface);
-    TRACE("(%p)->(%p): stub\n", This, lpDirect3D);
+    FIXME("(%p)->(%p): stub\n", This, lpDirect3D);
 
     return DD_OK;
 }
Index: d3ddevice/mesa.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/d3ddevice/mesa.c,v
retrieving revision 1.19
diff -u -r1.19 mesa.c
--- d3ddevice/mesa.c	27 Sep 2002 22:01:12 -0000	1.19
+++ d3ddevice/mesa.c	16 Oct 2002 11:01:46 -0000
@@ -225,6 +225,7 @@
     (*device)->surface = surface;
     (*device)->viewport_list = NULL;
     (*device)->current_viewport = NULL;
+    (*device)->current_texture = NULL;
     (*device)->set_context = set_context;
 
     TRACE("Creating OpenGL device for surface %p\n", surface);
@@ -401,10 +402,10 @@
   TRACE("Enumerating GL_RGB packed GL_UNSIGNED_BYTE_3_3_2 (8)\n");
   pformat->dwFlags = DDPF_RGB;
   pformat->u1.dwRGBBitCount = 8;
-  pformat->u2.dwRBitMask =         0x0000F800;
-  pformat->u3.dwGBitMask =         0x000007C0;
-  pformat->u4.dwBBitMask =        0x0000003E;
-  pformat->u5.dwRGBAlphaBitMask = 0x00000001;
+  pformat->u2.dwRBitMask =        0x000000E0;
+  pformat->u3.dwGBitMask =        0x0000001C;
+  pformat->u4.dwBBitMask =        0x00000003;
+  pformat->u5.dwRGBAlphaBitMask = 0x00000000;
   if (cb(&sdesc, context) == 0)
     return DD_OK;
 #endif
@@ -891,6 +892,7 @@
 
     (*device)->viewport_list = NULL;
     (*device)->current_viewport = NULL;
+    (*device)->current_texture = NULL;
 
     (*device)->set_context = (void*)set_context;
 


More information about the wine-patches mailing list