[PATCH] Make sure we are comparing formats of the same pixel type (float/int)

Roderick Colenbrander thunderbird2k at gmx.net
Fri Mar 21 08:52:15 CDT 2008


---
 dlls/wined3d/directx.c         |   44 +++++++++++++++++++++++++++++----------
 dlls/wined3d/wined3d_private.h |    1 +
 2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index bd861a6..69134ae 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1614,24 +1614,44 @@ static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const WineD3D_Pixe
     if(!cfg)
         return FALSE;
 
-    if(!getColorBits(Format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits)) {
-        ERR("Unable to check compatibility for Format=%s\n", debug_d3dformat(Format));
-        return FALSE;
-    }
+    if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
+        if(!getColorBits(Format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits)) {
+            ERR("Unable to check compatibility for Format=%s\n", debug_d3dformat(Format));
+            return FALSE;
+        }
 
-    if(cfg->redSize < redSize)
-        return FALSE;
+        if(cfg->redSize <= redSize)
+            return FALSE;
 
-    if(cfg->greenSize < greenSize)
-        return FALSE;
+        if(cfg->greenSize <= greenSize)
+            return FALSE;
 
-    if(cfg->blueSize < blueSize)
-        return FALSE;
+        if(cfg->blueSize <= blueSize)
+            return FALSE;
 
-    if(cfg->alphaSize < alphaSize)
+        if(cfg->alphaSize <= alphaSize)
+            return FALSE;
+
+        return TRUE;
+    } else if(cfg->iPixelType == WGL_TYPE_RGBA_FLOAT_ARB) { /* Float RGBA formats; TODO: WGL_NV_float_buffer */
+        if(Format == WINED3DFMT_R16F)
+            return (cfg->redSize == 16 && cfg->greenSize == 0 && cfg->blueSize == 0 && cfg->alphaSize == 0);
+        if(Format == WINED3DFMT_G16R16F)
+            return (cfg->redSize == 16 && cfg->greenSize == 16 && cfg->blueSize == 0 && cfg->alphaSize == 0);
+        if(Format == WINED3DFMT_A16B16G16R16F)
+            return (cfg->redSize == 16 && cfg->greenSize == 16 && cfg->blueSize == 16 && cfg->alphaSize == 16);
+        if(Format == WINED3DFMT_R32F)
+            return (cfg->redSize == 32 && cfg->greenSize == 0 && cfg->blueSize == 0 && cfg->alphaSize == 0);
+        if(Format == WINED3DFMT_G32R32F)
+            return (cfg->redSize == 32 && cfg->greenSize == 32 && cfg->blueSize == 0 && cfg->alphaSize == 0);
+        if(Format == WINED3DFMT_A32B32G32R32F)
+            return (cfg->redSize == 32 && cfg->greenSize == 32 && cfg->blueSize == 32 && cfg->alphaSize == 32);
+    } else {
+        /* Probably a color index mode */
         return FALSE;
+    }
 
-    return TRUE;
+    return FALSE;
 }
 
 static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const WineD3D_PixelFormat *cfg, WINED3DFORMAT Format) {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 6b0cfb8..8da308e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -636,6 +636,7 @@ extern const WINED3DLIGHT WINED3D_default_light;
 typedef struct WineD3D_PixelFormat
 {
     int iPixelFormat; /* WGL pixel format */
+    int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
     int redSize, greenSize, blueSize, alphaSize;
     int depthSize, stencilSize;
     BOOL windowDrawable;
-- 
1.5.3.4


--========GMX13091206107335274748--



More information about the wine-patches mailing list