Module: wine Branch: master Commit: d9c369c7476c8681fc78cd0a38fb97e80036edaa URL: https://gitlab.winehq.org/wine/wine/-/commit/d9c369c7476c8681fc78cd0a38fb97e...
Author: Zebediah Figura zfigura@codeweavers.com Date: Tue Dec 20 17:47:54 2022 -0600
wined3d: Load and invalidate every mipmap level when mapping the top mipmap level.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53743 Signed-off-by: Zebediah Figura zfigura@codeweavers.com
---
dlls/d3d8/tests/visual.c | 2 +- dlls/d3d9/tests/visual.c | 2 +- dlls/wined3d/texture.c | 31 ++++++++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index c8822b4c0ca..5c2b71fc8c5 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -12187,7 +12187,7 @@ static void test_mipmap_upload(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
draw_textured_quad(&context, texture); - check_rt_color_todo_if(context.backbuffer, 0x00111111 * (j + 1), j > 0); + check_rt_color(context.backbuffer, 0x00111111 * (j + 1));
winetest_pop_context(); } diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index dfbfc705598..230f7deabb2 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -27983,7 +27983,7 @@ static void test_mipmap_upload(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
draw_textured_quad(&context, texture); - check_rt_color_todo_if(context.backbuffer, 0x00111111 * (j + 1), j > 0); + check_rt_color(context.backbuffer, 0x00111111 * (j + 1));
winetest_pop_context(); } diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index bb19ac6183d..8d416494eb8 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -3697,7 +3697,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour struct wined3d_bo_address data; unsigned int texture_level; BYTE *base_memory; - BOOL ret; + BOOL ret = TRUE;
TRACE("resource %p, sub_resource_idx %u, map_ptr %p, box %s, flags %#x.\n", resource, sub_resource_idx, map_ptr, debug_box(box), flags); @@ -3732,7 +3732,20 @@ 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); + if (!texture_level) + { + unsigned int i; + + for (i = 0; i < texture->level_count; ++i) + { + if (!(ret = wined3d_texture_load_location(texture, sub_resource_idx + i, context, resource->map_binding))) + break; + } + } + else + { + ret = wined3d_texture_load_location(texture, sub_resource_idx, context, resource->map_binding); + } }
if (!ret) @@ -3748,7 +3761,19 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour wined3d_texture_dirty_region_add(texture, sub_resource_idx / texture->level_count, box);
if (flags & WINED3D_MAP_WRITE) - wined3d_texture_invalidate_location(texture, sub_resource_idx, ~resource->map_binding); + { + if (!texture_level) + { + unsigned int i; + + for (i = 0; i < texture->level_count; ++i) + wined3d_texture_invalidate_location(texture, sub_resource_idx + i, ~resource->map_binding); + } + else + { + wined3d_texture_invalidate_location(texture, sub_resource_idx, ~resource->map_binding); + } + }
wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, resource->map_binding); base_memory = wined3d_context_map_bo_address(context, &data, sub_resource->size, flags);