[dx50] some textures fixes

Raphaël Junqueira fenix at club-internet.fr
Mon Jun 2 19:58:41 CDT 2003


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

Hi,

Now cleaning the texture management code and add some usefull attributes for 
optimisations.

Changelog:
 - cleaning of volume.c/volumtexture.c as done previously for 
surface.c/*texture.c (with add of lockable, locked and Dirty flags)
 - add of dirtyRect/dirtyBox for better dirtification management (not used 
yet, but huge optimisation can be possible now)
 - fix some debug traces (well it's better to use debug_d3dpool)
 - fix some stupid regression on point parameters (forgot to check extension 
on fillcaps)

PS: it's possible to have multiple locks on surface/volumes ?

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

iD8DBQE+2/LBp7NA3AmQTU4RAuUDAJ4sJjRrFtLDr2vGaEToFu9JX4NZ6ACeIzNF
idvJ5gl1FwbipkCyc8/d4gg=
=WBzf
-----END PGP SIGNATURE-----
-------------- next part --------------
diff -u /cvs-src/wine-pending/d3d8_49/basetexture.c dlls/d3d8/basetexture.c
--- /cvs-src/wine-pending/d3d8_49/basetexture.c	2003-06-03 02:40:48.000000000 +0200
+++ dlls/d3d8/basetexture.c	2003-06-03 01:22:37.000000000 +0200
@@ -123,21 +123,6 @@
     return 0;
 }
 
-BOOL WINAPI IDirect3DBaseTexture8Impl_IsDirty(LPDIRECT3DBASETEXTURE8 iface) {
-    ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
-    return This->Dirty;
-}
-
-BOOL WINAPI IDirect3DBaseTexture8Impl_SetDirty(LPDIRECT3DBASETEXTURE8 iface, BOOL dirty) {
-    BOOL old;
-    ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
-    
-    old = This->Dirty;
-    This->Dirty = dirty;
-    return old;
-}
-
-
 ICOM_VTABLE(IDirect3DBaseTexture8) Direct3DBaseTexture8_Vtbl =
 {
     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
@@ -156,3 +141,17 @@
     IDirect3DBaseTexture8Impl_GetLOD,
     IDirect3DBaseTexture8Impl_GetLevelCount,
 };
+
+BOOL WINAPI IDirect3DBaseTexture8Impl_IsDirty(LPDIRECT3DBASETEXTURE8 iface) {
+    ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
+    return This->Dirty;
+}
+
+BOOL WINAPI IDirect3DBaseTexture8Impl_SetDirty(LPDIRECT3DBASETEXTURE8 iface, BOOL dirty) {
+    BOOL old;
+    ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
+    
+    old = This->Dirty;
+    This->Dirty = dirty;
+    return old;
+}
diff -u /cvs-src/wine-pending/d3d8_49/cubetexture.c dlls/d3d8/cubetexture.c
--- /cvs-src/wine-pending/d3d8_49/cubetexture.c	2003-06-03 02:40:48.000000000 +0200
+++ dlls/d3d8/cubetexture.c	2003-06-03 01:55:12.000000000 +0200
@@ -175,28 +175,6 @@
 	for (j = 0; j < 6; j++) {
 	  IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[j][i], cube_targets[j], i); 
 #if 0
-	  TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, glFmt=%x, glType=%x, Mem=%p\n",
-		cube_targets[j], 
-		i, 
-		fmt2glintFmt(This->format), 
-		This->surfaces[j][i]->myDesc.Width, 
-		This->surfaces[j][i]->myDesc.Height, 
-		0, 
-		fmt2glFmt(This->format), 
-		fmt2glType(This->format),
-		This->surfaces[j][i]->allocatedMemory);
-	  glTexImage2D(cube_targets[j],
-		       i,
-		       fmt2glintFmt(This->format),
-		       This->surfaces[j][i]->myDesc.Width,
-		       This->surfaces[j][i]->myDesc.Height,
-		       0,
-		       fmt2glFmt(This->format),
-		       fmt2glType(This->format),
-		       This->surfaces[j][i]->allocatedMemory);
-	  checkGLcall("glTexImage2D");
-#endif
-#if 0
 	  static int gen = 0;
 	  char buffer[4096];
 	  snprintf(buffer, sizeof(buffer), "/tmp/cube%d_face%d_level%d_%d.png", This->surfaces[0][0]->textureName, j, i, ++gen);
@@ -266,7 +244,7 @@
        * Not dirtified while Surfaces don't notify dirtification
        * This->Dirty = TRUE;
        */
