[dx43] many simple fixes and more debug code

Raphaël Junqueira fenix at club-internet.fr
Wed May 28 17:10:51 CDT 2003


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

Hi,

More work for your next come back Alexandre ;)

Changelog:
  - some cleanups
  -  more cubetextures fixes (now d3d8 sdk cubemap sample work almost 
perfectly)
  - add a new debug function "debug_d3dpool" and use it
  - and a new param (the device) for the conversions functions (because we 
need to check caps to see how to convert)
  - some crashes fixes in render to surface code with no stencil-depth surface
  - a very simple cliplane fix
  - a stupid palettes fix (stupid language)
  - begin of anisotropic filter support
  - begin of compressed textures support
  - a very usefull debug functions: IDirect3DSurface8Impl_SaveSnapshot to dump 
surfaces as png ;)
  - many usefulls surfaces debug code (using SaveSnapshot)

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

iD8DBQE+1TPrp7NA3AmQTU4RAkCVAJ96O5U8Rn3VosBJlxGQ4yJCm6p5RgCcCrD9
1GXmLME9SD51JRa5FxEy53Y=
=pCrc
-----END PGP SIGNATURE-----
-------------- next part --------------
Seulement dans dlls/d3d8: basetexture.o
diff -u ../winepatch/dlls/d3d8/cubetexture.c dlls/d3d8/cubetexture.c
--- ../winepatch/dlls/d3d8/cubetexture.c	2003-05-28 23:21:31.000000000 +0200
+++ dlls/d3d8/cubetexture.c	2003-05-24 20:34:15.000000000 +0200
@@ -135,34 +135,34 @@
     int i;
     int j;
     ICOM_THIS(IDirect3DCubeTexture8Impl,iface);
-    TRACE("(%p) : About to load texture\n", This);
+    TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->Dirty);
     for (i = 0; i < This->levels; i++) {
-      if (i == 0 && This->surfaces[0][i]->textureName != 0 && This->Dirty == FALSE) {
+      if (i == 0 && This->surfaces[0][0]->textureName != 0 && This->Dirty == FALSE) {
 	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
 #if defined(GL_VERSION_1_3)
-	glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][i]->textureName);
+	glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][0]->textureName);
 #else
-        glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][i]->textureName);
+        glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][0]->textureName);
 #endif
 	checkGLcall("glBindTexture");
-	TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][i], i, This->surfaces[0][i]->textureName);
+	TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][0], i, This->surfaces[0][0]->textureName);
 	/* No need to walk through all mip-map levels, since already all assigned */
 	i = This->levels;
       } else {
 	if (i == 0) {
-	  if (This->surfaces[0][i]->textureName == 0) {
-	    glGenTextures(1, &This->surfaces[0][i]->textureName);
+	  if (This->surfaces[0][0]->textureName == 0) {
+	    glGenTextures(1, &This->surfaces[0][0]->textureName);
 	    checkGLcall("glGenTextures");
-	    TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][i], i, This->surfaces[0][i]->textureName);
+	    TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][i], i, This->surfaces[0][0]->textureName);
 	  }
 
 #if defined(GL_VERSION_1_3)
-	  glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][i]->textureName);
+	  glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][0]->textureName);
 #else
-	  glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][i]->textureName);
+	  glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][0]->textureName);
 #endif
 	  checkGLcall("glBindTexture");
-	  
+
 	  TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1);
 #if defined(GL_VERSION_1_3)
 	  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, This->levels - 1); 
@@ -173,7 +173,7 @@
 	}
 	
 	for (j = 0; j < 6; j++) {
-	  IDirect3DSurface8Impl_CreateGLTexture((LPDIRECT3DSURFACE8) This->surfaces[j][i], cube_targets[j], i); 
+	  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], 
@@ -196,6 +196,12 @@
 		       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);
+	  IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8) This->surfaces[j][i], buffer);
+#endif
 	}
 	/* Removed glTexParameterf now TextureStageStates are initialized at startup */
 	This->Dirty = FALSE;
Seulement dans dlls/d3d8: cubetexture.o
Les sous-répertoires ../winepatch/dlls/d3d8/CVS et dlls/d3d8/CVS sont identiques.
Seulement dans dlls/d3d8: d3d8.dll.dbg.c
Seulement dans dlls/d3d8: d3d8.dll.dbg.o
Seulement dans dlls/d3d8: d3d8.dll.so
Seulement dans dlls/d3d8: d3d8.dll.tmp.o
Seulement dans dlls/d3d8: d3d8_main.o
diff -u ../winepatch/dlls/d3d8/d3d8_private.h dlls/d3d8/d3d8_private.h
--- ../winepatch/dlls/d3d8/d3d8_private.h	2003-05-28 23:22:24.000000000 +0200
+++ dlls/d3d8/d3d8_private.h	2003-05-26 19:59:56.000000000 +0200
@@ -168,6 +168,7 @@
   EXT_PALETTED_TEXTURE,
   EXT_SECONDARY_COLOR,
   EXT_TEXTURE_COMPRESSION_S3TC,
+  EXT_TEXTURE_FILTER_ANISOTROPIC,
   EXT_TEXTURE_LOD,
   EXT_TEXTURE_LOD_BIAS,
   EXT_VERTEX_WEIGHTING,
@@ -608,7 +609,8 @@
 extern HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface);
 
 /* internal Interfaces */
-extern HRESULT WINAPI IDirect3DSurface8Impl_CreateGLTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level);
+extern HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level);
+extern HRESULT WINAPI IDirect3DSurface8Impl_SaveSnapshot(LPDIRECT3DSURFACE8 iface, const char* filename);
 
 
 /* ------------------ */
@@ -1228,15 +1230,11 @@
  * to see how not defined it here
  */ 
 void   setupTextureStates(LPDIRECT3DDEVICE8 iface, DWORD Stage);
