Hi,
The attached patch modifies IWineD3D::CheckDeviceFormat to whitelist supported 
formats and return unsupported on unknown formats. Games which use funky 
float formats or simmilar things should then see that the formats aren't 
supported and (hopefully) fall back to less fancy formats. Before I send it 
to wine-patches I'd like to know however how those games react to the change. 
(Do they just fail with an error message or fall back to other formats).

Stefan
From nobody Mon Sep 17 00:00:00 2001
From: Stefan Dösinger <[EMAIL PROTECTED]>
Date: Sat Jul 1 13:37:46 2006 +0200
Subject: [PATCH] WineD3D: Whitelist formats instead of blacklisting

---

 dlls/wined3d/directx.c |  168 ++++++++++++++++++++++++++++++++----------------
 dlls/wined3d/utils.c   |    4 +
 2 files changed, 114 insertions(+), 58 deletions(-)

963751697f49d0d1eacbd454942f89ccb8c73287
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index e7d225b..c4b09c2 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1365,6 +1365,26 @@ static HRESULT WINAPI IWineD3DImpl_Check
         return WINED3DERR_INVALIDCALL;
     }
 
+    if(Usage & WINED3DUSAGE_DEPTHSTENCIL) {
+        switch (CheckFormat) {
+            case WINED3DFMT_D16_LOCKABLE:
+            case WINED3DFMT_D32:
+            case WINED3DFMT_D15S1:
+            case WINED3DFMT_D24S8:
+            case WINED3DFMT_D24X8:
+            case WINED3DFMT_D24X4S4:
+            case WINED3DFMT_D16:
+            case WINED3DFMT_L16:
+            case WINED3DFMT_D32F_LOCKABLE:
+            case WINED3DFMT_D24FS8:
+                TRACE_(d3d_caps)("[OK]\n");
+                return D3D_OK;
+            default:
+                TRACE_(d3d_caps)("[FAILED]\n");
+                return WINED3DERR_NOTAVAILABLE;
+        }
+    }
+
     if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
         switch (CheckFormat) {
         case D3DFMT_DXT1:
@@ -1380,65 +1400,101 @@ static HRESULT WINAPI IWineD3DImpl_Check
     }
 
     switch (CheckFormat) {
-    /*****
-     * check supported using GL_SUPPORT
-     */
-    case D3DFMT_DXT1:
-    case D3DFMT_DXT2:
-    case D3DFMT_DXT3:
-    case D3DFMT_DXT4:
-    case D3DFMT_DXT5:
-
-    /*****
-     *  supported
-     */
-      /*case D3DFMT_R5G6B5: */
-      /*case D3DFMT_X1R5G5B5:*/
-      /*case D3DFMT_A1R5G5B5: */
-      /*case D3DFMT_A4R4G4B4:*/
-
-    /*****
-     * unsupported
-     */
-
-      /* color buffer */
-      /*case D3DFMT_X8R8G8B8:*/
-    case D3DFMT_A8R3G3B2:
-
-      /* Paletted */
-    case D3DFMT_P8:
-    case D3DFMT_A8P8:
-
-      /* Luminance */
-    case D3DFMT_L8:
-    case D3DFMT_A8L8:
-    case D3DFMT_A4L4:
 
-      /* Bump */
-#if 0
-    case D3DFMT_V8U8:
-    case D3DFMT_V16U16:
-#endif
-    case D3DFMT_L6V5U5:
-    case D3DFMT_X8L8V8U8:
-    case D3DFMT_Q8W8V8U8:
-    case D3DFMT_W11V11U10:
-
-    /****
-     * currently hard to support
-     */
-    case D3DFMT_UYVY:
-    case D3DFMT_YUY2:
-
-      /* Since we do not support these formats right now, don't pretend to. */
-      TRACE_(d3d_caps)("[FAILED]\n");
-      return WINED3DERR_NOTAVAILABLE;
-    default:
-      break;
+        /*****
+         *  supported: RGB(A) formats
+         */
+        case WINED3DFMT_R8G8B8:
+        case WINED3DFMT_A8R8G8B8:
+        case WINED3DFMT_X8R8G8B8:
+        case WINED3DFMT_R5G6B5:
+        case WINED3DFMT_X1R5G5B5:
+        case WINED3DFMT_A1R5G5B5:
+        case WINED3DFMT_A4R4G4B4:
+        case WINED3DFMT_R3G3B2:
+        case WINED3DFMT_A8:
+        case WINED3DFMT_A8R3G3B2:
+        case WINED3DFMT_X4R4G4B4:
+        case WINED3DFMT_A8B8G8R8:
+        case WINED3DFMT_X8B8G8R8:
+        case WINED3DFMT_A2R10G10B10:
+        case WINED3DFMT_A2B10G10R10:
+            TRACE_(d3d_caps)("[OK]\n");
+            return WINED3D_OK;
+
+        /*****
+         *  supported: Palettized
+         */
+        case WINED3DFMT_P8:
+            TRACE_(d3d_caps)("[OK]\n");
+            return WINED3D_OK;
+
+        /*****
+         *  Supported: (Alpha)-Luminance
+         */
+        case WINED3DFMT_L8:
+        case WINED3DFMT_A8L8:
+        case WINED3DFMT_A4L4:
+            TRACE_(d3d_caps)("[OK]\n");
+            return WINED3D_OK;
+
+        /*****
+         *  Not supported for now: Bump mapping formats
+         */
+        case WINED3DFMT_V8U8:
+        case WINED3DFMT_L6V5U5:
+        case WINED3DFMT_X8L8V8U8:
+        case WINED3DFMT_Q8W8V8U8:
+        case WINED3DFMT_V16U16:
+        case WINED3DFMT_W11V11U10:
+        case WINED3DFMT_A2W10V10U10:
+            TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
+            return D3DERR_NOTAVAILABLE;
+
+        /*****
+         *  DXTN Formats: Handled above
+         * WINED3DFMT_DXT1
+         * WINED3DFMT_DXT2
+         * WINED3DFMT_DXT3
+         * WINED3DFMT_DXT4
+         * WINED3DFMT_DXT5
+         */
+
+        /*****
+         *  Odd formats - not supported
+         */
+        case WINED3DFMT_VERTEXDATA:
+        case WINED3DFMT_INDEX16:
+        case WINED3DFMT_INDEX32:
+        case WINED3DFMT_Q16W16V16U16:
+            TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
+            return D3DERR_NOTAVAILABLE;
+
+        /*****
+         *  Float formats: Not supported right now
+         */
+        case WINED3DFMT_R16F:
+        case WINED3DFMT_G16R16F:
+        case WINED3DFMT_A16B16G16R16F:
+        case WINED3DFMT_R32F:
+        case WINED3DFMT_G32R32F:
+        case WINED3DFMT_A32B32G32R32F:
+        case WINED3DFMT_CxV8U8:
+            TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
+            return D3DERR_NOTAVAILABLE;
+
+            /* Not supported */
+        case WINED3DFMT_G16R16:
+        case WINED3DFMT_A16B16G16R16:
+            TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
+            return D3DERR_NOTAVAILABLE;
+
+        default:
+            break;
     }
 
