[PATCH v3 0/3] MR1865: wined3d: Load and invalidate every mipmap level when mapping the top mipmap level.
-- v3: wined3d: Load and invalidate every mipmap level when mapping the top mipmap level. d3d8/tests: Test uploading the whole mipmap chain in one map. d3d9/tests: Test uploading the whole mipmap chain in one map. https://gitlab.winehq.org/wine/wine/-/merge_requests/1865
From: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> --- dlls/d3d9/tests/visual.c | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 12105cfa0e0..fd835b195a9 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -260,6 +260,7 @@ static DWORD getPixelColor(IDirect3DDevice9 *device, UINT x, UINT y) #define check_rt_color(a, b) check_rt_color_(__LINE__, a, b, false) #define check_rt_color_todo(a, b) check_rt_color_(__LINE__, a, b, true) +#define check_rt_color_todo_if(a, b, c) check_rt_color_(__LINE__, a, b, c) static void check_rt_color_(unsigned int line, IDirect3DSurface9 *rt, D3DCOLOR expected_color, bool todo) { unsigned int color = 0xdeadbeef; @@ -27909,6 +27910,78 @@ static void test_managed_generate_mipmap(void) release_test_context(&context); } +/* Some applications lock a mipmapped texture at level 0, write every level at + * once, and expect it to be uploaded. */ +static void test_mipmap_upload(void) +{ + unsigned int i, j, width, level_count; + struct d3d9_test_context context; + IDirect3DTexture9 *texture; + D3DLOCKED_RECT locked_rect; + IDirect3DDevice9 *device; + unsigned int *mem; + HRESULT hr; + + static const D3DPOOL pools[] = + { + D3DPOOL_MANAGED, + D3DPOOL_SYSTEMMEM, + }; + + if (!init_test_context(&context)) + return; + device = context.device; + + for (i = 0; i < ARRAY_SIZE(pools); ++i) + { + winetest_push_context("pool %#x", pools[i]); + + hr = IDirect3DDevice9_CreateTexture(device, 32, 32, 0, 0, + D3DFMT_A8R8G8B8, pools[i], &texture, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + level_count = IDirect3DBaseTexture9_GetLevelCount(texture); + + hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + mem = locked_rect.pBits; + + for (j = 0; j < level_count; ++j) + { + width = 32 >> j; + memset(mem, 0x11 * (j + 1), width * width * 4); + mem += width * width; + } + + hr = IDirect3DTexture9_UnlockRect(texture, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + for (j = 0; j < level_count; ++j) + { + winetest_push_context("level %u", j); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, j); + 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); + + winetest_pop_context(); + } + + IDirect3DTexture9_Release(texture); + + winetest_pop_context(); + } + release_test_context(&context); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER9 identifier; @@ -28062,4 +28135,5 @@ START_TEST(visual) test_filling_convention(); test_managed_reset(); test_managed_generate_mipmap(); + test_mipmap_upload(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1865
From: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> --- dlls/d3d8/tests/visual.c | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index ea2d96378f7..c8822b4c0ca 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -250,6 +250,7 @@ static void check_rect(struct surface_readback *rb, RECT r, const char *message) #define check_rt_color(a, b) check_rt_color_(__LINE__, a, b, false) #define check_rt_color_todo(a, b) check_rt_color_(__LINE__, a, b, true) +#define check_rt_color_todo_if(a, b, c) check_rt_color_(__LINE__, a, b, c) static void check_rt_color_(unsigned int line, IDirect3DSurface8 *rt, D3DCOLOR expected_color, bool todo) { unsigned int color = 0xdeadbeef; @@ -12126,6 +12127,78 @@ static void test_managed_reset(void) release_test_context(&context); } +/* Some applications lock a mipmapped texture at level 0, write every level at + * once, and expect it to be uploaded. */ +static void test_mipmap_upload(void) +{ + unsigned int i, j, width, level_count; + struct d3d8_test_context context; + IDirect3DTexture8 *texture; + D3DLOCKED_RECT locked_rect; + IDirect3DDevice8 *device; + unsigned int *mem; + HRESULT hr; + + static const D3DPOOL pools[] = + { + D3DPOOL_MANAGED, + D3DPOOL_SYSTEMMEM, + }; + + if (!init_test_context(&context)) + return; + device = context.device; + + for (i = 0; i < ARRAY_SIZE(pools); ++i) + { + winetest_push_context("pool %#x", pools[i]); + + hr = IDirect3DDevice8_CreateTexture(device, 32, 32, 0, 0, + D3DFMT_A8R8G8B8, pools[i], &texture); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + level_count = IDirect3DBaseTexture8_GetLevelCount(texture); + + hr = IDirect3DTexture8_LockRect(texture, 0, &locked_rect, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + mem = locked_rect.pBits; + + for (j = 0; j < level_count; ++j) + { + width = 32 >> j; + memset(mem, 0x11 * (j + 1), width * width * 4); + mem += width * width; + } + + hr = IDirect3DTexture8_UnlockRect(texture, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + for (j = 0; j < level_count; ++j) + { + winetest_push_context("level %u", j); + + hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MIPFILTER, D3DTEXF_POINT); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAXMIPLEVEL, j); + 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); + + winetest_pop_context(); + } + + IDirect3DTexture8_Release(texture); + + winetest_pop_context(); + } + release_test_context(&context); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER8 identifier; @@ -12208,4 +12281,5 @@ START_TEST(visual) test_dynamic_map_synchronization(); test_filling_convention(); test_managed_reset(); + test_mipmap_upload(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1865
From: Zebediah Figura <zfigura(a)codeweavers.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53743 Signed-off-by: Zebediah Figura <zfigura(a)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 fd835b195a9..57b14eeb20d 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -27970,7 +27970,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); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1865
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=128001 Your paranoid android. === build (build log) === error: patch failed: dlls/d3d9/tests/visual.c:28062 error: patch failed: dlls/d3d9/tests/visual.c:27970 Task: Patch failed to apply === debian11 (build log) === error: patch failed: dlls/d3d9/tests/visual.c:28062 error: patch failed: dlls/d3d9/tests/visual.c:27970 Task: Patch failed to apply === debian11b (build log) === error: patch failed: dlls/d3d9/tests/visual.c:28062 error: patch failed: dlls/d3d9/tests/visual.c:27970 Task: Patch failed to apply
v3: Remove the SCRATCH tests for now; they seem to fail on WARP and they aren't particularly interesting. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1865#note_20070
This merge request was approved by Jan Sikorski. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1865
participants (4)
-
Jan Sikorski (@jsikorski) -
Marvin -
Zebediah Figura -
Zebediah Figura (@zfigura)