-      hr = IDirect3DSurface8_LockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level], pLockedRect, pRect, Flags);
+      hr = IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level], pLockedRect, pRect, Flags);
       TRACE("(%p) -> faceType(%d) level(%d) returning memory@%p success(%lu)\n", This, FaceType, Level, pLockedRect->pBits, hr);
     } else {
       FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
@@ -278,8 +256,8 @@
     HRESULT hr;
     ICOM_THIS(IDirect3DCubeTexture8Impl,iface);
     if (Level < This->levels) {
-      hr = IDirect3DSurface8_UnlockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level]);
-      FIXME("(%p) -> faceType(%d) level(%d) success(%lu)\n", This, FaceType, Level, hr);
+      hr = IDirect3DSurface8Impl_UnlockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level]);
+      TRACE("(%p) -> faceType(%d) level(%d) success(%lu)\n", This, FaceType, Level, hr);
     } else {
       FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
       return D3DERR_INVALIDCALL;
@@ -289,8 +267,8 @@
 HRESULT  WINAPI        IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
     ICOM_THIS(IDirect3DCubeTexture8Impl,iface);
     This->Dirty = TRUE;
-    FIXME("(%p) : stub\n", This);
-    return D3D_OK;
+    TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);    
+    return IDirect3DSurface8Impl_AddDirtyRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][0], pDirtyRect);
 }
 
 
Les sous-répertoires /cvs-src/wine-pending/d3d8_49/CVS et dlls/d3d8/CVS sont identiques.
diff -u /cvs-src/wine-pending/d3d8_49/d3d8_private.h dlls/d3d8/d3d8_private.h
--- /cvs-src/wine-pending/d3d8_49/d3d8_private.h	2003-06-03 02:44:22.000000000 +0200
+++ dlls/d3d8/d3d8_private.h	2003-06-03 01:31:50.000000000 +0200
@@ -495,6 +495,12 @@
     BYTE                   *allocatedMemory;
     UINT                    textureName;
     UINT                    bytesPerPixel;
+
+    BOOL                    lockable;
+    BOOL                    locked;
+    D3DBOX                  lockedBox;
+    D3DBOX                  dirtyBox;
+    BOOL                    Dirty;
 };
 
 /* IUnknown: */
@@ -509,9 +515,12 @@
 extern HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid);
 extern HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void** ppContainer);
 extern HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC* pDesc);
-extern HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox, DWORD Flags);
+extern HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags);
 extern HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface);
 
+/* internal Interfaces */
+extern HRESULT WINAPI IDirect3DVolume8Impl_CleanDirtyBox(LPDIRECT3DVOLUME8 iface);
+extern HRESULT WINAPI IDirect3DVolume8Impl_AddDirtyBox(LPDIRECT3DVOLUME8 iface, CONST D3DBOX* pDirtyBox);
 
 /* ------------------- */
 /* IDirect3DSwapChain8 */
@@ -540,7 +549,6 @@
     /* OpenGL/GLX related */
     GLXContext              swap_ctx;
     Drawable                swap_drawable;
-    
 };
 
 /* IUnknown: */
@@ -584,8 +592,8 @@
     BOOL                    lockable;
     BOOL                    locked;
     RECT                    lockedRect;
+    RECT                    dirtyRect;
     BOOL                    Dirty;
-
 };
 
 /* IUnknown: */
@@ -606,7 +614,8 @@
 /* internal Interfaces */
 extern HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level);
 extern HRESULT WINAPI IDirect3DSurface8Impl_SaveSnapshot(LPDIRECT3DSURFACE8 iface, const char* filename);
-
+extern HRESULT WINAPI IDirect3DSurface8Impl_CleanDirtyRect(LPDIRECT3DSURFACE8 iface);
+extern HRESULT WINAPI IDirect3DSurface8Impl_AddDirtyRect(LPDIRECT3DSURFACE8 iface, CONST RECT* pDirtyRect);
 
 /* ------------------ */
 /* IDirect3DResource8 */