-SHORT  bytesPerPixel(D3DFORMAT fmt);
-GLint  fmt2glintFmt(D3DFORMAT fmt);
-GLenum fmt2glFmt(D3DFORMAT fmt);
-GLenum fmt2glType(D3DFORMAT fmt);
-
-SHORT  D3DFmtGetBpp(D3DFORMAT fmt);
-GLint  D3DFmt2GLIntFmt(D3DFORMAT fmt);
-GLenum D3DFmt2GLFmt(D3DFORMAT fmt);
-GLenum D3DFmt2GLType(D3DFORMAT fmt);
+
+SHORT  D3DFmtGetBpp(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
+GLint  D3DFmt2GLIntFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
+GLenum D3DFmt2GLFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
+GLenum D3DFmt2GLType(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
 
 GLenum D3DFmt2GLDepthFmt(D3DFORMAT fmt);
 GLenum D3DFmt2GLDepthType(D3DFORMAT fmt);
@@ -1259,5 +1257,6 @@
 const char* debug_d3dformat(D3DFORMAT fmt);
 const char* debug_d3dressourcetype(D3DRESOURCETYPE res);
 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
+const char* debug_d3dpool(D3DPOOL Pool);
 
 #endif /* __WINE_D3DX8_PRIVATE_H */
Seulement dans dlls/d3d8: d3d8.spec.c
Seulement dans dlls/d3d8: d3d8.spec.def
Seulement dans dlls/d3d8: d3d8.spec.o
diff -u ../winepatch/dlls/d3d8/device.c dlls/d3d8/device.c
--- ../winepatch/dlls/d3d8/device.c	2003-05-28 23:40:34.000000000 +0200
+++ dlls/d3d8/device.c	2003-05-28 23:55:07.000000000 +0200
@@ -46,11 +46,11 @@
      of each frame, a check is made for the existance of C:\D3DTRACE, and if if exists d3d trace
      is enabled, and if it doesnt exists it is disabled. Adding in the SINGLE_FRAME_DEBUGGING
      gives a trace of just what makes up a single frame                                           */
-  #define FRAME_DEBUGGING
-  #if 1
-    #define SINGLE_FRAME_DEBUGGING
-  #endif  
-  static BOOL isOn  = FALSE;
+# define FRAME_DEBUGGING
+# if 1
+#  define SINGLE_FRAME_DEBUGGING
+# endif  
+static BOOL isOn  = FALSE;
 #endif
 
 /* Per-vertex trace: */
@@ -1435,7 +1435,7 @@
         volume->myDesc.Type   = D3DRTYPE_VOLUME;
         volume->myDesc.Pool   = Pool;
         volume->myDesc.Usage  = Usage;
-        volume->bytesPerPixel   = D3DFmtGetBpp(Format);
+        volume->bytesPerPixel   = D3DFmtGetBpp(This, Format);
         volume->myDesc.Size     = (Width * volume->bytesPerPixel) * Height * Depth;
         volume->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->myDesc.Size);
 
@@ -1501,8 +1501,8 @@
 	   }
 
            TRACE("Created surface level %d @ %p, memory at %p\n", i, object->surfaces[j][i], object->surfaces[j][i]->allocatedMemory);
-           tmpW = max(1, tmpW / 2);
         }
+        tmpW = max(1, tmpW / 2);
     }
 
     TRACE("(%p) : Iface@%p\n", This, object);
@@ -1582,7 +1582,7 @@
     object->myDesc.Usage = D3DUSAGE_RENDERTARGET;
     object->myDesc.Pool = D3DPOOL_DEFAULT;
     object->myDesc.MultiSampleType = MultiSample;
-    object->bytesPerPixel = D3DFmtGetBpp(Format);
+    object->bytesPerPixel = D3DFmtGetBpp(This, Format);
     object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
     object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
     object->lockable = Lockable;
@@ -1615,7 +1615,7 @@
     object->myDesc.Usage = D3DUSAGE_DEPTHSTENCIL;
     object->myDesc.Pool = D3DPOOL_DEFAULT;
     object->myDesc.MultiSampleType = MultiSample;
-    object->bytesPerPixel = D3DFmtGetBpp(Format);
+    object->bytesPerPixel = D3DFmtGetBpp(This, Format);
     object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
     object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
     object->lockable = (D3DFMT_D16_LOCKABLE == Format) ? TRUE : FALSE;
@@ -1643,7 +1643,7 @@
     object->myDesc.Type = D3DRTYPE_SURFACE;
     object->myDesc.Usage = 0;
     object->myDesc.Pool = D3DPOOL_SYSTEMMEM;
-    object->bytesPerPixel = D3DFmtGetBpp(Format);
+    object->bytesPerPixel = D3DFmtGetBpp(This, Format);
     object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
     object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
     object->lockable = TRUE;
@@ -1924,7 +1924,20 @@
     IDirect3DDevice8Impl_CleanRender(iface);
 
     if ((IDirect3DSurface8Impl*) pRenderTarget == This->frontBuffer && (IDirect3DSurface8Impl*) pNewZStencil == This->depthStencilBuffer) {
+      IDirect3DSurface8Impl* tmp;
+
       TRACE("retoring SetRenderTarget defaults\n");
+
+      tmp = This->renderTarget;
+      This->renderTarget = (IDirect3DSurface8Impl*) This->frontBuffer;
+      IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->renderTarget);
+      IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
+      
+      tmp = This->stencilBufferTarget;
+      This->stencilBufferTarget = (IDirect3DSurface8Impl*) This->depthStencilBuffer;
+      if (NULL != This->stencilBufferTarget) IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->stencilBufferTarget);
+      if (NULL != tmp) IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
+
       return D3D_OK;
     }
 
@@ -1953,7 +1966,7 @@
     
     /* Note inc ref on returned surface */
     *ppZStencilSurface = (LPDIRECT3DSURFACE8) This->stencilBufferTarget;
-    IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) *ppZStencilSurface);
+    if (NULL != *ppZStencilSurface) IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) *ppZStencilSurface);
 
     return D3D_OK;
 }
