Roderick Colenbrander : wined3d: Move depth/ stencil verification to CheckDepthStencilCapability.

Alexandre Julliard julliard at winehq.org
Mon Mar 17 10:46:28 CDT 2008


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

Author: Roderick Colenbrander <thunderbird2k at gmx.net>
Date:   Sun Mar 16 16:02:02 2008 +0000

wined3d: Move depth/stencil verification to CheckDepthStencilCapability.

---

 dlls/wined3d/directx.c |   99 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 75 insertions(+), 24 deletions(-)

diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index e852d6b..0dcc8f4 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1806,10 +1806,50 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter
     return hr;
 }
 
+
 #define GLINFO_LOCATION Adapters[Adapter].gl_info
+/* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
+static BOOL CheckDepthStencilCapability(UINT Adapter, WINED3DFORMAT DisplayFormat,
+WINED3DFORMAT DepthStencilFormat)
+{
+    int it=0;
+    WineD3D_PixelFormat *cfgs = Adapters[Adapter].cfgs;
+
+    /* Only allow depth/stencil formats */
+    switch (DepthStencilFormat) {
+        case WINED3DFMT_D16_LOCKABLE:
+        case WINED3DFMT_D16:
+        case WINED3DFMT_D15S1:
+        case WINED3DFMT_D24X8:
+        case WINED3DFMT_D24X4S4:
+        case WINED3DFMT_D24S8:
+        case WINED3DFMT_D24FS8:
+        case WINED3DFMT_D32:
+        case WINED3DFMT_D32F_LOCKABLE:
+            break;
+
+        default:
+            return FALSE;
+    }
+
+    /* Walk through all WGL pixel formats to find a match */
+    cfgs = Adapters[Adapter].cfgs;
+    for (it = 0; it < Adapters[Adapter].nCfgs; ++it) {
+        if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&cfgs[it], DisplayFormat)) {
+            if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&cfgs[it], DepthStencilFormat)) {
+                return TRUE;
+            }
+        }
+    }
+
+    return FALSE;
+}
+
 static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, 
                                               WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) {
     IWineD3DImpl *This = (IWineD3DImpl *)iface;
+    DWORD UsageCaps = 0;
+
     TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%u,%s,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s))\n",
           This,
           Adapter,
@@ -1842,7 +1882,38 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
         }
     }
 
-    if(RType == WINED3DRTYPE_VOLUMETEXTURE) {
+    if(RType == WINED3DRTYPE_SURFACE) {
+        /* Surface allows:
+         *                - D3DUSAGE_DEPTHSTENCIL
+         *                - D3DUSAGE_NONSECURE (d3d9ex)
+         *                - D3DUSAGE_RENDERTARGET
+         */
+
+        if(Usage & WINED3DUSAGE_DEPTHSTENCIL) {
+            if(CheckDepthStencilCapability(Adapter, AdapterFormat, CheckFormat)) {
+                UsageCaps |= WINED3DUSAGE_DEPTHSTENCIL;
+            } else {
+                TRACE_(d3d_caps)("[FAILED] - No depthstencil support\n");
+                return WINED3DERR_NOTAVAILABLE;
+            }
+         }
+    } else if(RType == WINED3DRTYPE_TEXTURE) {
+        /* Texture allows:
+         *                - D3DUSAGE_AUTOGENMIPMAP
+         *                - D3DUSAGE_DEPTHSTENCIL
+         *                - D3DUSAGE_DMAP
+         *                - D3DUSAGE_DYNAMIC
+         *                - D3DUSAGE_NONSECURE (d3d9ex)
+         *                - D3DUSAGE_RENDERTARGET
+         *                - D3DUSAGE_SOFTWAREPROCESSING
+         *                - D3DUSAGE_TEXTAPI (d3d9ex)
+         */
+
+        if(CheckDepthStencilCapability(Adapter, AdapterFormat, CheckFormat)) {
+            if(Usage & WINED3DUSAGE_DEPTHSTENCIL)
+                UsageCaps |= WINED3DUSAGE_DEPTHSTENCIL;
+        }
+    } else if(RType == WINED3DRTYPE_VOLUMETEXTURE) {
         if(!GL_SUPPORT(EXT_TEXTURE3D)) {
             TRACE_(d3d_caps)("[FAILED] - No volume texture support\n");
             return WINED3DERR_NOTAVAILABLE;
@@ -1919,29 +1990,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
         }
     }
 
-    if(Usage & WINED3DUSAGE_DEPTHSTENCIL) {
-        switch (CheckFormat) {
-            /* In theory we could do all formats, just fetch them accordingly should the buffer be locked.
-             * Windows supports only those 3, and enumerating the other formats confuses applications
-             */
-            case WINED3DFMT_D24S8:
-            case WINED3DFMT_D24X8:
-            case WINED3DFMT_D16:
-                TRACE_(d3d_caps)("[OK]\n");
-                return WINED3D_OK;
-            case WINED3DFMT_D16_LOCKABLE:
-            case WINED3DFMT_D24FS8:
-            case WINED3DFMT_D32F_LOCKABLE:
-            case WINED3DFMT_D24X4S4:
-            case WINED3DFMT_D15S1:
-            case WINED3DFMT_D32:
-                TRACE_(d3d_caps)("[FAILED]. Disabled because not enumerated on windows\n");
-                return WINED3DERR_NOTAVAILABLE;
-            default:
-                TRACE_(d3d_caps)("[FAILED]\n");
-                return WINED3DERR_NOTAVAILABLE;
-        }
-    } else if(Usage & WINED3DUSAGE_RENDERTARGET) {
+    if(Usage & WINED3DUSAGE_RENDERTARGET) {
         switch (CheckFormat) {
             case WINED3DFMT_R8G8B8:
             case WINED3DFMT_A8R8G8B8:
@@ -2190,6 +2239,8 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
             break;
     }
 
+
+
     TRACE_(d3d_caps)("[FAILED]\n");
     return WINED3DERR_NOTAVAILABLE;
 }




More information about the wine-cvs mailing list