diff -u /cvs-src/wine-pending/d3d8_49/device.c dlls/d3d8/device.c
--- /cvs-src/wine-pending/d3d8_49/device.c	2003-06-03 02:44:22.000000000 +0200
+++ dlls/d3d8/device.c	2003-06-03 02:13:03.000000000 +0200
@@ -1411,7 +1411,7 @@
     ICOM_THIS(IDirect3DDevice8Impl,iface);
 
     /* Allocate the storage for it */
-    TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%d)\n", This, Width, Height, Depth, Levels, Usage, Format, debug_d3dformat(Format), Pool);
+    TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%s)\n", This, Width, Height, Depth, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture8Impl));
     object->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
     object->ResourceType = D3DRTYPE_VOLUMETEXTURE;
@@ -1470,6 +1470,12 @@
         volume->myDesc.Size     = (Width * volume->bytesPerPixel) * Height * Depth;
         volume->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->myDesc.Size);
 
+	volume->lockable = TRUE;
+	volume->locked = FALSE;
+	memset(&volume->lockedBox, 0, sizeof(D3DBOX));
+	volume->Dirty = FALSE;
+	IDirect3DVolume8Impl_CleanDirtyBox((LPDIRECT3DVOLUME8) volume);
+
         TRACE("(%p) : Volume at w(%d) h(%d) d(%d) fmt(%u,%s) surf@%p, surfmem@%p, %d bytes\n", 
               This, Width, Height, Depth, Format, debug_d3dformat(Format),
               volume, volume->allocatedMemory, volume->myDesc.Size);
@@ -1491,7 +1497,7 @@
     UINT tmpW;
 
     /* Allocate the storage for it */
-    TRACE("(%p) : Len(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%d)\n", This, EdgeLength, Levels, Usage, Format, debug_d3dformat(Format), Pool);
+    TRACE("(%p) : Len(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%s)\n", This, EdgeLength, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DCubeTexture8Impl));
     object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
     object->ref = 1;
@@ -1537,7 +1543,7 @@
     }
 
     TRACE("(%p) : Iface@%p\n", This, object);
-    *ppCubeTexture = (LPDIRECT3DCUBETEXTURE8)object;
+    *ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object;
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) {
@@ -1559,7 +1565,7 @@
 
     TRACE("(%p) : Size=%d, Usage=%ld, FVF=%lx, Pool=%d - Memory@%p, Iface@%p\n", This, Size, Usage, FVF, Pool, object->allocatedMemory, object);
 
-    *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER8)object;
+    *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER8) object;
 
     return D3D_OK;
 }
@@ -1586,7 +1592,7 @@
 
     TRACE("(%p) : Iface@%p allocatedMem @ %p\n", This, object, object->allocatedMemory);
 
-    *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER8)object;
+    *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER8) object;
 
     return D3D_OK;
 }
@@ -1618,7 +1624,9 @@
     object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
     object->lockable = Lockable;
     object->locked = FALSE;
-    
+    memset(&object->lockedRect, 0, sizeof(RECT));
+    IDirect3DSurface8Impl_CleanDirtyRect((LPDIRECT3DSURFACE8) object);
+
     TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), Lockable, *ppSurface, object->allocatedMemory, object->myDesc.Size);
     return D3D_OK;
 }
@@ -1651,7 +1659,9 @@
     object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
     object->lockable = (D3DFMT_D16_LOCKABLE == Format) ? TRUE : FALSE;
     object->locked = FALSE;
-        
+    memset(&object->lockedRect, 0, sizeof(RECT));
+    IDirect3DSurface8Impl_CleanDirtyRect((LPDIRECT3DSURFACE8) object);
+
     TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->myDesc.Size);
     return D3D_OK;
 }
@@ -1679,6 +1689,8 @@
     object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
     object->lockable = TRUE;
     object->locked = FALSE;
+    memset(&object->lockedRect, 0, sizeof(RECT));
+    IDirect3DSurface8Impl_CleanDirtyRect((LPDIRECT3DSURFACE8) object);
 
     TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->myDesc.Size);
     return D3D_OK;
