Henri Verbeet : wined3d: Use the format block dimensions to construct the destination box for sub-resource region copies.

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


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

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

wined3d: Use the format block dimensions to construct the destination box for sub-resource region copies.

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

---

 dlls/d3d11/tests/d3d11.c |  5 ++---
 dlls/wined3d/device.c    | 20 ++++++++++++++++++--
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index b690f94af92..43bdec02c0d 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -28182,9 +28182,8 @@ static void test_compressed_format_compatibility(const D3D_FEATURE_LEVEL feature
                         expected = texture_data[k - ((row_block_count + 1) * dst_format->block_size) / sizeof(colour)];
                     else
                         expected = initial_data[k];
-                    todo_wine_if(supported && x == 1 && y == 1)
-                        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);
+                    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)
                         break;
                 }
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index ac8d5d78b61..25ef0d1c016 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4694,6 +4694,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
         struct wined3d_texture *dst_texture = texture_from_resource(dst_resource);
         struct wined3d_texture *src_texture = texture_from_resource(src_resource);
         unsigned int src_level = src_sub_resource_idx % src_texture->level_count;
+        unsigned int src_row_block_count, src_row_count;
 
         if (dst_sub_resource_idx >= dst_texture->level_count * dst_texture->layer_count)
         {
@@ -4741,8 +4742,23 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
             return WINED3DERR_INVALIDCALL;
         }
 
-        wined3d_box_set(&dst_box, dst_x, dst_y, dst_x + (src_box->right - src_box->left),
-                dst_y + (src_box->bottom - src_box->top), dst_z, dst_z + (src_box->back - src_box->front));
+        if (src_resource->format->block_width == dst_resource->format->block_width
+                && src_resource->format->block_height == dst_resource->format->block_height)
+        {
+            wined3d_box_set(&dst_box, dst_x, dst_y, dst_x + (src_box->right - src_box->left),
+                    dst_y + (src_box->bottom - src_box->top), dst_z, dst_z + (src_box->back - src_box->front));
+        }
+        else
+        {
+            src_row_block_count = (src_box->right - src_box->left + src_resource->format->block_width - 1)
+                    / src_resource->format->block_width;
+            src_row_count = (src_box->bottom - src_box->top + src_resource->format->block_height - 1)
+                    / src_resource->format->block_height;
+            wined3d_box_set(&dst_box, dst_x, dst_y,
+                    dst_x + (src_row_block_count * dst_resource->format->block_width),
+                    dst_y + (src_row_count * dst_resource->format->block_height),
+                    dst_z, dst_z + (src_box->back - src_box->front));
+        }
         if (FAILED(wined3d_texture_check_box_dimensions(dst_texture,
                 dst_sub_resource_idx % dst_texture->level_count, &dst_box)))
         {




More information about the wine-cvs mailing list