[PATCH] WineD3D: Test formats for surface support=0A=

Stefan Doesinger stefan at codeweavers.com
Fri Jul 25 16:10:53 CDT 2008

Currently, if the application asks for plain surface support=0A=
without any flags, we return OK on all formats. This patch adds=0A=
some filters for sanity.=0A=
This patch is needed by the next patch, which adds a YUV format=0A=
test and YUV support based on an opengl extension. The YUV test=0A=
operates on surface because Windows doesn't do YUV textures, so=0A=
it has to check for surface capability=0A=
 dlls/wined3d/directx.c |   16 ++++++++++++++++=0A=
 1 files changed, 16 insertions(+), 0 deletions(-)=0A=
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c=0A=
index ebf7b40..6dbd14f 100644=0A=
--- a/dlls/wined3d/directx.c=0A=
+++ b/dlls/wined3d/directx.c=0A=
@@ -2406,6 +2406,17 @@ static BOOL CheckTextureCapability(UINT Adapter, =
WINED3DFORMAT CheckFormat)=0A=
     return FALSE;=0A=
+static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT =
AdapterFormat, WINED3DFORMAT CheckFormat) {=0A=
+    /* All format that are supported for textures are supported for =
surfaces as well */=0A=
+    if(CheckTextureCapability(Adapter, CheckFormat)) return TRUE;=0A=
+    /* All depth stencil formats are supported on surfaces */=0A=
+    if(CheckDepthStencilCapability(Adapter, AdapterFormat, =
CheckFormat)) return TRUE;=0A=
+    /* Reject other formats */=0A=
+    TRACE_(d3d_caps)("[FAILED]\n");=0A=
+    return FALSE;=0A=
 static BOOL CheckVertexTextureCapability(UINT Adapter, WINED3DFORMAT =
     if (!GL_LIMITS(vertex_samplers)) {=0A=
@@ -2561,6 +2572,11 @@ static HRESULT WINAPI =
IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt=0A=
          *                - D3DUSAGE_RENDERTARGET=0A=
+        if(!CheckSurfaceCapability(Adapter, AdapterFormat, =
CheckFormat)) {=0A=
+            TRACE_(d3d_caps)("[FAILED] - Not supported for plain =
+            return WINED3DERR_NOTAVAILABLE;=0A=
+        }=0A=
         if(Usage & WINED3DUSAGE_DEPTHSTENCIL) {=0A=
             if(CheckDepthStencilCapability(Adapter, AdapterFormat, =
CheckFormat)) {=0A=
                 UsageCaps |=3D WINED3DUSAGE_DEPTHSTENCIL;=0A=
-- =0A=


More information about the wine-patches mailing list