diff -u /cvs-src/wine-pending/d3d8_49/directx.c dlls/d3d8/directx.c
--- /cvs-src/wine-pending/d3d8_49/directx.c	2003-06-03 02:44:22.000000000 +0200
+++ dlls/d3d8/directx.c	2003-06-03 02:05:15.000000000 +0200
@@ -712,10 +712,12 @@
         } else if (strcmp(ThisExtn, "GL_EXT_fog_coord") == 0) {
 	  FIXME(" FOUND: EXT Fog coord support\n");
 	  This->gl_info.supported[EXT_FOG_COORD] = TRUE;
-        } else if (strcmp(ThisExtn, "GL_EXT_paletted_texture") == 0) {
-	  /* handle paletted texture extensions */
+        } else if (strcmp(ThisExtn, "GL_EXT_paletted_texture") == 0) { /* handle paletted texture extensions */
 	  FIXME(" FOUND: EXT Paletted texture support\n");
 	  This->gl_info.supported[EXT_PALETTED_TEXTURE] = TRUE;
+        } else if (strcmp(ThisExtn, "GL_EXT_point_parameters") == 0) {
+	  FIXME(" FOUND: EXT Point parameters support\n");
+	  This->gl_info.supported[EXT_POINT_PARAMETERS] = TRUE;
 	} else if (strcmp(ThisExtn, "GL_EXT_secondary_color") == 0) {
 	  FIXME(" FOUND: EXT Secondary coord support\n");
 	  This->gl_info.supported[EXT_SECONDARY_COLOR] = TRUE;
diff -u /cvs-src/wine-pending/d3d8_49/surface.c dlls/d3d8/surface.c
--- /cvs-src/wine-pending/d3d8_49/surface.c	2003-06-03 02:40:48.000000000 +0200
+++ dlls/d3d8/surface.c	2003-06-03 01:34:37.000000000 +0200
@@ -235,7 +235,8 @@
        * Dirtify on lock
        * as seen in msdn docs
        */
-      This->Dirty = TRUE;
+      IDirect3DSurface8Impl_AddDirtyRect(iface, &This->lockedRect);
+
       /** Dirtify Container if needed */
       if (NULL != This->Container) {
 	IDirect3DBaseTexture8* cont = NULL;
@@ -348,7 +349,8 @@
 	vcheckGLcall("glRasterPos3iv");
 	LEAVE_GL();
 
-	This->Dirty = FALSE;
+	/** restore clean dirty state */
+	IDirect3DSurface8Impl_CleanDirtyRect(iface);
 
       } else {
 	FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
@@ -368,6 +370,7 @@
 
 unlock_end:
     This->locked = FALSE;
+    memset(&This->lockedRect, 0, sizeof(RECT));
     return D3D_OK;
 }
 
@@ -583,3 +586,27 @@
   fclose(f);
   return D3D_OK;
 }
+
+HRESULT WINAPI IDirect3DSurface8Impl_CleanDirtyRect(LPDIRECT3DSURFACE8 iface) {
+  ICOM_THIS(IDirect3DSurface8Impl,iface);
+  This->Dirty = FALSE;
+  This->dirtyRect.left   = This->myDesc.Width;
+  This->dirtyRect.top    = This->myDesc.Height;
+  This->dirtyRect.right  = 0;
+  This->dirtyRect.bottom = 0;
+  return D3D_OK;
+}
+
+/**
+ * Raphael:
+ *   very stupid way to handle multiple dirty rects but it works :)
+ */
+extern HRESULT WINAPI IDirect3DSurface8Impl_AddDirtyRect(LPDIRECT3DSURFACE8 iface, CONST RECT* pDirtyRect) {
+  ICOM_THIS(IDirect3DSurface8Impl,iface);
+  This->Dirty = TRUE;
+  This->dirtyRect.left   = min(This->dirtyRect.left,   pDirtyRect->left);
+  This->dirtyRect.top    = min(This->dirtyRect.top,    pDirtyRect->top);
+  This->dirtyRect.right  = max(This->dirtyRect.right,  pDirtyRect->right);
+  This->dirtyRect.bottom = max(This->dirtyRect.bottom, pDirtyRect->bottom);
+  return D3D_OK;
+}
diff -u /cvs-src/wine-pending/d3d8_49/texture.c dlls/d3d8/texture.c
--- /cvs-src/wine-pending/d3d8_49/texture.c	2003-06-03 02:40:48.000000000 +0200
+++ dlls/d3d8/texture.c	2003-06-03 01:56:20.000000000 +0200
@@ -135,28 +135,6 @@
 	}
 
 	IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[i], GL_TEXTURE_2D, i); 