@@ -1977,10 +1990,36 @@
     getchar(); */
 
     if (This->frontBuffer != This->renderTarget) {
+      {
+	GLenum prev_read;
+	glGetIntegerv(GL_READ_BUFFER, &prev_read);
+	vcheckGLcall("glIntegerv");
+	glReadBuffer(GL_BACK);
+	vcheckGLcall("glReadBuffer");
+	{
+	  long j;
+	  long pitch = This->renderTarget->myDesc.Width * This->renderTarget->bytesPerPixel;
+	  for (j = 0; j < This->renderTarget->myDesc.Height; ++j) {
+	    glReadPixels(0, 
+			 This->renderTarget->myDesc.Height - j - 1, 
+			 This->renderTarget->myDesc.Width, 
+			 1,
+			 D3DFmt2GLFmt(This, This->renderTarget->myDesc.Format), 
+			 D3DFmt2GLType(This, This->renderTarget->myDesc.Format), 
+			 This->renderTarget->allocatedMemory + j * pitch);
+	    vcheckGLcall("glReadPixels");
+	  }
+	}      
+	glReadBuffer(prev_read);
+	vcheckGLcall("glReadBuffer");
+      }
+
       IDirect3DBaseTexture8* cont = NULL;
       HRESULT hr;
       hr = IDirect3DSurface8_GetContainer((LPDIRECT3DSURFACE8) This->renderTarget, &IID_IDirect3DBaseTexture8, (void**) &cont);
       if (SUCCEEDED(hr) && NULL != cont) {
+	/** always dirtify for now. we must find a better way to see that surface have been modified */
+	IDirect3DBaseTexture8Impl_SetDirty(cont, TRUE);
 	IDirect3DBaseTexture8_PreLoad(cont);
 	IDirect3DBaseTexture8_Release(cont);
 	cont = NULL;
@@ -2716,8 +2755,11 @@
     glPushMatrix();
     glLoadMatrixf((float *) &This->StateBlock->transforms[D3DTS_VIEW].u.m[0][0]);
 
-    TRACE("Clipplane [%f,%f,%f,%f]\n", This->UpdateStateBlock->clipplane[Index][0], This->UpdateStateBlock->clipplane[Index][1],
-          This->UpdateStateBlock->clipplane[Index][2], This->UpdateStateBlock->clipplane[Index][3]);
+    TRACE("Clipplane [%f,%f,%f,%f]\n", 
+	  This->UpdateStateBlock->clipplane[Index][0], 
+	  This->UpdateStateBlock->clipplane[Index][1],
+          This->UpdateStateBlock->clipplane[Index][2], 
+	  This->UpdateStateBlock->clipplane[Index][3]);
     glClipPlane(GL_CLIP_PLANE0 + Index, This->UpdateStateBlock->clipplane[Index]);
 
     glPopMatrix();
@@ -2736,9 +2778,9 @@
     }
 
     pPlane[0] = This->StateBlock->clipplane[Index][0];
-    pPlane[1] = This->StateBlock->clipplane[Index][0];
-    pPlane[2] = This->StateBlock->clipplane[Index][0];
-    pPlane[3] = This->StateBlock->clipplane[Index][0];
+    pPlane[1] = This->StateBlock->clipplane[Index][1];
+    pPlane[2] = This->StateBlock->clipplane[Index][2];
+    pPlane[3] = This->StateBlock->clipplane[Index][3];
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD Value) {
@@ -2886,12 +2928,6 @@
     case D3DRS_AMBIENT                   :
         {
             float col[4];
-#if 0
-            col[0] = ((Value >> 16) & 0xFF) / 255.0;
-            col[1] = ((Value >>  8) & 0xFF) / 255.0;
-            col[2] = ((Value >>  0) & 0xFF) / 255.0;
-            col[3] = ((Value >> 24) & 0xFF) / 255.0;
-#endif
 	    D3DCOLORTOGLFLOAT4(Value, col);
             TRACE("Setting ambient to (%f,%f,%f,%f)\n", col[0], col[1], col[2], col[3]);
             glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
@@ -2965,14 +3001,14 @@
             float ref = ((float) This->StateBlock->renderstate[D3DRS_ALPHAREF]) / 255.0f;
 
             switch ((D3DCMPFUNC) Value) {
-            case D3DCMP_NEVER:         glParm=GL_NEVER; break;
-            case D3DCMP_LESS:          glParm=GL_LESS; break;
-            case D3DCMP_EQUAL:         glParm=GL_EQUAL; break;
-            case D3DCMP_LESSEQUAL:     glParm=GL_LEQUAL; break;
-            case D3DCMP_GREATER:       glParm=GL_GREATER; break;
-            case D3DCMP_NOTEQUAL:      glParm=GL_NOTEQUAL; break;
-            case D3DCMP_GREATEREQUAL:  glParm=GL_GEQUAL; break;
-            case D3DCMP_ALWAYS:        glParm=GL_ALWAYS; break;
+            case D3DCMP_NEVER:         glParm = GL_NEVER; break;
+            case D3DCMP_LESS:          glParm = GL_LESS; break;
+            case D3DCMP_EQUAL:         glParm = GL_EQUAL; break;
+            case D3DCMP_LESSEQUAL:     glParm = GL_LEQUAL; break;
+            case D3DCMP_GREATER:       glParm = GL_GREATER; break;
+            case D3DCMP_NOTEQUAL:      glParm = GL_NOTEQUAL; break;
+            case D3DCMP_GREATEREQUAL:  glParm = GL_GEQUAL; break;
+            case D3DCMP_ALWAYS:        glParm = GL_ALWAYS; break;
             default:
                 FIXME("Unrecognized/Unhandled D3DCMPFUNC value %ld\n", Value);
             }
@@ -3097,7 +3133,7 @@
                NOTE: If not supported dont give FIXME as very minimal impact and very few people are
                   yet running 1.4!
              */
-            if (Value) {
+              if (Value) {
                 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &This->UpdateStateBlock->material.Specular);
                 checkGLcall("glMaterialfv");
 #if defined(GL_VERSION_1_4)
@@ -3110,7 +3146,7 @@
                 TRACE("Specular colors cannot be enabled in this version of opengl\n");
 #endif
                 checkGLcall("glEnable(GL_COLOR_)\n");
-            } else {
+              } else {
                 float black[4] = {0.0, 0.0, 0.0, 0.0};
 
                 /* for the case of enabled lighting: */
@@ -3128,7 +3164,7 @@
                 TRACE("Specular colors cannot be disabled in this version of opengl\n");
 #endif
                 checkGLcall("glDisable(GL_COLOR_)\n");
-	    }
+	      }
         }
         break;
 
@@ -3161,8 +3197,8 @@
                FIXME("Unrecognized/Unhandled D3DCMPFUNC value %ld\n", Value);
            }
            TRACE("glStencilFunc with Parm=%x, ref=%d, mask=%x\n", glParm, ref, mask);
-           This->stencilfunc = glParm;
-           glStencilFunc(glParm, ref, mask);
+	   This->stencilfunc = glParm;
+	   glStencilFunc(glParm, ref, mask);
            checkGLcall("glStencilFunc");
         }
         break;
@@ -3513,13 +3549,13 @@
 
     case D3DRS_COLORWRITEENABLE          :
         TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n", 
-                    Value & D3DCOLORWRITEENABLE_RED?1:0,
-                    Value & D3DCOLORWRITEENABLE_GREEN?1:0,
-                    Value & D3DCOLORWRITEENABLE_BLUE?1:0,
-                    Value & D3DCOLORWRITEENABLE_ALPHA?1:0); 
-		glColorMask(Value & D3DCOLORWRITEENABLE_RED, 
+	      Value & D3DCOLORWRITEENABLE_RED   ? 1 : 0,
+	      Value & D3DCOLORWRITEENABLE_GREEN ? 1 : 0,
+	      Value & D3DCOLORWRITEENABLE_BLUE  ? 1 : 0,
+	      Value & D3DCOLORWRITEENABLE_ALPHA ? 1 : 0); 
+	glColorMask(Value & D3DCOLORWRITEENABLE_RED, 
                     Value & D3DCOLORWRITEENABLE_GREEN,
-		            Value & D3DCOLORWRITEENABLE_BLUE, 
+		    Value & D3DCOLORWRITEENABLE_BLUE, 
                     Value & D3DCOLORWRITEENABLE_ALPHA);
         checkGLcall("glColorMask(...)\n");
 		break;
