Commit 54edd5b2 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

wined3d: Update a part of the texture if dirty regions are tracked.

parent c90d3417
......@@ -19340,7 +19340,7 @@ static void add_dirty_rect_test(void)
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
add_dirty_rect_test_draw(device);
color = getPixelColor(device, 320, 240);
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);
......@@ -19353,7 +19353,7 @@ static void add_dirty_rect_test(void)
ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
add_dirty_rect_test_draw(device);
color = getPixelColor(device, 320, 240);
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);
......@@ -19365,7 +19365,7 @@ static void add_dirty_rect_test(void)
ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
add_dirty_rect_test_draw(device);
color = getPixelColor(device, 320, 240);
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);
......@@ -19382,7 +19382,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);
......@@ -19404,7 +19404,7 @@ static void add_dirty_rect_test(void)
ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
add_dirty_rect_test_draw(device);
color = getPixelColor(device, 320, 240);
todo_wine ok(color_match(color, 0x0000ff00, 1),
ok(color_match(color, 0x0000ff00, 1),
"Expected color 0x0000ff00, got 0x%08x.\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
......@@ -19416,7 +19416,7 @@ static void add_dirty_rect_test(void)
ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
add_dirty_rect_test_draw(device);
color = getPixelColor(device, 320, 240);
todo_wine ok(color_match(color, 0x0000ff00, 1),
ok(color_match(color, 0x0000ff00, 1),
"Expected color 0x0000ff00, got 0x%08x.\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
......@@ -4141,10 +4141,9 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
}
}
if (!entire_texture)
FIXME("Ignoring dirty regions.\n");
/* Update every surface level of the texture. */
if (entire_texture)
{
for (i = 0; i < level_count; ++i)
{
wined3d_texture_get_level_box(dst_texture, i, &box);
......@@ -4156,6 +4155,54 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
0, NULL, WINED3D_TEXF_POINT);
}
}
}
else
{
unsigned int src_level, box_count, k;
const struct wined3d_box *boxes;
struct wined3d_box b;
for (i = 0; i < layer_count; ++i)
{
boxes = regions[i].boxes;
box_count = regions[i].box_count;
if (regions[i].box_count >= WINED3D_MAX_DIRTY_REGION_COUNT)
{
boxes = &b;
box_count = 1;
wined3d_texture_get_level_box(dst_texture, i, &b);
}
for (j = 0; j < level_count; ++j)
{
src_level = j + src_skip_levels;
/* TODO: We could pass an array of boxes here to avoid
* multiple context acquisitions for the same resource. */
for (k = 0; k < box_count; ++k)
{
box = boxes[k];
if (src_level)
{
box.left >>= src_level;
box.top >>= src_level;
box.right = min((box.right + (1u << src_level) - 1) >> src_level,
wined3d_texture_get_level_width(src_texture, src_level));
box.bottom = min((box.bottom + (1u << src_level) - 1) >> src_level,
wined3d_texture_get_level_height(src_texture, src_level));
box.front >>= src_level;
box.back = min((box.back + (1u << src_level) - 1) >> src_level,
wined3d_texture_get_level_depth(src_texture, src_level));
}
wined3d_cs_emit_blt_sub_resource(device->cs,
&dst_texture->resource, i * dst_level_count + j, &box,
&src_texture->resource, i * src_level_count + src_level, &box,
0, NULL, WINED3D_TEXF_POINT);
}
}
}
}
wined3d_texture_clear_dirty_regions(src_texture);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment