Roderick Colenbrander : wined3d: Allow stencil support when it wasn' t requested on broken drivers.

Alexandre Julliard julliard at winehq.org
Mon May 5 14:28:33 CDT 2008


Module: wine
Branch: master
Commit: 7b5561cbb8bd24d64aaa06f42876f4e4e1e3f3f5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7b5561cbb8bd24d64aaa06f42876f4e4e1e3f3f5

Author: Roderick Colenbrander <thunderbird2k at gmx.net>
Date:   Sat May  3 14:37:09 2008 +0000

wined3d: Allow stencil support when it wasn't requested on broken drivers.

---

 dlls/wined3d/context.c         |    6 ++++--
 dlls/wined3d/directx.c         |   23 ++++++++++++++++++++++-
 dlls/wined3d/wined3d_private.h |    1 +
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 3341555..14d8fce 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -169,8 +169,10 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc, WINED3DF
             exactDepthMatch = FALSE;
 
         /* In all cases make sure the number of stencil bits matches our requirements
-         * even when we don't need stencil because it could affect performance */
-        if(!(cfgs->stencilSize == stencilBits))
+         * even when we don't need stencil because it could affect performance EXCEPT
+         * on cards which don't offer depth formats without stencil like the i915 drivers
+         * on Linux. */
+        if(stencilBits != cfgs->stencilSize && !(This->adapter->brokenStencil && stencilBits <= cfgs->stencilSize))
             continue;
 
         /* Check multisampling support */
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 8ac6473..32f7323 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1706,7 +1706,9 @@ static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const WineD3D_Pixel
     if(!(cfg->depthSize == depthSize || (!lockable && cfg->depthSize > depthSize)))
         return FALSE;
 
-    if(cfg->stencilSize != stencilSize)
+    /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
+     * allow more stencil bits than requested. */
+    if(cfg->stencilSize < stencilSize)
         return FALSE;
 
     return TRUE;
@@ -3839,6 +3841,7 @@ BOOL InitAdapters(void) {
         int values[10];
         int nAttribs = 0;
         int res;
+        int i;
         WineD3D_PixelFormat *cfgs;
         int attribute;
         DISPLAY_DEVICEW DisplayDevice;
@@ -3953,6 +3956,24 @@ BOOL InitAdapters(void) {
             cfgs++;
         }
 
+        /* D16, D24X8 and D24S8 are common depth / depth+stencil formats. All drivers support them though this doesn't
+         * mean that the format is offered in hardware. For instance Geforce8 cards don't have offer D16 in hardware
+         * but just fake it using D24(X8?) which is fine. D3D also allows that.
+         * Some display drivers (i915 on Linux) only report mixed depth+stencil formats like D24S8. MSDN clearly mentions
+         * that only on lockable formats (e.g. D16_locked) the bit order is guaranteed and that on other formats the
+         * driver is allowed to consume more bits EXCEPT for stencil bits.
+         *
+         * Mark an adapter with this broken stencil behavior.
+         */
+        Adapters[0].brokenStencil = TRUE;
+        for(i=0, cfgs=Adapters[0].cfgs; i<Adapters[0].nCfgs; i++) {
+            /* Nearly all drivers offer depth formats without stencil, only on i915 this if-statement won't be entered. */
+            if(cfgs[i].depthSize && !cfgs[i].stencilSize) {
+                Adapters[0].brokenStencil = FALSE;
+                break;
+            }
+        }
+
         fixup_extensions(&Adapters[0].gl_info);
 
         WineD3D_ReleaseFakeGLContext();
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 17a8fb0..083b0d8 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -702,6 +702,7 @@ struct WineD3DAdapter
     WCHAR                   DeviceName[CCHDEVICENAME]; /* DeviceName for use with e.g. ChangeDisplaySettings */
     int                     nCfgs;
     WineD3D_PixelFormat     *cfgs;
+    BOOL                    brokenStencil; /* Set on cards which only offer mixed depth+stencil */
     unsigned int            TextureRam; /* Amount of texture memory both video ram + AGP/TurboCache/HyperMemory/.. */
     unsigned int            UsedTextureRam;
 };




More information about the wine-cvs mailing list