-#if 0
-	TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
-	      GL_TEXTURE_2D, 
-              i, 
-              D3DFmt2GLIntFmt(This->format),
-	      This->surfaces[i]->myDesc.Width, 
-              This->surfaces[i]->myDesc.Height, 
-	      0, 
-              D3DFmt2GLFmt(This->format), 
-              D3DFmt2GLType(This->format),
-	      This->surfaces[i]->allocatedMemory);
-	glTexImage2D(GL_TEXTURE_2D, 
-		     i,
-		     D3DFmt2GLIntFmt(This->format),
-		     This->surfaces[i]->myDesc.Width,
-		     This->surfaces[i]->myDesc.Height,
-		     0,
-		     D3DFmt2GLFmt(This->format),
-		     D3DFmt2GLType(This->format),
-		     This->surfaces[i]->allocatedMemory);
-	checkGLcall("glTexImage2D");
-#endif
 	/* Removed glTexParameterf now TextureStageStates are initialized at startup */
 	This->Dirty = FALSE;
       }
@@ -187,7 +165,7 @@
 }
 
 /* IDirect3DTexture8 */
-HRESULT  WINAPI        IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level,D3DSURFACE_DESC* pDesc) {
+HRESULT  WINAPI        IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
 
     if (Level < This->levels) {
@@ -199,7 +177,7 @@
     }
     return D3D_OK;
 }
-HRESULT  WINAPI        IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level,IDirect3DSurface8** ppSurfaceLevel) {
+HRESULT  WINAPI        IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8** ppSurfaceLevel) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
     *ppSurfaceLevel = (LPDIRECT3DSURFACE8)This->surfaces[Level];
     IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->surfaces[Level]);
@@ -239,8 +217,8 @@
 HRESULT  WINAPI        IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
     This->Dirty = TRUE;
-    FIXME("(%p) : stub\n", This);    
-    return D3D_OK;
+    TRACE("(%p) : dirtyfication of surface Level (0)\n", This);    
+    return IDirect3DSurface8Impl_AddDirtyRect((LPDIRECT3DSURFACE8) This->surfaces[0], pDirtyRect);
 }
 
 
diff -u /cvs-src/wine-pending/d3d8_49/volume.c dlls/d3d8/volume.c
--- /cvs-src/wine-pending/d3d8_49/volume.c	2003-06-03 02:40:48.000000000 +0200
+++ dlls/d3d8/volume.c	2003-06-03 01:47:51.000000000 +0200
@@ -116,12 +116,24 @@
     if (!pBox) {
         TRACE("No box supplied - all is ok\n");
         pLockedVolume->pBits = This->allocatedMemory;
+	This->lockedBox.Left   = 0;
+	This->lockedBox.Top    = 0;
+	This->lockedBox.Front  = 0;
+	This->lockedBox.Right  = This->myDesc.Width;
+	This->lockedBox.Bottom = This->myDesc.Height;
+	This->lockedBox.Back   = This->myDesc.Depth;
     } else {
         TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
         pLockedVolume->pBits = This->allocatedMemory + 
-            (pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
-            (pLockedVolume->RowPitch * pBox->Top) + 
-            (pBox->Left * This->bytesPerPixel);
+	  (pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
+	  (pLockedVolume->RowPitch * pBox->Top) + 
+	  (pBox->Left * This->bytesPerPixel);
+	This->lockedBox.Left   = pBox->Left;
+	This->lockedBox.Top    = pBox->Top;
+	This->lockedBox.Front  = pBox->Front;
+	This->lockedBox.Right  = pBox->Right;
+	This->lockedBox.Bottom = pBox->Bottom;
+	This->lockedBox.Back   = pBox->Back;
     }
     
     if (Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)) {
@@ -131,6 +143,8 @@
        * Dirtify on lock
        * as seen in msdn docs
        */
+      IDirect3DVolume8Impl_AddDirtyBox(iface, &This->lockedBox);
+
       /**  Dirtify Container if needed */
       if (NULL != This->Container) {
         IDirect3DVolumeTexture8* cont = (IDirect3DVolumeTexture8*) This->Container;	
@@ -144,24 +158,19 @@
       }
     }
 
+    This->locked = TRUE;
     TRACE("returning memory@%p rpitch(%d) spitch(%d)\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
     return D3D_OK;
 }
 HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
     ICOM_THIS(IDirect3DVolume8Impl,iface);
-    TRACE("(%p) : stub\n", This);
-#if 0
-    if (This->Container) {
-        IDirect3DVolumeTexture8* cont = (IDirect3DVolumeTexture8*) This->Container;
-        D3DRESOURCETYPE containerType = IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) cont);
-        if (containerType == D3DRTYPE_VOLUMETEXTURE) {
-            IDirect3DTexture8Impl* pTexture = (IDirect3DTexture8Impl*) cont;
-            pTexture->Dirty = TRUE;
-        } else {
-            FIXME("Set dirty on container type %d\n", containerType);
-        }
+    if (FALSE == This->locked) {
+      ERR("trying to lock unlocked volume@%p\n", This);  
+      return D3DERR_INVALIDCALL;
     }