@@ -3827,6 +3863,14 @@
         }
         break;
 
+    case D3DTSS_MAXANISOTROPY         :
+      {	
+	if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
+	  glTexParameteri(This->StateBlock->textureDimensions[Stage], GL_TEXTURE_MAX_ANISOTROPY_EXT, This->StateBlock->texture_state[Stage][D3DTSS_MAXANISOTROPY]);
+	  checkGLcall("glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT ...");
+	}
+      }
+      break;
 
     case D3DTSS_MAGFILTER             :
         if (Value == D3DTEXF_POINT) {
@@ -4043,6 +4087,7 @@
 		     *   we can use GL_SUBTRACT_ARB here
 		     */
 #endif
+
                 case D3DTOP_ADDSMOOTH                 :
                 case D3DTOP_BLENDDIFFUSEALPHA         :
                 case D3DTOP_BLENDTEXTUREALPHA         :
@@ -4300,7 +4345,6 @@
 
     case D3DTSS_MIPMAPLODBIAS         :
     case D3DTSS_MAXMIPLEVEL           :
-    case D3DTSS_MAXANISOTROPY         :
     case D3DTSS_BUMPENVLSCALE         :
     case D3DTSS_BUMPENVLOFFSET        :
     case D3DTSS_RESULTARG             :
@@ -4324,12 +4368,12 @@
     ICOM_THIS(IDirect3DDevice8Impl,iface);
     FIXME("(%p) : setting p[%u] <= RGBA(%02x,%02x,%02x,%02x)\n", This, PaletteNumber,
           pEntries->peRed, pEntries->peGreen, pEntries->peBlue, pEntries->peFlags);
-    memcpy(&This->palettes[PaletteNumber], pEntries, 256 * sizeof(PALETTEENTRY));
+    memcpy(This->palettes[PaletteNumber], pEntries, 256 * sizeof(PALETTEENTRY));
     return D3D_OK;
 }
 HRESULT  WINAPI  IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
     ICOM_THIS(IDirect3DDevice8Impl,iface);
-    memcpy(pEntries, &This->palettes[PaletteNumber], 256 * sizeof(PALETTEENTRY));
+    memcpy(pEntries, This->palettes[PaletteNumber], 256 * sizeof(PALETTEENTRY));
     FIXME("(%p) : returning p[%u] => RGBA(%02x,%02x,%02x,%02x)\n", This, PaletteNumber,
           pEntries->peRed, pEntries->peGreen, pEntries->peBlue, pEntries->peFlags);
     return D3D_OK;
@@ -4345,7 +4389,7 @@
 		      256,              /* table size */
 		      GL_RGBA,          /* table format */
 		      GL_UNSIGNED_BYTE, /* table type */
-		      &This->palettes[PaletteNumber]);
+		      This->palettes[PaletteNumber]);
       checkGLcall("glColorTableEXT");
     } else {
       /* Delayed palette handling ... waiting for software emulation into preload code */
@@ -4932,7 +4976,7 @@
   int attribs[256];
   int nAttribs = 0;
   D3DFORMAT BackBufferFormat = ((IDirect3DSurface8Impl*) RenderSurface)->myDesc.Format;
-  D3DFORMAT StencilBufferFormat = ((IDirect3DSurface8Impl*) StencilSurface)->myDesc.Format;
+  D3DFORMAT StencilBufferFormat = (NULL != StencilSurface) ? ((IDirect3DSurface8Impl*) StencilSurface)->myDesc.Format : 0;
   UINT Width = ((IDirect3DSurface8Impl*) RenderSurface)->myDesc.Width;
   UINT Height = ((IDirect3DSurface8Impl*) RenderSurface)->myDesc.Height;
   IDirect3DSurface8Impl* tmp;
@@ -5057,14 +5101,15 @@
       vcheckGLcall("glReadBuffer");
       {
 	long j;
+	long pitch = This->renderTarget->myDesc.Width * This->renderTarget->bytesPerPixel;
 	for (j = 0; j < This->renderTarget->myDesc.Height; ++j) {
 	  glReadPixels(0, 
 		       This->renderTarget->myDesc.Height - j - 1, 
 		       This->renderTarget->myDesc.Width, 
 		       1,
-		       D3DFmt2GLFmt(This->renderTarget->myDesc.Format), 
-		       D3DFmt2GLType(This->renderTarget->myDesc.Format), 
-		       This->renderTarget->allocatedMemory);
+		       D3DFmt2GLFmt(This, This->renderTarget->myDesc.Format), 
+		       D3DFmt2GLType(This, This->renderTarget->myDesc.Format), 
+		       This->renderTarget->allocatedMemory + j * pitch);
 	  vcheckGLcall("glReadPixels");
 	}
       }      
@@ -5100,8 +5145,8 @@
 
     tmp = This->stencilBufferTarget;
     This->stencilBufferTarget = (IDirect3DSurface8Impl*) StencilSurface;
-    IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->stencilBufferTarget);
-    IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
+    if (NULL != This->stencilBufferTarget) IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->stencilBufferTarget);
+    if (NULL != tmp) IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
 
     return D3D_OK;
 
Seulement dans dlls/d3d8: device.c.orig
Seulement dans dlls/d3d8: device.o
diff -u ../winepatch/dlls/d3d8/directx.c dlls/d3d8/directx.c
--- ../winepatch/dlls/d3d8/directx.c	2003-05-28 23:34:20.000000000 +0200
+++ dlls/d3d8/directx.c	2003-05-27 01:35:10.000000000 +0200
@@ -513,7 +513,7 @@
                           D3DSTENCILCAPS_REPLACE | 
                           D3DSTENCILCAPS_ZERO;
 #if defined(GL_VERSION_1_4) || defined(GL_EXT_stencil_wrap)
-    pCaps->StencilCaps |= D3DSTENCILCAPS_DECR    |
+    pCaps->StencilCaps |= D3DSTENCILCAPS_DECR    | 
                           D3DSTENCILCAPS_INCR;
 #endif
 
@@ -603,8 +603,13 @@
     pCaps->MaxStreams = 2; /* HACK: Some games want at least 2 */ 
     pCaps->MaxStreamStride = 1024;
 
+#if 1
     pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
     pCaps->MaxVertexShaderConst = D3D8_VSHADER_MAX_CONSTANTS;
