Henri Verbeet : wined3d: Compare resource sizes in blocks in wined3d_device_copy_resource().

Alexandre Julliard julliard at winehq.org
Wed Feb 10 15:34:01 CST 2021


Module: wine
Branch: master
Commit: 1039bf036f9b98e367abe3a473499ccbdf4371f0
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1039bf036f9b98e367abe3a473499ccbdf4371f0

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Feb 10 00:24:04 2021 +0100

wined3d: Compare resource sizes in blocks in wined3d_device_copy_resource().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3d11/tests/d3d11.c |  3 ++-
 dlls/wined3d/device.c    | 30 ++++++++++++++++++++----------
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 43bdec02c0d..21543cd224c 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -28205,7 +28205,8 @@ static void test_compressed_format_compatibility(const D3D_FEATURE_LEVEL feature
                     expected = texture_data[k];
                 else
                     expected = initial_data[k];
-                todo_wine_if(supported)
+                todo_wine_if(supported && (dst_format->block_edge != 1
+                        || k >= src_format->block_size / (sizeof(colour))))
                     ok(colour == expected, "%#x -> %#x: Got unexpected colour 0x%08x at %u, expected 0x%08x.\n",
                             src_format->id, dst_format->id, colour, k, expected);
                 if (colour != expected)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 25ef0d1c016..df0f9721e4a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4541,7 +4541,9 @@ static bool resources_format_compatible(const struct wined3d_resource *src_resou
 void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
         struct wined3d_resource *dst_resource, struct wined3d_resource *src_resource)
 {
+    unsigned int src_row_block_count, dst_row_block_count;
     struct wined3d_texture *dst_texture, *src_texture;
+    unsigned int src_row_count, dst_row_count;
     struct wined3d_box box;
     unsigned int i, j;
 
@@ -4561,16 +4563,6 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
         return;
     }
 
-    if (src_resource->width != dst_resource->width
-            || src_resource->height != dst_resource->height
-            || src_resource->depth != dst_resource->depth)
-    {
-        WARN("Resource dimensions (%ux%ux%u / %ux%ux%u) don't match.\n",
-                dst_resource->width, dst_resource->height, dst_resource->depth,
-                src_resource->width, src_resource->height, src_resource->depth);
-        return;
-    }
-
     if (!resources_format_compatible(src_resource, dst_resource))
     {
         WARN("Resource formats %s and %s are incompatible.\n",
@@ -4579,6 +4571,24 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
         return;
     }
 
+    src_row_block_count = (src_resource->width + (src_resource->format->block_width - 1))
+            / src_resource->format->block_width;
+    dst_row_block_count = (dst_resource->width + (dst_resource->format->block_width - 1))
+            / dst_resource->format->block_width;
+    src_row_count = (src_resource->height + (src_resource->format->block_height - 1))
+            / src_resource->format->block_height;
+    dst_row_count = (dst_resource->height + (dst_resource->format->block_height - 1))
+            / dst_resource->format->block_height;
+
+    if (src_row_block_count != dst_row_block_count || src_row_count != dst_row_count
+            || src_resource->depth != dst_resource->depth)
+    {
+        WARN("Resource block dimensions (%ux%ux%u / %ux%ux%u) don't match.\n",
+                dst_row_block_count, dst_row_count, dst_resource->depth,
+                src_row_block_count, src_row_count, src_resource->depth);
+        return;
+    }
+
     if (dst_resource->type == WINED3D_RTYPE_BUFFER)
     {
         wined3d_box_set(&box, 0, 0, src_resource->size, 1, 0, 1);




More information about the wine-cvs mailing list