[v5 PATCH 3/3] wined3d: Update only dirty regions in wined3d_cs_exec_update_texture().
Masanori Kakura
kakurasan at gmail.com
Wed May 24 08:49:57 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/cs.c | 53 ++++++++++++++++++++++++++++++++++++------------
3 files changed, 42 insertions(+), 15 deletions(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index b074d9c661..9113ceb21c 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -5383,7 +5383,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 a23ba32a20..14196dbe29 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -17504,7 +17504,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/cs.c b/dlls/wined3d/cs.c
index 53465ed411..c766cb5832 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2188,7 +2188,7 @@ static void wined3d_cs_exec_update_texture(struct wined3d_cs *cs, const void *da
unsigned int src_level_count = op->src_level_count;
unsigned int dst_level_count = op->dst_level_count;
unsigned int src_skip_levels = op->src_skip_levels;
- unsigned int i, j;
+ unsigned int i, j, k;
unsigned int width, height, depth;
UINT src_dirty_layers = 0;
struct wined3d_box box;
@@ -2199,20 +2199,47 @@ static void wined3d_cs_exec_update_texture(struct wined3d_cs *cs, const void *da
if (src_dirty_layers == 0)
goto release;
- /* 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)
+ {
+ for (j = 0; j < layer_count; ++j)
+ {
+ for (k = 0; k < src_texture->async.dirty_regions_count[j]; ++k)
+ {
+ const struct wined3d_box *dirty_box = &src_texture->async.dirty_regions[j][k];
+
+ 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(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);
+ }
+ }
+ }
+ }
+ else
+ {
+ /* Update every surface level of the texture. */
+ for (i = 0; i < level_count; ++i)
{
- wined3d_cs_emit_blt_sub_resource(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);
+ 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(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