+#else
+    pCaps->VertexShaderVersion = 0;
+    pCaps->MaxVertexShaderConst = D3D8_VSHADER_MAX_CONSTANTS;
+#endif
 
 #if 0
     pCaps->PixelShaderVersion = D3DPS_VERSION(1,1);
@@ -837,9 +842,9 @@
     object->renderTarget = object->frontBuffer;
     IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) object->renderTarget);
     object->stencilBufferTarget = object->depthStencilBuffer;
-    if (NULL != object->stencilBufferTarget)
+    if (NULL != object->stencilBufferTarget) {
       IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) object->stencilBufferTarget);
-
+    }
 
     /* Now override the surface's Flip method (if in double buffering) ?COPIED from DDRAW!?
     ((x11_ds_private *) surface->private)->opengl_flip = TRUE;
@@ -875,8 +880,8 @@
     glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
     checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
 
-    glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR);
-    checkGLcall("glLightModel (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR);");
+    glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+    checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
 
     /* 
      * Initialize openGL extension related variables
@@ -955,6 +960,9 @@
 	} else if (strcmp(ThisExtn, "GL_EXT_texture_compression_s3tc") == 0) {
 	  FIXME(" FOUND: EXT Texture S3TC compression support\n");
 	  This->gl_info.supported[EXT_TEXTURE_COMPRESSION_S3TC] = TRUE;
+	} else if (strcmp(ThisExtn, "GL_EXT_texture_filter_anisotropic") == 0) {
+	  FIXME(" FOUND: EXT Texture Anisotropic filter support\n");
+	  This->gl_info.supported[EXT_TEXTURE_FILTER_ANISOTROPIC] = TRUE;
 	} else if (strcmp(ThisExtn, "GL_EXT_texture_lod") == 0) {
 	  FIXME(" FOUND: EXT Texture LOD support\n");
 	  This->gl_info.supported[EXT_TEXTURE_LOD] = TRUE;
Seulement dans dlls/d3d8: directx.c.save
Seulement dans dlls/d3d8: directx.o
Seulement dans dlls/d3d8: indexbuffer.o
Seulement dans dlls/d3d8: Makefile
Seulement dans dlls/d3d8: resource.o
Seulement dans dlls/d3d8: shader.o
Seulement dans dlls/d3d8: stateblock.o
diff -u ../winepatch/dlls/d3d8/surface.c dlls/d3d8/surface.c
--- ../winepatch/dlls/d3d8/surface.c	2003-05-28 23:21:31.000000000 +0200
+++ dlls/d3d8/surface.c	2003-05-24 23:11:54.000000000 +0200
@@ -25,6 +25,7 @@
 #include "winuser.h"
 #include "wingdi.h"
 #include "wine/debug.h"
+#include <stdio.h>
 
 #include "d3d8_private.h"
 
@@ -204,8 +205,8 @@
 			 This->lockedRect.bottom - j - 1, 
 			 This->lockedRect.right - This->lockedRect.left, 
 			 1,
-			 D3DFmt2GLFmt(This->myDesc.Format), 
-                         D3DFmt2GLType(This->myDesc.Format), 
+			 D3DFmt2GLFmt(This->Device, This->myDesc.Format), 
+                         D3DFmt2GLType(This->Device, This->myDesc.Format), 
                          pLockedRect->pBits);
 	    vcheckGLcall("glReadPixels");
 	  }
@@ -398,12 +399,14 @@
     IDirect3DSurface8Impl_UnlockRect,
 };
 
-HRESULT WINAPI IDirect3DSurface8Impl_CreateGLTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level) {
+HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level) {
   ICOM_THIS(IDirect3DSurface8Impl,iface);
 
-
-  if ((This->myDesc.Format == D3DFMT_P8 || This->myDesc.Format == D3DFMT_A8P8) && 
-      !GL_SUPPORT_DEV(EXT_PALETTED_TEXTURE, This->Device)) {
+  if ((This->myDesc.Format == D3DFMT_P8 || This->myDesc.Format == D3DFMT_A8P8) 
+#if defined(GL_EXT_paletted_texture)
+      && !GL_SUPPORT_DEV(EXT_PALETTED_TEXTURE, This->Device)
+#endif
+      ) {
     /**
      * wanted a paletted texture and not really support it in HW 
      * so software emulation code begin
@@ -450,27 +453,133 @@
     return D3D_OK;    
   }
 
-  TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
-	gl_target, 
-	gl_level, 
-	D3DFmt2GLIntFmt(This->myDesc.Format), 
-	This->myDesc.Width, 
-	This->myDesc.Height, 
-	0, 
-	D3DFmt2GLFmt(This->myDesc.Format), 
-	D3DFmt2GLType(This->myDesc.Format),
-	This->allocatedMemory);
-  glTexImage2D(gl_target,
-	       gl_level,
-	       D3DFmt2GLIntFmt(This->myDesc.Format),
-	       This->myDesc.Width,
-	       This->myDesc.Height,
-	       0,
-	       D3DFmt2GLFmt(This->myDesc.Format),
-	       D3DFmt2GLType(This->myDesc.Format),
-	       This->allocatedMemory);
-  checkGLcall("glTexImage2D");
-  
+  if (This->myDesc.Format == D3DFMT_DXT1 || 
+      This->myDesc.Format == D3DFMT_DXT3 || 
+      This->myDesc.Format == D3DFMT_DXT5) {
+#if defined(GL_EXT_texture_compression_s3tc)
+    if (GL_SUPPORT_DEV(EXT_TEXTURE_COMPRESSION_S3TC, This->Device)) {
+      TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n",
+	    gl_target, 
+	    gl_level, 
+	    D3DFmt2GLIntFmt(This->Device, This->myDesc.Format), 
+	    This->myDesc.Width, 
+	    This->myDesc.Height, 
+	    0, 
+	    This->myDesc.Size,
+	    This->allocatedMemory);
+      glCompressedTexImage2DARB(gl_target, 
+				gl_level, 
+				D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
+				This->myDesc.Width,
+				This->myDesc.Height,
+				0,
+				This->myDesc.Size,
+				This->allocatedMemory);
+      checkGLcall("glCommpressedTexTexImage2D");
+    }
+#endif
+  } else {
+    TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
+	  gl_target, 
+	  gl_level, 
+	  D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
+	  This->myDesc.Width, 
+	  This->myDesc.Height, 
+	  0, 
+	  D3DFmt2GLFmt(This->Device, This->myDesc.Format), 
+	  D3DFmt2GLType(This->Device, This->myDesc.Format),
+	  This->allocatedMemory);
+    glTexImage2D(gl_target, 
+		 gl_level,
+		 D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
+		 This->myDesc.Width,
+		 This->myDesc.Height,
+		 0,
+		 D3DFmt2GLFmt(This->Device, This->myDesc.Format),
+		 D3DFmt2GLType(This->Device, This->myDesc.Format),
+		 This->allocatedMemory);
+    checkGLcall("glTexImage2D");
 
+#if 0
+    {
+      static int gen = 0;
+      char buffer[4096];
+      ++gen;
+      if ((gen % 10) == 0) {
+	snprintf(buffer, sizeof(buffer), "/tmp/surface%d_level%d_%d.png", gl_target, gl_level, gen);
+	IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8) This, buffer);
+      }
+    }
+#endif
+  }
+
+  return D3D_OK;
+}
+
+#include <errno.h>
+HRESULT WINAPI IDirect3DSurface8Impl_SaveSnapshot(LPDIRECT3DSURFACE8 iface, const char* filename) {
+  FILE* f = NULL;
+  int i;
+  ICOM_THIS(IDirect3DSurface8Impl,iface);
+
+  f = fopen(filename, "w+");
+  if (NULL == f) {
+    ERR("opening of %s failed with: %s\n", filename, strerror(errno));
+    return D3DERR_INVALIDCALL;
+  }
+
+  TRACE("opened %s\n", filename);
+
+  fprintf(f, "P6\n%u %u\n255\n", This->myDesc.Width, This->myDesc.Height);
+  switch (This->myDesc.Format) {
+  case D3DFMT_X8R8G8B8:
+  case D3DFMT_A8R8G8B8:
+    {
+      DWORD color;
+      for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
+	color = ((DWORD*) This->allocatedMemory)[i];
+	fputc((color >> 16) & 0xFF, f);
+	fputc((color >>  8) & 0xFF, f);
+	fputc((color >>  0) & 0xFF, f);
+      }
+    }
+    break;
+  case D3DFMT_R8G8B8:
+    {
+      BYTE* color;
+      for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
+	color = ((BYTE*) This->allocatedMemory) + (3 * i);
+	fputc((color[0]) & 0xFF, f);
+	fputc((color[1]) & 0xFF, f);
+	fputc((color[2]) & 0xFF, f);
+      }
+    }
+    break;
+  case D3DFMT_A1R5G5B5: 
+    {
+      WORD color;
+      for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
+	color = ((WORD*) This->allocatedMemory)[i];
+	fputc((color >> 10) & 0xFF, f);
+	fputc((color >>  5) & 0xFF, f);
+	fputc((color >>  0) & 0xFF, f);
+      }
+    }
+    break;
+  case D3DFMT_R5G6B5: 
+    {
+      WORD color;
+      for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
+	color = ((WORD*) This->allocatedMemory)[i];
+	fputc((color >> 11) & 0xFF, f);
+	fputc((color >>  5) & 0xFF, f);
+	fputc((color >>  0) & 0xFF, f);
+      }
+    }
+    break;
+  default: 
+    FIXME("Unimplemented dump mode format(%u,%s)\n", This->myDesc.Format, debug_d3dformat(This->myDesc.Format));
+  }
+  fclose(f);
   return D3D_OK;
 }
Seulement dans dlls/d3d8: surface.o
Seulement dans dlls/d3d8: swapchain.o
diff -u ../winepatch/dlls/d3d8/texture.c dlls/d3d8/texture.c
--- ../winepatch/dlls/d3d8/texture.c	2003-05-28 23:21:31.000000000 +0200
+++ dlls/d3d8/texture.c	2003-05-26 20:01:26.000000000 +0200
@@ -31,10 +31,10 @@
 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
 
 /* IDirect3DTexture8 IUnknown parts follow: */
-HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface,REFIID riid,LPVOID *ppobj)
+HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface, REFIID riid, LPVOID *ppobj)
 {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
-    TRACE("(%p) : QueryInterface\n", This);
+    TRACE("(%p) : QueryInterface for %s\n", This, debugstr_guid(riid));
     if (IsEqualGUID(riid, &IID_IUnknown)
         || IsEqualGUID(riid, &IID_IDirect3DResource8)
         || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
@@ -44,7 +44,7 @@
         return D3D_OK;
     }
 
-    WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+    WARN("(%p)->(%s,%p) not found\n", This, debugstr_guid(riid), ppobj);
     return E_NOINTERFACE;
 }
 
@@ -134,7 +134,7 @@
 	  
 	}
 
-	IDirect3DSurface8Impl_CreateGLTexture((LPDIRECT3DSURFACE8) This->surfaces[i], GL_TEXTURE_2D, i); 
+	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, 
@@ -194,7 +194,8 @@
         TRACE("(%p) Level (%d)\n", This, Level);
         return IDirect3DSurface8Impl_GetDesc((LPDIRECT3DSURFACE8) This->surfaces[Level], pDesc);
     } else {
-        FIXME("(%p) Level (%d)\n", This, Level);
+        FIXME("Levels seems too high?!!\n");
+	return D3DERR_INVALIDCALL;
     }
     return D3D_OK;
 }
@@ -218,6 +219,7 @@
         TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
     } else {
         FIXME("Levels seems too high?!!\n");
+	return D3DERR_INVALIDCALL;
     }
     return hr;
 }
@@ -230,8 +232,9 @@
         TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
     } else {
         FIXME("Levels seems too high?!!\n");
+	return D3DERR_INVALIDCALL;
     }
-    return D3D_OK;
+    return hr;
 }
 HRESULT  WINAPI        IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect) {
     ICOM_THIS(IDirect3DTexture8Impl,iface);
Seulement dans dlls/d3d8: texture.o
diff -u ../winepatch/dlls/d3d8/utils.c dlls/d3d8/utils.c
--- ../winepatch/dlls/d3d8/utils.c	2003-05-28 23:21:57.000000000 +0200
+++ dlls/d3d8/utils.c	2003-05-29 00:06:25.000000000 +0200
@@ -158,10 +158,99 @@
   }
 }
 
+const char* debug_d3dpool(D3DPOOL Pool) {
+  switch (Pool) {
+#define POOL_TO_STR(p) case p: return #p;
+    POOL_TO_STR(D3DPOOL_DEFAULT);
+    POOL_TO_STR(D3DPOOL_MANAGED);
+    POOL_TO_STR(D3DPOOL_SYSTEMMEM);
+    POOL_TO_STR(D3DPOOL_SCRATCH);
+#undef  POOL_TO_STR
+  default:
+    FIXME("Unrecognized %u D3DPOOL!\n", Pool);
+    return "unrecognized";
+  }
+}
+
 /*
  * Simple utility routines used for dx -> gl mapping of byte formats
  */
