[PATCH 10/10] wined3d: Update only dirty region for level 0 in wined3d_device_update_texture().
Masanori Kakura
kakurasan at gmail.com
Mon Apr 17 08:47:15 CDT 2017
Fixes https://bugs.winehq.org/show_bug.cgi?id=35205
Signed-off-by: Masanori Kakura <kakurasan at gmail.com>
---
dlls/d3d9/tests/visual.c | 2 +-
dlls/wined3d/device.c | 60 ++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 51 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 0bc22ead8d..a564222864 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -17471,7 +17471,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 44f468ef31..9ca35c0c39 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3612,19 +3612,59 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
}
/* 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 (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);
+ if (i == 0)
+ {
+ struct wined3d_dirty_regions *d = src_texture->resource.dirty_regions;
+ for (j = 0; j < layer_count; ++j)
+ {
+ for (; d; d = d->next)
+ {
+ wined3d_cs_emit_blt_sub_resource(device->cs,
+ &dst_texture->resource, j * dst_level_count, (struct wined3d_box *)d,
+ &src_texture->resource, j * src_level_count + src_skip_levels, (struct wined3d_box *)d,
+ 0, NULL, WINED3D_TEXF_POINT);
+ }
+ }
+ }
+ else
+ {
+ wined3d_box_set(&box, 0, 0, width, height, 0, depth);
- for (j = 0; j < layer_count; ++j)
+ 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);
+ }
+ }
+ }
+ }
+ else
+ {
+ 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);
+ 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