From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index d1bcaf39c14..bed8b5257f1 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; @@ -27869,6 +27870,79 @@ 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 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, + D3DPOOL_SCRATCH, + }; + + 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; @@ -28021,4 +28095,5 @@ START_TEST(visual) test_dynamic_map_synchronization(); test_filling_convention(); test_managed_reset(); + test_mipmap_upload(); }
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d8/tests/visual.c | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index 434474b292d..e629b66eaa9 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; @@ -12125,6 +12126,79 @@ 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, + D3DPOOL_SCRATCH, + }; + + 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; @@ -12207,4 +12281,5 @@ START_TEST(visual) test_dynamic_map_synchronization(); test_filling_convention(); test_managed_reset(); + test_mipmap_upload(); }
From: Zebediah Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53743 --- 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 e629b66eaa9..84d919090c8 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), j > 0);
winetest_pop_context(); } diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index bed8b5257f1..3c5e7d17b33 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -27931,7 +27931,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), j > 0);
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);
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=127936
Your paranoid android.
=== build (build log) ===
../wine/dlls/d3d8/tests/visual.c:12191:75: error: macro "check_rt_color" passed 3 arguments, but takes just 2 ../wine/dlls/d3d8/tests/visual.c:12191:13: error: ���check_rt_color��� undeclared (first use in this function) Makefile:20676: recipe for target 'dlls/d3d8/tests/i386-windows/visual.o' failed ../wine/dlls/d3d9/tests/visual.c:27941:75: error: macro "check_rt_color" passed 3 arguments, but takes just 2 ../wine/dlls/d3d9/tests/visual.c:27941:13: error: ���check_rt_color��� undeclared (first use in this function) Makefile:21517: recipe for target 'dlls/d3d9/tests/i386-windows/visual.o' failed Task: The exe32 Wine build failed
=== debian11 (build log) ===
../wine/dlls/d3d8/tests/visual.c:12191:75: error: macro "check_rt_color" passed 3 arguments, but takes just 2 ../wine/dlls/d3d8/tests/visual.c:12191:13: error: ���check_rt_color��� undeclared (first use in this function); did you mean ���check_rt_color_���? ../wine/dlls/d3d9/tests/visual.c:27941:75: error: macro "check_rt_color" passed 3 arguments, but takes just 2 ../wine/dlls/d3d9/tests/visual.c:27941:13: error: ���check_rt_color��� undeclared (first use in this function); did you mean ���check_rt_color_���? Task: The win32 Wine build failed
=== debian11b (build log) ===
../wine/dlls/d3d8/tests/visual.c:12191:75: error: macro "check_rt_color" passed 3 arguments, but takes just 2 ../wine/dlls/d3d8/tests/visual.c:12191:13: error: ���check_rt_color��� undeclared (first use in this function); did you mean ���check_rt_color_���? ../wine/dlls/d3d9/tests/visual.c:27941:75: error: macro "check_rt_color" passed 3 arguments, but takes just 2 ../wine/dlls/d3d9/tests/visual.c:27941:13: error: ���check_rt_color��� undeclared (first use in this function); did you mean ���check_rt_color_���? Task: The wow64 Wine build failed