-SHORT bytesPerPixel(D3DFORMAT fmt) {
+int D3DPrimitiveListGetVertexSize(D3DPRIMITIVETYPE PrimitiveType, int iNumPrim) {
+  switch (PrimitiveType) {
+  case D3DPT_POINTLIST:     return iNumPrim;
+  case D3DPT_LINELIST:      return iNumPrim * 2;
+  case D3DPT_LINESTRIP:     return iNumPrim + 1;
+  case D3DPT_TRIANGLELIST:  return iNumPrim * 3;
+  case D3DPT_TRIANGLESTRIP: return iNumPrim + 2;
+  case D3DPT_TRIANGLEFAN:   return iNumPrim + 2;
+  default:
+    FIXME("Unrecognized %u D3DPRIMITIVETYPE!\n", PrimitiveType);
+    return 0;
+  }
+}
+
+int D3DPrimitive2GLenum(D3DPRIMITIVETYPE PrimitiveType) {
+  switch (PrimitiveType) {
+  case D3DPT_POINTLIST:     return GL_POINTS;
+  case D3DPT_LINELIST:      return GL_LINES;
+  case D3DPT_LINESTRIP:     return GL_LINE_STRIP;
+  case D3DPT_TRIANGLELIST:  return GL_TRIANGLES;
+  case D3DPT_TRIANGLESTRIP: return GL_TRIANGLE_STRIP;
+  case D3DPT_TRIANGLEFAN:   return GL_TRIANGLE_FAN;
+  default:
+    FIXME("Unrecognized %u D3DPRIMITIVETYPE!\n", PrimitiveType);
+    return GL_POLYGON;
+  }
+}
+
+int D3DFVFGetSize(D3DFORMAT fvf) {
+  int ret = 0;
+  if      (fvf & D3DFVF_XYZ)    ret += 3 * sizeof(float);
+  else if (fvf & D3DFVF_XYZRHW) ret += 4 * sizeof(float);
+  if (fvf & D3DFVF_NORMAL)      ret += 3 * sizeof(float);
+  if (fvf & D3DFVF_PSIZE)       ret += sizeof(float);
+  if (fvf & D3DFVF_DIFFUSE)     ret += sizeof(DWORD);
+  if (fvf & D3DFVF_SPECULAR)    ret += sizeof(DWORD);
+  /*if (fvf & D3DFVF_TEX1)        ret += 1;*/
+  return ret;
+}
+
+GLenum D3DFmt2GLDepthFmt(D3DFORMAT fmt) {
+  switch (fmt) {
+  /* depth/stencil buffer */
+  case D3DFMT_D16_LOCKABLE:
+  case D3DFMT_D16:
+  case D3DFMT_D15S1:
+  case D3DFMT_D24X4S4:
+  case D3DFMT_D24S8:
+  case D3DFMT_D24X8:
+  case D3DFMT_D32:
+    return GL_DEPTH_COMPONENT;
+  default:
+    FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
+  }
+  return 0;
+}
+
+GLenum D3DFmt2GLDepthType(D3DFORMAT fmt) {
+  switch (fmt) {
+  /* depth/stencil buffer */
+  case D3DFMT_D15S1:
+  case D3DFMT_D16_LOCKABLE:     
+  case D3DFMT_D16:              
+    return GL_UNSIGNED_SHORT;
+  case D3DFMT_D24X4S4:          
+  case D3DFMT_D24S8:            
+  case D3DFMT_D24X8:            
+  case D3DFMT_D32:              
+    return GL_UNSIGNED_INT;
+  default:
+    FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
+  }
+  return 0;
+}
+
+SHORT D3DFmtGetBpp(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
     SHORT retVal;
 
     switch (fmt) {
@@ -199,10 +288,13 @@
     return retVal;
 }
 
-GLint fmt2glintFmt(D3DFORMAT fmt) {
+GLint D3DFmt2GLIntFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
     GLint retVal;
 
     switch (fmt) {
+    case D3DFMT_P8:               retVal = GL_COLOR_INDEX8_EXT; break;
+    case D3DFMT_A8P8:             retVal = GL_COLOR_INDEX8_EXT; break;
+
     case D3DFMT_A4R4G4B4:         retVal = GL_RGBA4; break;
     case D3DFMT_A8R8G8B8:         retVal = GL_RGBA8; break;
     case D3DFMT_X8R8G8B8:         retVal = GL_RGB8; break;
@@ -213,14 +305,29 @@
         FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
         retVal = GL_RGB8;
     }
+#if defined(GL_EXT_texture_compression_s3tc)
+    if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
+      switch (fmt) {
+      case D3DFMT_DXT1:             retVal = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
+      case D3DFMT_DXT3:             retVal = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
+      case D3DFMT_DXT5:             retVal = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
+      default:
+	/* stupid compiler */
+	break;
+      }
+    }
+#endif
     TRACE("fmt2glintFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
     return retVal;
 }
 
-GLenum fmt2glFmt(D3DFORMAT fmt) {
+GLenum D3DFmt2GLFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
     GLenum retVal;
 
     switch (fmt) {
+    case D3DFMT_P8:               retVal = GL_COLOR_INDEX; break;
+    case D3DFMT_A8P8:             retVal = GL_COLOR_INDEX; break;
+
     case D3DFMT_A4R4G4B4:         retVal = GL_BGRA; break;
     case D3DFMT_A8R8G8B8:         retVal = GL_BGRA; break;
     case D3DFMT_X8R8G8B8:         retVal = GL_BGRA; break;
@@ -231,14 +338,29 @@
         FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
         retVal = GL_BGR;
     }
+#if defined(GL_EXT_texture_compression_s3tc)
+    if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
+      switch (fmt) {
+      case D3DFMT_DXT1:             retVal = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
+      case D3DFMT_DXT3:             retVal = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
+      case D3DFMT_DXT5:             retVal = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
+      default:
+	/* stupid compiler */
+	break;
+      }
+    }
+#endif
     TRACE("fmt2glFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
     return retVal;
 }
 
-GLenum fmt2glType(D3DFORMAT fmt) {
+GLenum D3DFmt2GLType(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
     GLenum retVal;
 
     switch (fmt) {
+    case D3DFMT_P8:               retVal = GL_UNSIGNED_BYTE; break;
+    case D3DFMT_A8P8:             retVal = GL_UNSIGNED_BYTE; break;
+
     case D3DFMT_A4R4G4B4:         retVal = GL_UNSIGNED_SHORT_4_4_4_4_REV; break;
     case D3DFMT_A8R8G8B8:         retVal = GL_UNSIGNED_BYTE; break;
     case D3DFMT_X8R8G8B8:         retVal = GL_UNSIGNED_BYTE; break;
@@ -249,101 +371,22 @@
         FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
         retVal = GL_UNSIGNED_BYTE;
     }
+#if defined(GL_EXT_texture_compression_s3tc)
+    if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
+      switch (fmt) {
+      case D3DFMT_DXT1:             retVal = 0; break;
+      case D3DFMT_DXT3:             retVal = 0; break;
+      case D3DFMT_DXT5:             retVal = 0; break;
+      default:
+	/* stupid compiler */
+	break;
+      }
+    }
+#endif
     TRACE("fmt2glType for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
     return retVal;
 }
 
-int D3DPrimitiveListGetVertexSize(D3DPRIMITIVETYPE PrimitiveType, int iNumPrim) {
-  switch (PrimitiveType) {
-  case D3DPT_POINTLIST:     return iNumPrim;
-  case D3DPT_LINELIST:      return iNumPrim * 2;
-  case D3DPT_LINESTRIP:     return iNumPrim + 1;
-  case D3DPT_TRIANGLELIST:  return iNumPrim * 3;
-  case D3DPT_TRIANGLESTRIP: return iNumPrim + 2;
-  case D3DPT_TRIANGLEFAN:   return iNumPrim + 2;
-  default:
-    FIXME("Unrecognized %u D3DPRIMITIVETYPE!\n", PrimitiveType);
-    return 0;
-  }
-}
-
-int D3DPrimitive2GLenum(D3DPRIMITIVETYPE PrimitiveType) {
-  switch (PrimitiveType) {
-  case D3DPT_POINTLIST:     return GL_POINTS;
-  case D3DPT_LINELIST:      return GL_LINES;
-  case D3DPT_LINESTRIP:     return GL_LINE_STRIP;
-  case D3DPT_TRIANGLELIST:  return GL_TRIANGLES;
-  case D3DPT_TRIANGLESTRIP: return GL_TRIANGLE_STRIP;
-  case D3DPT_TRIANGLEFAN:   return GL_TRIANGLE_FAN;
-  default:
-    FIXME("Unrecognized %u D3DPRIMITIVETYPE!\n", PrimitiveType);
-    return GL_POLYGON;
-  }
-}
-
-int D3DFVFGetSize(D3DFORMAT fvf) {
-  int ret = 0;
-  if      (fvf & D3DFVF_XYZ)    ret += 3 * sizeof(float);
-  else if (fvf & D3DFVF_XYZRHW) ret += 4 * sizeof(float);
-  if (fvf & D3DFVF_NORMAL)      ret += 3 * sizeof(float);
-  if (fvf & D3DFVF_PSIZE)       ret += sizeof(float);
-  if (fvf & D3DFVF_DIFFUSE)     ret += sizeof(DWORD);
-  if (fvf & D3DFVF_SPECULAR)    ret += sizeof(DWORD);
-  /*if (fvf & D3DFVF_TEX1)        ret += 1;*/
-  return ret;
-}
-
-GLenum D3DFmt2GLDepthFmt(D3DFORMAT fmt) {
-  switch (fmt) {
-  /* depth/stencil buffer */
-  case D3DFMT_D16_LOCKABLE:
-  case D3DFMT_D16:
-  case D3DFMT_D15S1:
-  case D3DFMT_D24X4S4:
-  case D3DFMT_D24S8:
-  case D3DFMT_D24X8:
-  case D3DFMT_D32:
-    return GL_DEPTH_COMPONENT;
-  default:
-    FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
-  }
-  return 0;
-}
-
-GLenum D3DFmt2GLDepthType(D3DFORMAT fmt) {
-  switch (fmt) {
-  /* depth/stencil buffer */
-  case D3DFMT_D15S1:
-  case D3DFMT_D16_LOCKABLE:     
-  case D3DFMT_D16:              
-    return GL_UNSIGNED_SHORT;
-  case D3DFMT_D24X4S4:          
-  case D3DFMT_D24S8:            
-  case D3DFMT_D24X8:            
-  case D3DFMT_D32:              
-    return GL_UNSIGNED_INT;
-  default:
-    FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
-  }
-  return 0;
-}
-
-SHORT D3DFmtGetBpp(D3DFORMAT fmt) {
-  return bytesPerPixel(fmt);
-}
-
-GLint D3DFmt2GLIntFmt(D3DFORMAT fmt) {
-  return fmt2glintFmt(fmt);
-}
-
-GLenum D3DFmt2GLFmt(D3DFORMAT fmt) {
-  return fmt2glFmt(fmt);
-}
-
-GLenum D3DFmt2GLType(D3DFORMAT fmt) {
-  return fmt2glType(fmt);
-}
-
 int SOURCEx_RGB_EXT(DWORD arg) {
     switch(arg) {
     case D3DTSS_COLORARG0: return GL_SOURCE2_RGB_EXT;
Seulement dans dlls/d3d8: utils.c~
Seulement dans dlls/d3d8: utils.o
Seulement dans dlls/d3d8: version.res
Seulement dans dlls/d3d8: vertexbuffer.o
Seulement dans dlls/d3d8: volume.o
diff -u ../winepatch/dlls/d3d8/volumetexture.c dlls/d3d8/volumetexture.c
--- ../winepatch/dlls/d3d8/volumetexture.c	2003-05-28 23:21:31.000000000 +0200
+++ dlls/d3d8/volumetexture.c	2003-05-24 18:07:03.000000000 +0200
@@ -140,23 +140,23 @@
 	TRACE("Calling glTexImage3D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
 	      GL_TEXTURE_3D, 
 	      i, 
-	      fmt2glintFmt(This->format), 
+	      D3DFmt2GLIntFmt(This->Device, This->format), 
 	      This->volumes[i]->myDesc.Width, 
 	      This->volumes[i]->myDesc.Height, 
 	      This->volumes[i]->myDesc.Depth,
 	      0, 
-	      fmt2glFmt(This->format), 
-	      fmt2glType(This->format),
+	      D3DFmt2GLFmt(This->Device, This->format), 
+	      D3DFmt2GLType(This->Device, This->format),
 	      This->volumes[i]->allocatedMemory);
 	glTexImage3D(GL_TEXTURE_3D, 
 		     i,
-		     fmt2glintFmt(This->format),
+		     D3DFmt2GLIntFmt(This->Device, This->format),
 		     This->volumes[i]->myDesc.Width,
 		     This->volumes[i]->myDesc.Height,
 		     This->volumes[i]->myDesc.Depth,
 		     0,
-		     fmt2glFmt(This->format),
-		     fmt2glType(This->format),
+		     D3DFmt2GLFmt(This->Device, This->format),
+		     D3DFmt2GLType(This->Device, This->format),
 		     This->volumes[i]->allocatedMemory);
 	checkGLcall("glTexImage3D");
 
Seulement dans dlls/d3d8: volumetexture.o
Seulement dans dlls/d3d8: vshaderdeclaration.o


More information about the wine-patches mailing list