-#endif
+    TRACE("(%p) : unlocking volume\n", This);
+    This->locked = FALSE;
+    memset(&This->lockedBox, 0, sizeof(RECT));
     return D3D_OK;
 }
 
@@ -181,3 +190,31 @@
     IDirect3DVolume8Impl_LockBox,
     IDirect3DVolume8Impl_UnlockBox
 };
+
+HRESULT WINAPI IDirect3DVolume8Impl_CleanDirtyBox(LPDIRECT3DVOLUME8 iface) {
+  ICOM_THIS(IDirect3DVolume8Impl,iface);
+  This->Dirty = FALSE;
+  This->lockedBox.Left   = This->myDesc.Width;
+  This->lockedBox.Top    = This->myDesc.Height;
+  This->lockedBox.Front  = This->myDesc.Depth;  
+  This->lockedBox.Right  = 0;
+  This->lockedBox.Bottom = 0;
+  This->lockedBox.Back   = 0;
+  return D3D_OK;
+}
+
+/**
+ * Raphael:
+ *   very stupid way to handle multiple dirty box but it works :)
+ */
+HRESULT WINAPI IDirect3DVolume8Impl_AddDirtyBox(LPDIRECT3DVOLUME8 iface, CONST D3DBOX* pDirtyBox) {
+  ICOM_THIS(IDirect3DVolume8Impl,iface);
+  This->Dirty = TRUE;
+  This->lockedBox.Left   = min(This->lockedBox.Left,   pDirtyBox->Left);
+  This->lockedBox.Top    = min(This->lockedBox.Top,    pDirtyBox->Top);
+  This->lockedBox.Front  = min(This->lockedBox.Front,  pDirtyBox->Front);
+  This->lockedBox.Right  = max(This->lockedBox.Right,  pDirtyBox->Right);
+  This->lockedBox.Bottom = max(This->lockedBox.Bottom, pDirtyBox->Bottom);
+  This->lockedBox.Back   = max(This->lockedBox.Back,   pDirtyBox->Back);
+  return D3D_OK;
+}
diff -u /cvs-src/wine-pending/d3d8_49/volumetexture.c dlls/d3d8/volumetexture.c
--- /cvs-src/wine-pending/d3d8_49/volumetexture.c	2003-06-03 02:40:48.000000000 +0200
+++ dlls/d3d8/volumetexture.c	2003-06-03 01:54:12.000000000 +0200
@@ -230,20 +230,22 @@
     return hr;
 }
 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
+    HRESULT hr;
     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
     if (Level < This->levels) {
-      TRACE("(%p) level(%d) stub\n", This, Level);
+      hr = IDirect3DVolume8Impl_UnlockBox((LPDIRECT3DVOLUME8) This->volumes[Level]);
+      TRACE("(%p) -> level(%d) success(%lu)\n", This, Level, hr);
     } else {
       FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
       return D3DERR_INVALIDCALL;
     }
-    return D3D_OK;
+    return hr;
 }
 HRESULT  WINAPI        IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX* pDirtyBox) {
     ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
     This->Dirty = TRUE;
-    FIXME("(%p) : stub\n", This);    
-    return D3D_OK;
+    TRACE("(%p) : dirtyfication of volume Level (0)\n", This);    
+    return IDirect3DVolume8Impl_AddDirtyBox((LPDIRECT3DVOLUME8) This->volumes[0], pDirtyBox);
 }
 
 


More information about the wine-patches mailing list