-    TRACE_(d3d_caps)("[OK]\n");
-    return WINED3D_OK;
+    TRACE_(d3d_caps)("[FAILED]\n");
+    return D3DERR_NOTAVAILABLE;
 }
 
 static HRESULT  WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D 
*iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index a89a4c2..a511bf0 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -71,11 +71,11 @@ static const PixelFormatDesc formats[] =
     {WINED3DFMT_A8          ,0x000000ff ,0x0        ,0x0        ,0x0        ,1 
     ,FALSE      ,GL_ALPHA8              ,GL_ALPHA           ,GL_ALPHA          
             },
     {WINED3DFMT_A8R3G3B2    ,0x0000ff00 ,0x000000e0 ,0x0000001c ,0x00000003 ,2 
     ,FALSE      ,0                      ,0                  ,0                 
             },
     {WINED3DFMT_X4R4G4B4    ,0x0        ,0x00000f00 ,0x000000f0 ,0x0000000f ,2 
     ,FALSE      ,GL_RGB4                ,GL_BGRA            
,GL_UNSIGNED_SHORT_4_4_4_4_REV  },
-    {WINED3DFMT_A2B10G10R10 ,0xb0000000 ,0x000003ff ,0x000ffc00 ,0x3ff00000 ,4 
     ,FALSE      ,0                      ,0                  ,0                 
             },
+    {WINED3DFMT_A2B10G10R10 ,0xb0000000 ,0x000003ff ,0x000ffc00 ,0x3ff00000 ,4 
     ,FALSE      ,GL_RGB                 ,GL_RGBA            
,GL_UNSIGNED_INT_2_10_10_10_REV },
     {WINED3DFMT_A8B8G8R8    ,0xff000000 ,0x000000ff ,0x0000ff00 ,0x00ff0000 ,4 
     ,FALSE      ,GL_RGBA8               ,GL_RGBA            
,GL_UNSIGNED_INT_8_8_8_8_REV    },
     {WINED3DFMT_X8B8G8R8    ,0x0        ,0x000000ff ,0x0000ff00 ,0x00ff0000 ,4 
     ,FALSE      ,GL_RGB8                ,GL_RGBA            
,GL_UNSIGNED_INT_8_8_8_8_REV    },
     {WINED3DFMT_G16R16      ,0x0        ,0x0000ffff ,0xffff0000 ,0x0        ,4 
     ,FALSE      ,0                      ,0                  ,0                 
             },
-    {WINED3DFMT_A2R10G10B10 ,0xb0000000 ,0x3ff00000 ,0x000ffc00 ,0x000003ff ,4 
     ,FALSE      ,0                      ,0                  ,0                 
             },
+    {WINED3DFMT_A2R10G10B10 ,0xb0000000 ,0x3ff00000 ,0x000ffc00 ,0x000003ff ,4 
     ,FALSE      ,GL_RGBA                ,GL_BGRA            
,GL_UNSIGNED_INT_2_10_10_10_REV },
     {WINED3DFMT_A16B16G16R16,0x0        ,0x0000ffff ,0xffff0000 ,0x0        ,8 
     ,FALSE      ,GL_RGBA16_EXT          ,GL_RGBA            ,GL_UNSIGNED_SHORT 
             },
     /* Luminance */
     {WINED3DFMT_L8          ,0x0        ,0x0        ,0x0        ,0x0        ,1 
     ,FALSE      ,GL_LUMINANCE8          ,GL_LUMINANCE       ,GL_UNSIGNED_BYTE  
             },
-- 
1.2.4

Attachment: pgpbmqkTfnGzN.pgp
Description: PGP signature



Reply via email to