[v6 PATCH 3/3] wined3d: Update only dirty regions in wined3d_cs_exec_update_texture().
Masanori Kakura
kakurasan at gmail.com
Sun May 28 09:10:47 CDT 2017
Fixes https://bugs.winehq.org/show_bug.cgi?id=35205
v6 - Fix position calculation in wined3d_cs_exec_update_texture()
- Try to be less redundant
Signed-off-by: Masanori Kakura <kakurasan at gmail.com>
---
dlls/d3d8/tests/visual.c | 2 +-
dlls/d3d9/tests/visual.c | 2 +-
dlls/wined3d/context.c | 2 +-
dlls/wined3d/cs.c | 146 +++++++++++++++++++++++++----------------
dlls/wined3d/device.c | 4 +-
dlls/wined3d/surface.c | 38 +++++------
dlls/wined3d/swapchain.c | 8 +--
dlls/wined3d/texture.c | 29 ++++----
dlls/wined3d/view.c | 2 +-
dlls/wined3d/wined3d_private.h | 5 +-
10 files changed, 137 insertions(+), 101 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/context.c b/dlls/wined3d/context.c
index 49b9186645..8027f2b9e2 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2736,7 +2736,7 @@ static void context_validate_onscreen_formats(struct wined3d_context *context,
/* The currently active context is the necessary context to access the swapchain's onscreen buffers */
if (!(wined3d_texture_load_location(context->current_rt.texture, context->current_rt.sub_resource_idx,
- context, WINED3D_LOCATION_TEXTURE_RGB)))
+ context, NULL, WINED3D_LOCATION_TEXTURE_RGB)))
ERR("Failed to load location.\n");
swapchain->render_to_fbo = TRUE;
swapchain_update_draw_bindings(swapchain);
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 0132894cd9..04b6e7f3eb 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2021,7 +2021,7 @@ static void wined3d_cs_exec_blt_sub_resource(struct wined3d_cs *cs, const void *
context = context_acquire(cs->device, NULL, 0);
if (!wined3d_texture_load_location(src_texture, op->src_sub_resource_idx,
- context, src_texture->resource.map_binding))
+ context, NULL, src_texture->resource.map_binding))
{
ERR("Failed to load source sub-resource into %s.\n",
wined3d_debug_location(src_texture->resource.map_binding));
@@ -2037,7 +2037,7 @@ static void wined3d_cs_exec_blt_sub_resource(struct wined3d_cs *cs, const void *
wined3d_texture_prepare_texture(dst_texture, context, FALSE);
}
else if (!wined3d_texture_load_location(dst_texture, op->dst_sub_resource_idx,
- context, WINED3D_LOCATION_TEXTURE_RGB))
+ context, NULL, WINED3D_LOCATION_TEXTURE_RGB))
{
ERR("Failed to load destination sub-resource.\n");
context_release(context);
@@ -2140,7 +2140,7 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi
&& box->right == width && box->bottom == height && box->back == depth)
wined3d_texture_prepare_texture(texture, context, FALSE);
else
- wined3d_texture_load_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
+ wined3d_texture_load_location(texture, op->sub_resource_idx, context, NULL, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_bind_and_dirtify(texture, context, FALSE);
wined3d_texture_upload_data(texture, op->sub_resource_idx, context,
@@ -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;
@@ -2213,73 +2213,107 @@ static void wined3d_cs_exec_update_texture(struct wined3d_cs *cs, const void *da
if (dst_resource->type == WINED3D_RTYPE_TEXTURE_2D)
{
- RECT rect;
struct wined3d_surface *dst_surface, *src_surface;
dst_surface = dst_texture->sub_resources[dst_sub_resource_idx].u.surface;
src_surface = src_texture->sub_resources[src_sub_resource_idx].u.surface;
- SetRect(&rect, 0, 0, width, height);
-
- TRACE("src_texture %p, dst_texture %p, level %u, layer %u, "
- "src_sub_resource_idx %u, dst_sub_resource_idx %u, rect %s.\n",
- src_texture, dst_texture, i, j,
- src_sub_resource_idx, dst_sub_resource_idx, wine_dbgstr_rect(&rect));
- if (FAILED(wined3d_surface_blt(dst_surface, &rect, src_surface,
- &rect, 0, NULL, WINED3D_TEXF_POINT)))
- FIXME("Blit failed.\n");
+ 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];
+ RECT rect;
+
+ SetRect(&rect,
+ dirty_box->left >> i, dirty_box->top >> i,
+ dirty_box->right >> i, dirty_box->bottom >> i);
+ if (rect.right << i != dirty_box->right)
+ rect.right += 1;
+ rect.right = max(1, min(rect.right, width));
+ if (rect.bottom << i != dirty_box->bottom)
+ rect.bottom += 1;
+ rect.bottom = max(1, min(rect.bottom, height));
+
+ TRACE("src_texture %p, dst_texture %p, level %u, layer %u, "
+ "src_sub_resource_idx %u, dst_sub_resource_idx %u, rect %s.\n",
+ src_texture, dst_texture, i, j,
+ src_sub_resource_idx, dst_sub_resource_idx, wine_dbgstr_rect(&rect));
+
+ if (FAILED(wined3d_surface_blt(dst_surface, &rect, src_surface,
+ &rect, 0, NULL, WINED3D_TEXF_POINT)))
+ FIXME("Blit failed.\n");
+ }
}
else if (dst_resource->type == WINED3D_RTYPE_TEXTURE_3D)
{
- struct wined3d_box box;
unsigned int row_pitch, slice_pitch;
struct wined3d_context *context;
struct wined3d_bo_address addr;
- wined3d_box_set(&box, 0, 0, width, height, 0, depth);
-
- TRACE("src_texture %p, dst_texture %p, level %u, layer %u, "
- "src_sub_resource_idx %u, dst_sub_resource_idx %u, box %s.\n",
- src_texture, dst_texture, i, j,
- src_sub_resource_idx, dst_sub_resource_idx, debug_box(&box));
-
- if (box.left || box.top || box.front)
- {
- FIXME("Source box %s not supported for %s resources.\n",
- debug_box(&box), debug_d3dresourcetype(dst_resource->type));
- continue;
- }
-
context = context_acquire(cs->device, NULL, 0);
- if (!wined3d_texture_load_location(src_texture, src_sub_resource_idx,
- context, src_texture->resource.map_binding))
- {
- ERR("Failed to load source sub-resource into %s.\n",
- wined3d_debug_location(src_texture->resource.map_binding));
- goto release_context;
- }
-
- if (box.right - box.left == width
- && box.bottom - box.top == height
- && box.back - box.front == depth)
+ for (k = 0; k < src_texture->async.dirty_regions_count[j]; ++k)
{
- wined3d_texture_prepare_texture(dst_texture, context, FALSE);
+ const struct wined3d_box *dirty_box = &src_texture->async.dirty_regions[j][k];
+ struct wined3d_box box;
+
+ 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);
+ if (box.right << i != dirty_box->right)
+ box.right += 1;
+ box.right = max(1, min(box.right, width));
+ if (box.bottom << i != dirty_box->bottom)
+ box.bottom += 1;
+ box.bottom = max(1, min(box.bottom, height));
+ if (box.back << i != dirty_box->back)
+ box.back += 1;
+ box.back = max(1, min(box.back, depth));
+
+ TRACE("src_texture %p, dst_texture %p, level %u, layer %u, "
+ "src_sub_resource_idx %u, dst_sub_resource_idx %u, box %s.\n",
+ src_texture, dst_texture, i, j,
+ src_sub_resource_idx, dst_sub_resource_idx, debug_box(&box));
+
+ if (box.left || box.top || box.front)
+ {
+ FIXME("Source box %s not supported for %s resources.\n",
+ debug_box(&box), debug_d3dresourcetype(dst_resource->type));
+ goto release_context;
+ }
+
+ if (!wined3d_texture_load_location(src_texture, src_sub_resource_idx,
+ context, &box, src_texture->resource.map_binding))
+ {
+ ERR("Failed to load source sub-resource into %s.\n",
+ wined3d_debug_location(src_texture->resource.map_binding));
+ goto release_context;
+ }
+
+ if (box.right - box.left == width
+ && box.bottom - box.top == height
+ && box.back - box.front == depth)
+ {
+ wined3d_texture_prepare_texture(dst_texture, context, FALSE);
+ }
+ else if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx,
+ context, &box, WINED3D_LOCATION_TEXTURE_RGB))
+ {
+ ERR("Failed to load destination sub-resource.\n");
+ goto release_context;
+ }
+
+ if (k == 0)
+ {
+ wined3d_texture_get_memory(src_texture, src_sub_resource_idx, &addr, src_texture->resource.map_binding);
+ wined3d_texture_get_pitch(src_texture, src_sub_resource_idx % src_texture->level_count,
+ &row_pitch, &slice_pitch);
+
+ wined3d_texture_bind_and_dirtify(dst_texture, context, FALSE);
+ }
+ wined3d_texture_upload_data(dst_texture, dst_sub_resource_idx, context, &box,
+ wined3d_const_bo_address(&addr), row_pitch, slice_pitch);
}
- else if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx,
- context, WINED3D_LOCATION_TEXTURE_RGB))
- {
- ERR("Failed to load destination sub-resource.\n");
- goto release_context;
- }
-
- wined3d_texture_get_memory(src_texture, src_sub_resource_idx, &addr, src_texture->resource.map_binding);
- wined3d_texture_get_pitch(src_texture, src_sub_resource_idx % src_texture->level_count,
- &row_pitch, &slice_pitch);
-
- wined3d_texture_bind_and_dirtify(dst_texture, context, FALSE);
- wined3d_texture_upload_data(dst_texture, dst_sub_resource_idx, context, &box,
- wined3d_const_bo_address(&addr), row_pitch, slice_pitch);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
@@ -2337,7 +2371,7 @@ static void wined3d_cs_exec_add_dirty_texture_region(struct wined3d_cs *cs, cons
sub_resource_idx = op->layer * texture->level_count;
for (i = 0; i < texture->level_count; ++i, ++sub_resource_idx)
{
- if (wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding))
+ if (wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, texture->resource.map_binding))
wined3d_texture_invalidate_location(texture, sub_resource_idx, ~texture->resource.map_binding);
else
ERR("Failed to load location %s.\n", wined3d_debug_location(texture->resource.map_binding));
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 42ddbb389b..d837df7f8d 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -268,7 +268,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
struct wined3d_texture *rt = wined3d_texture_from_resource(rtv->resource);
if (flags & WINED3DCLEAR_TARGET && !is_full_clear(target, draw_rect, rect_count ? clear_rect : NULL))
- wined3d_texture_load_location(rt, rtv->sub_resource_idx, context, rtv->resource->draw_binding);
+ wined3d_texture_load_location(rt, rtv->sub_resource_idx, context, NULL, rtv->resource->draw_binding);
else
wined3d_texture_prepare_location(rt, rtv->sub_resource_idx, context, rtv->resource->draw_binding);
}
@@ -297,7 +297,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
DWORD location = render_offscreen ? dsv->resource->draw_binding : WINED3D_LOCATION_DRAWABLE;
wined3d_texture_load_location(depth_stencil->container,
- dsv->sub_resource_idx, context, location);
+ dsv->sub_resource_idx, context, NULL, location);
}
if (!context_apply_clear_state(context, state, rt_count, fb))
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index abdeb9cac0..e72c40dcdb 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -305,9 +305,9 @@ static void surface_depth_blt_fbo(const struct wined3d_device *device,
/* Make sure the locations are up-to-date. Loading the destination
* surface isn't required if the entire surface is overwritten. */
- wined3d_texture_load_location(src_texture, src_sub_resource_idx, context, src_location);
+ wined3d_texture_load_location(src_texture, src_sub_resource_idx, context, NULL, src_location);
if (!surface_is_full_rect(dst_surface, dst_rect))
- wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, dst_location);
+ wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, NULL, dst_location);
else
wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, context, dst_location);
@@ -402,9 +402,9 @@ static void surface_blt_fbo(const struct wined3d_device *device,
* surface isn't required if the entire surface is overwritten. (And is
* in fact harmful if we're being called by surface_load_location() with
* the purpose of loading the destination surface.) */
- wined3d_texture_load_location(src_texture, src_sub_resource_idx, old_ctx, src_location);
+ wined3d_texture_load_location(src_texture, src_sub_resource_idx, old_ctx, NULL, src_location);
if (!surface_is_full_rect(dst_surface, &dst_rect))
- wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, old_ctx, dst_location);
+ wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, old_ctx, NULL, dst_location);
else
wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, old_ctx, dst_location);
@@ -887,7 +887,7 @@ static HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface,
&& update_h == wined3d_texture_get_level_height(dst_texture, dst_surface->texture_level))
wined3d_texture_prepare_texture(dst_texture, context, FALSE);
else
- wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
+ wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, NULL, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_bind_and_dirtify(dst_texture, context, FALSE);
wined3d_texture_get_memory(src_texture, src_sub_resource_idx, &data,
@@ -1296,7 +1296,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
}
map_binding = src_texture->resource.map_binding;
- if (!wined3d_texture_load_location(src_texture, sub_resource_idx, context, map_binding))
+ if (!wined3d_texture_load_location(src_texture, sub_resource_idx, context, NULL, map_binding))
ERR("Failed to load the source sub-resource into %s.\n", wined3d_debug_location(map_binding));
wined3d_texture_get_pitch(src_texture, texture_level, &src_row_pitch, &src_slice_pitch);
wined3d_texture_get_memory(src_texture, sub_resource_idx, &src_data, map_binding);
@@ -1309,7 +1309,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
BYTE *dst;
map_binding = dst_texture->resource.map_binding;
- if (!wined3d_texture_load_location(dst_texture, 0, context, map_binding))
+ if (!wined3d_texture_load_location(dst_texture, 0, context, NULL, map_binding))
ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(map_binding));
wined3d_texture_get_pitch(dst_texture, 0, &dst_row_pitch, &dst_slice_pitch);
wined3d_texture_get_memory(dst_texture, 0, &dst_data, map_binding);
@@ -2081,7 +2081,7 @@ static BOOL surface_load_sysmem(struct wined3d_surface *surface,
wined3d_texture_prepare_location(texture, sub_resource_idx, context, dst_location);
if (sub_resource->locations & (WINED3D_LOCATION_RB_MULTISAMPLE | WINED3D_LOCATION_RB_RESOLVED))
- wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
+ wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, WINED3D_LOCATION_TEXTURE_RGB);
/* Download the surface to system memory. */
if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
@@ -2140,7 +2140,7 @@ static BOOL surface_load_drawable(struct wined3d_surface *surface,
SetRect(&r, 0, 0, wined3d_texture_get_level_width(texture, surface->texture_level),
wined3d_texture_get_level_height(texture, surface->texture_level));
- wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
+ wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, WINED3D_LOCATION_TEXTURE_RGB);
device->blitter->ops->blitter_blit(device->blitter, WINED3D_BLIT_OP_COLOR_BLIT, context,
surface, WINED3D_LOCATION_TEXTURE_RGB, &r,
surface, WINED3D_LOCATION_DRAWABLE, &r,
@@ -2227,7 +2227,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
== WINED3D_LOCATION_TEXTURE_RGB)
{
FIXME_(d3d_perf)("Downloading RGB surface %p to reload it as sRGB.\n", surface);
- wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding);
+ wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, texture->resource.map_binding);
}
}
else
@@ -2236,7 +2236,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
== WINED3D_LOCATION_TEXTURE_SRGB)
{
FIXME_(d3d_perf)("Downloading sRGB surface %p to reload it as RGB.\n", surface);
- wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding);
+ wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, texture->resource.map_binding);
}
}
@@ -2244,7 +2244,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
{
WARN("Trying to load a texture from sysmem, but no simple location is valid.\n");
/* Lets hope we get it from somewhere... */
- wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM);
+ wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, WINED3D_LOCATION_SYSMEM);
}
wined3d_texture_prepare_texture(texture, context, srgb);
@@ -2262,7 +2262,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
{
TRACE("Removing the pbo attached to surface %p.\n", surface);
- wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM);
+ wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, WINED3D_LOCATION_SYSMEM);
wined3d_texture_set_map_binding(texture, WINED3D_LOCATION_SYSMEM);
}
@@ -2907,7 +2907,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
map_binding = dst_texture->resource.map_binding;
texture_level = dst_sub_resource_idx % dst_texture->level_count;
- if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, map_binding))
+ if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, NULL, map_binding))
ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(map_binding));
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~map_binding);
wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch);
@@ -2944,7 +2944,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
map_binding = src_texture->resource.map_binding;
texture_level = src_sub_resource_idx % src_texture->level_count;
- if (!wined3d_texture_load_location(src_texture, src_sub_resource_idx, context, map_binding))
+ if (!wined3d_texture_load_location(src_texture, src_sub_resource_idx, context, NULL, map_binding))
ERR("Failed to load the source sub-resource into %s.\n", wined3d_debug_location(map_binding));
wined3d_texture_get_pitch(src_texture, texture_level, &src_map.row_pitch, &src_map.slice_pitch);
wined3d_texture_get_memory(src_texture, src_sub_resource_idx, &src_data, map_binding);
@@ -2953,7 +2953,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
map_binding = dst_texture->resource.map_binding;
texture_level = dst_sub_resource_idx % dst_texture->level_count;
- if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, map_binding))
+ if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, NULL, map_binding))
ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(map_binding));
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~map_binding);
wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch);
@@ -3386,7 +3386,7 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view,
texture = texture_from_resource(view->resource);
map_binding = texture->resource.map_binding;
- if (!wined3d_texture_load_location(texture, view->sub_resource_idx, context, map_binding))
+ if (!wined3d_texture_load_location(texture, view->sub_resource_idx, context, NULL, map_binding))
ERR("Failed to load the sub-resource into %s.\n", wined3d_debug_location(map_binding));
wined3d_texture_invalidate_location(texture, view->sub_resource_idx, ~map_binding);
wined3d_texture_get_pitch(texture, view->sub_resource_idx % texture->level_count,
@@ -3530,7 +3530,7 @@ static void cpu_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_
if (FAILED(surface_cpu_blt(dst_texture, dst_sub_resource_idx, &dst_box,
src_texture, src_sub_resource_idx, &src_box, flags, &fx, filter)))
ERR("Failed to blit.\n");
- wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, dst_location);
+ wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, NULL, dst_location);
}
static const struct wined3d_blitter_ops cpu_blitter_ops =
@@ -3726,7 +3726,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
{
context = context_acquire(device, dst_texture, dst_sub_resource_idx);
wined3d_texture_load_location(dst_texture, dst_sub_resource_idx,
- context, dst_texture->resource.draw_binding);
+ context, NULL, dst_texture->resource.draw_binding);
context_release(context);
}
return WINED3D_OK;
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index e23e99b67b..712089b38b 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -361,7 +361,7 @@ static void wined3d_swapchain_rotate(struct wined3d_swapchain *swapchain, struct
sub_resource = &texture->sub_resources[0];
if (!(sub_resource->locations & supported_locations))
- wined3d_texture_load_location(texture, 0, context, texture->resource.draw_binding);
+ wined3d_texture_load_location(texture, 0, context, NULL, texture->resource.draw_binding);
texture_prev->texture_rgb = texture->texture_rgb;
texture_prev->rb_multisample = texture->rb_multisample;
@@ -458,14 +458,14 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
*/
if (!swapchain->render_to_fbo && render_to_fbo && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
- wined3d_texture_load_location(back_buffer, 0, context, WINED3D_LOCATION_TEXTURE_RGB);
+ wined3d_texture_load_location(back_buffer, 0, context, NULL, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_invalidate_location(back_buffer, 0, WINED3D_LOCATION_DRAWABLE);
swapchain->render_to_fbo = TRUE;
swapchain_update_draw_bindings(swapchain);
}
else
{
- wined3d_texture_load_location(back_buffer, 0, context, back_buffer->resource.draw_binding);
+ wined3d_texture_load_location(back_buffer, 0, context, NULL, back_buffer->resource.draw_binding);
}
if (swapchain->render_to_fbo)
@@ -535,7 +535,7 @@ static void swapchain_gl_frontbuffer_updated(struct wined3d_swapchain *swapchain
struct wined3d_context *context;
context = context_acquire(swapchain->device, front_buffer, 0);
- wined3d_texture_load_location(front_buffer, 0, context, front_buffer->resource.draw_binding);
+ wined3d_texture_load_location(front_buffer, 0, context, NULL, front_buffer->resource.draw_binding);
context_release(context);
SetRectEmpty(&swapchain->front_buffer_update);
}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index e520979c90..5c5f1709e4 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -222,15 +222,16 @@ static BOOL wined3d_texture_copy_sysmem_location(struct wined3d_texture *texture
/* Context activation is done by the caller. Context may be NULL in
* WINED3D_NO3D mode. */
BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
- unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
+ unsigned int sub_resource_idx, struct wined3d_context *context,
+ const struct wined3d_box *box, DWORD location)
{
static const DWORD sysmem_locations = WINED3D_LOCATION_SYSMEM | WINED3D_LOCATION_USER_MEMORY
| WINED3D_LOCATION_BUFFER;
DWORD current = texture->sub_resources[sub_resource_idx].locations;
BOOL ret;
- TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
- texture, sub_resource_idx, context, wined3d_debug_location(location));
+ TRACE("texture %p, sub_resource_idx %u, context %p, location %s, box %s.\n",
+ texture, sub_resource_idx, context, wined3d_debug_location(location), debug_box(box));
TRACE("Current resource location %s.\n", wined3d_debug_location(current));
@@ -263,13 +264,13 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
ERR("Sub-resource %u of texture %p does not have any up to date location.\n",
sub_resource_idx, texture);
wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_DISCARDED);
- return wined3d_texture_load_location(texture, sub_resource_idx, context, location);
+ return wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, location);
}
if ((location & sysmem_locations) && (current & sysmem_locations))
ret = wined3d_texture_copy_sysmem_location(texture, sub_resource_idx, context, location);
else
- ret = texture->texture_ops->texture_load_location(texture, sub_resource_idx, context, location);
+ ret = texture->texture_ops->texture_load_location(texture, sub_resource_idx, context, box, location);
if (ret)
wined3d_texture_validate_location(texture, sub_resource_idx, location);
@@ -427,7 +428,7 @@ static void wined3d_texture_update_map_binding(struct wined3d_texture *texture)
for (i = 0; i < sub_count; ++i)
{
if (texture->sub_resources[i].locations == texture->resource.map_binding
- && !wined3d_texture_load_location(texture, i, context, map_binding))
+ && !wined3d_texture_load_location(texture, i, context, NULL, map_binding))
ERR("Failed to load location %s.\n", wined3d_debug_location(map_binding));
if (texture->resource.map_binding == WINED3D_LOCATION_BUFFER)
wined3d_texture_remove_buffer_object(texture, i, context->gl_info);
@@ -1001,7 +1002,7 @@ void wined3d_texture_load(struct wined3d_texture *texture,
TRACE("Reloading because of color key value change.\n");
for (i = 0; i < sub_count; i++)
{
- if (!wined3d_texture_load_location(texture, i, context, texture->resource.map_binding))
+ if (!wined3d_texture_load_location(texture, i, context, NULL, texture->resource.map_binding))
ERR("Failed to load location %s.\n", wined3d_debug_location(texture->resource.map_binding));
else
wined3d_texture_invalidate_location(texture, i, ~texture->resource.map_binding);
@@ -1019,7 +1020,7 @@ void wined3d_texture_load(struct wined3d_texture *texture,
/* Reload the surfaces if the texture is marked dirty. */
for (i = 0; i < sub_count; ++i)
{
- if (!wined3d_texture_load_location(texture, i, context,
+ if (!wined3d_texture_load_location(texture, i, context, NULL,
srgb ? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB))
ERR("Failed to load location (srgb %#x).\n", srgb);
}
@@ -1211,7 +1212,7 @@ static void texture2d_create_dc(void *object)
if (device->d3d_initialized)
context = context_acquire(device, NULL, 0);
- wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding);
+ wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, texture->resource.map_binding);
wined3d_texture_invalidate_location(texture, sub_resource_idx, ~texture->resource.map_binding);
wined3d_texture_get_pitch(texture, surface->texture_level, &row_pitch, &slice_pitch);
wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding);
@@ -1661,7 +1662,7 @@ static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int
}
static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
- struct wined3d_context *context, DWORD location)
+ struct wined3d_context *context, const struct wined3d_box *box, DWORD location)
{
return surface_load_location(texture->sub_resources[sub_resource_idx].u.surface, context, location);
}
@@ -1811,7 +1812,7 @@ static void wined3d_texture_unload(struct wined3d_resource *resource)
struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[i];
if (resource->pool != WINED3D_POOL_DEFAULT
- && wined3d_texture_load_location(texture, i, context, resource->map_binding))
+ && wined3d_texture_load_location(texture, i, context, NULL, resource->map_binding))
{
wined3d_texture_invalidate_location(texture, i, ~resource->map_binding);
}
@@ -1915,7 +1916,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
{
if (resource->usage & WINED3DUSAGE_DYNAMIC)
WARN_(d3d_perf)("Mapping a dynamic texture without WINED3D_MAP_DISCARD.\n");
- ret = wined3d_texture_load_location(texture, sub_resource_idx, context, resource->map_binding);
+ ret = wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, resource->map_binding);
}
if (!ret)
@@ -2451,7 +2452,7 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in
/* Context activation is done by the caller. */
static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
- struct wined3d_context *context, DWORD location)
+ struct wined3d_context *context, const struct wined3d_box *box, DWORD location)
{
struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
unsigned int row_pitch, slice_pitch;
@@ -2470,7 +2471,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
wined3d_texture_bind_and_dirtify(texture, context,
location == WINED3D_LOCATION_TEXTURE_SRGB);
wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
- texture3d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch);
+ texture3d_upload_data(texture, sub_resource_idx, context, box, &data, row_pitch, slice_pitch);
}
else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
{
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index adb43dd374..c452387777 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -461,7 +461,7 @@ void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *v
sub_resource_idx = view->sub_resource_idx;
layer_count = resource->type != WINED3D_RTYPE_TEXTURE_3D ? view->layer_count : 1;
for (i = 0; i < layer_count; ++i, sub_resource_idx += texture->level_count)
- wined3d_texture_load_location(texture, sub_resource_idx, context, location);
+ wined3d_texture_load_location(texture, sub_resource_idx, context, NULL, location);
}
void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view, DWORD location)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 7ba1c2f839..6fe7c8fb81 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2941,7 +2941,7 @@ struct wined3d_texture_ops
const struct wined3d_context *context, const struct wined3d_box *box,
const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch);
BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
- struct wined3d_context *context, DWORD location);
+ struct wined3d_context *context, const struct wined3d_box *box, DWORD location);
void (*texture_prepare_texture)(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb);
void (*texture_cleanup_sub_resources)(struct wined3d_texture *texture);
@@ -3086,7 +3086,8 @@ void wined3d_texture_invalidate_location(struct wined3d_texture *texture,
void wined3d_texture_load(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
- unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
+ unsigned int sub_resource_idx, struct wined3d_context *context,
+ const struct wined3d_box *box, DWORD location) DECLSPEC_HIDDEN;
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
void wined3d_texture_prepare_texture(struct wined3d_texture *texture,
--
2.11.0
More information about the wine-patches
mailing list