[v4 PATCH 2/2] wined3d: Update only dirty regions in wined3d_device_update_texture().
Masanori Kakura
kakurasan at gmail.com
Tue Apr 25 09:11:31 CDT 2017
Fixes https://bugs.winehq.org/show_bug.cgi?id=35205
The width/height/depth check is still needed because Wine d3d8/d3d9 tests crash without the check.
Signed-off-by: Masanori Kakura <kakurasan at gmail.com>
---
dlls/d3d8/tests/visual.c | 2 +-
dlls/d3d9/tests/visual.c | 2 +-
dlls/wined3d/device.c | 49 ++++++++++++++++++++++++++++++++++++------------
3 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index c4e9e4c57c..4446b4a107 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -5356,7 +5356,7 @@ static void add_dirty_rect_test(void)
ok(color_match(color, 0x0000ff00, 1),
"Expected color 0x0000ff00, got 0x%08x.\n", color);
color = getPixelColor(device, 1, 1);
- todo_wine ok(color_match(color, 0x00ff0000, 1),
+ ok(color_match(color, 0x00ff0000, 1),
"Expected color 0x00ff0000, got 0x%08x.\n", color);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 5e00ec5e40..4f44aee174 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -17477,7 +17477,7 @@ static void add_dirty_rect_test(void)
ok(color_match(color, 0x0000ff00, 1),
"Expected color 0x0000ff00, got 0x%08x.\n", color);
color = getPixelColor(device, 1, 1);
- todo_wine ok(color_match(color, 0x00ff0000, 1),
+ ok(color_match(color, 0x00ff0000, 1),
"Expected color 0x00ff0000, got 0x%08x.\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 03ac2af6b3..adac30f6bd 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3687,20 +3687,45 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
return WINED3DERR_INVALIDCALL;
}
- /* Update every surface level of the texture. */
- for (i = 0; i < level_count; ++i)
+ if (src_texture->resource.width <= dst_texture->resource.width
+ && src_texture->resource.height <= dst_texture->resource.height
+ && src_texture->resource.depth <= dst_texture->resource.depth)
{
- width = wined3d_texture_get_level_width(dst_texture, i);
- height = wined3d_texture_get_level_height(dst_texture, i);
- depth = wined3d_texture_get_level_depth(dst_texture, i);
- wined3d_box_set(&box, 0, 0, width, height, 0, depth);
-
- for (j = 0; j < layer_count; ++j)
+ for (i = 0; i < level_count; ++i)
{
- wined3d_cs_emit_blt_sub_resource(device->cs,
- &dst_texture->resource, j * dst_level_count + i, &box,
- &src_texture->resource, j * src_level_count + i + src_skip_levels, &box,
- 0, NULL, WINED3D_TEXF_POINT);
+ for (j = 0; j < src_texture->dirty_regions_count; ++j)
+ {
+ const struct wined3d_box *dirty_box = &src_texture->dirty_regions[j].box;
+ const UINT layer = src_texture->dirty_regions[j].layer;
+
+ wined3d_box_set(&box,
+ dirty_box->left >> i, dirty_box->top >> i,
+ dirty_box->right >> i, dirty_box->bottom >> i,
+ dirty_box->front >> i, dirty_box->back >> i);
+ wined3d_cs_emit_blt_sub_resource(device->cs,
+ &dst_texture->resource, layer * dst_level_count + i, &box,
+ &src_texture->resource, layer * src_level_count + i + src_skip_levels, &box,
+ 0, NULL, WINED3D_TEXF_POINT);
+ }
+ }
+ }
+ else
+ {
+ /* Update every surface level of the texture. */
+ for (i = 0; i < level_count; ++i)
+ {
+ width = wined3d_texture_get_level_width(dst_texture, i);
+ height = wined3d_texture_get_level_height(dst_texture, i);
+ depth = wined3d_texture_get_level_depth(dst_texture, i);
+ wined3d_box_set(&box, 0, 0, width, height, 0, depth);
+
+ for (j = 0; j < layer_count; ++j)
+ {
+ wined3d_cs_emit_blt_sub_resource(device->cs,
+ &dst_texture->resource, j * dst_level_count + i, &box,
+ &src_texture->resource, j * src_level_count + i + src_skip_levels, &box,
+ 0, NULL, WINED3D_TEXF_POINT);
+ }
}
}
--
2.11.0
More information about the wine-patches
mailing list