[PATCH] Add a function which checks if the given DepthStencilFormat is valid for the DisplayFormat. This function is for use with a rewrite of CheckDeviceFormat which is also part of this series.

Roderick Colenbrander thunderbird2k at gmx.net
Mon Mar 3 15:06:16 CST 2008


---
 dlls/wined3d/directx.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 991baaa..bd83ed3 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1823,6 +1823,43 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter
 }
 
 #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;
-- 
1.5.3.4


--========GMX11801204622522680220--



More information about the wine-patches mailing list