wined3d: Ignore clears when the framebuffer setup is broken.
authorStefan Dösinger <stefan@codeweavers.com>
Fri, 11 Mar 2011 10:15:25 +0000 (11:15 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 16 Mar 2011 15:31:53 +0000 (16:31 +0100)
dlls/wined3d/device.c

index 735cbca66397738c45c5f16dda474c43dae4158b..be6f90067487b1a2532eb766c3c116cca1a45d9c 100644 (file)
@@ -4780,11 +4780,24 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD rect
     TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, depth %.8e, stencil %u.\n",
             iface, rect_count, rects, flags, color, depth, stencil);
 
-    if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL) && !device->depth_stencil)
+    if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL))
     {
-        WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n");
-        /* TODO: What about depth stencil buffers without stencil bits? */
-        return WINED3DERR_INVALIDCALL;
+        IWineD3DSurfaceImpl *ds = device->depth_stencil;
+        if (!ds)
+        {
+            WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n");
+            /* TODO: What about depth stencil buffers without stencil bits? */
+            return WINED3DERR_INVALIDCALL;
+        }
+        else if (flags & WINED3DCLEAR_TARGET)
+        {
+            if(ds->resource.width < device->render_targets[0]->resource.width ||
+               ds->resource.height < device->render_targets[0]->resource.height)
+            {
+                WARN("Silently ignoring depth and target clear with mismatching sizes\n");
+                return WINED3D_OK;
+            }
+        }
     }
 
     device_get_draw_rect(device, &draw_rect);