-- v2: d3d9/tests: Add more tests for dirty rect handling. d3d8/tests: Add more tests for dirty rect handling. d3d8/tests: Read back directly from the specified surface if possible. d3d9/tests: Expand tests for valid pools in UpdateTexture(). d3d8/tests: Expand tests for valid pools in UpdateTexture(). wined3d: Use wined3d_array_reserve() in wined3d_adapter_create_output().
From: Zebediah Figura zfigura@codeweavers.com
This also has the effect of consistently zero-initializing the wined3d_output structure.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53497 --- dlls/wined3d/directx.c | 14 ++------------ dlls/wined3d/wined3d_private.h | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 0444f76a5c6..fa4432a5dd8 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -3409,21 +3409,11 @@ static struct wined3d_adapter *wined3d_adapter_no3d_create(unsigned int ordinal,
static BOOL wined3d_adapter_create_output(struct wined3d_adapter *adapter, const WCHAR *output_name) { - struct wined3d_output *outputs; HRESULT hr;
- if (!adapter->outputs && !(adapter->outputs = heap_calloc(1, sizeof(*adapter->outputs)))) - { + if (!wined3d_array_reserve((void **)&adapter->outputs, &adapter->outputs_size, + adapter->output_count + 1, sizeof(*adapter->outputs))) return FALSE; - } - else - { - if (!(outputs = heap_realloc(adapter->outputs, - sizeof(*adapter->outputs) * (adapter->output_count + 1)))) - return FALSE; - - adapter->outputs = outputs; - }
if (FAILED(hr = wined3d_output_init(&adapter->outputs[adapter->output_count], adapter->output_count, adapter, output_name))) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 95af2775dfe..1dbd90067f5 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3525,7 +3525,7 @@ struct wined3d_adapter struct wined3d_d3d_info d3d_info; struct wined3d_driver_info driver_info; struct wined3d_output *outputs; - unsigned int output_count; + SIZE_T output_count, outputs_size; D3DKMT_HANDLE kmt_adapter; UINT64 vram_bytes_used; GUID driver_uuid;
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d8/tests/device.c | 229 ++++++++++++++++++++++++++------------- 1 file changed, 153 insertions(+), 76 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index d7c149f8154..4f362ad5ea5 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -7019,6 +7019,150 @@ out: DestroyWindow(window); }
+static void test_update_texture_pool(void) +{ + static const struct + { + D3DPOOL pool; + DWORD usage; + } + tests[] = + { + {D3DPOOL_DEFAULT, D3DUSAGE_DYNAMIC}, + {D3DPOOL_MANAGED, 0}, + {D3DPOOL_SYSTEMMEM, 0}, + {D3DPOOL_SCRATCH, 0}, + }; + + unsigned int expect_colour, colour, i, j; + IDirect3DVolumeTexture8 *src_3d, *dst_3d; + IDirect3DTexture8 *src_2d, *dst_2d; + D3DLOCKED_RECT locked_rect; + IDirect3DDevice8 *device; + D3DLOCKED_BOX locked_box; + IDirect3D8 *d3d8; + ULONG refcount; + D3DCAPS8 caps; + HWND window; + HRESULT hr; + + window = create_window(); + d3d8 = Direct3DCreate8(D3D_SDK_VERSION); + ok(!!d3d8, "Failed to create a D3D object.\n"); + if (!(device = create_device(d3d8, window, NULL))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + IDirect3D8_Release(d3d8); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice8_GetDeviceCaps(device, &caps); + ok(hr == S_OK, "Failed to get caps, hr %#lx.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + for (j = 0; j < ARRAY_SIZE(tests); ++j) + { + winetest_push_context("Source test %u, destination test %u", i, j); + + hr = IDirect3DDevice8_CreateTexture(device, 1, 1, 1, + tests[i].usage, D3DFMT_A8R8G8B8, tests[i].pool, &src_2d); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_CreateTexture(device, 1, 1, 1, + tests[j].usage, D3DFMT_A8R8G8B8, tests[j].pool, &dst_2d); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DTexture8_LockRect(src_2d, 0, &locked_rect, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + *((DWORD *)locked_rect.pBits) = 0x11223344; + hr = IDirect3DTexture8_UnlockRect(src_2d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DTexture8_LockRect(dst_2d, 0, &locked_rect, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + *((DWORD *)locked_rect.pBits) = 0x44332211; + hr = IDirect3DTexture8_UnlockRect(dst_2d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)src_2d, + (IDirect3DBaseTexture8 *)dst_2d); + if (tests[i].pool == D3DPOOL_SYSTEMMEM && tests[j].pool == D3DPOOL_DEFAULT) + { + expect_colour = 0x11223344; + ok(hr == S_OK, "Got hr %#lx.\n", hr); + } + else + { + expect_colour = 0x44332211; + ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr); + } + + hr = IDirect3DTexture8_LockRect(dst_2d, 0, &locked_rect, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + colour = *((DWORD *)locked_rect.pBits); + ok(colour == expect_colour, "Expected colour %08x, got %08x.\n", expect_colour, colour); + hr = IDirect3DTexture8_UnlockRect(dst_2d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + IDirect3DTexture8_Release(src_2d); + IDirect3DTexture8_Release(dst_2d); + + if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)) + continue; + + hr = IDirect3DDevice8_CreateVolumeTexture(device, 1, 1, 1, 1, + tests[i].usage, D3DFMT_A8R8G8B8, tests[i].pool, &src_3d); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_CreateVolumeTexture(device, 1, 1, 1, 1, + tests[j].usage, D3DFMT_A8R8G8B8, tests[j].pool, &dst_3d); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DVolumeTexture8_LockBox(src_3d, 0, &locked_box, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + *((DWORD *)locked_box.pBits) = 0x11223344; + hr = IDirect3DVolumeTexture8_UnlockBox(src_3d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DVolumeTexture8_LockBox(dst_3d, 0, &locked_box, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + *((DWORD *)locked_box.pBits) = 0x44332211; + hr = IDirect3DVolumeTexture8_UnlockBox(dst_3d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)src_3d, + (IDirect3DBaseTexture8 *)dst_3d); + if (tests[i].pool == D3DPOOL_SYSTEMMEM && tests[j].pool == D3DPOOL_DEFAULT) + { + expect_colour = 0x11223344; + ok(hr == S_OK, "Got hr %#lx.\n", hr); + } + else + { + expect_colour = 0x44332211; + ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr); + } + + hr = IDirect3DVolumeTexture8_LockBox(dst_3d, 0, &locked_box, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + colour = *((DWORD *)locked_box.pBits); + ok(colour == expect_colour, "Expected colour %08x, got %08x.\n", expect_colour, colour); + hr = IDirect3DVolumeTexture8_UnlockBox(dst_3d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + IDirect3DVolumeTexture8_Release(src_3d); + IDirect3DVolumeTexture8_Release(dst_3d); + + winetest_pop_context(); + } + } + + refcount = IDirect3DDevice8_Release(device); + ok(!refcount, "Device has %lu references left.\n", refcount); + IDirect3D8_Release(d3d8); + DestroyWindow(window); +} + static void test_update_volumetexture(void) { D3DADAPTER_IDENTIFIER8 identifier; @@ -7028,44 +7172,17 @@ static void test_update_volumetexture(void) HRESULT hr; IDirect3DVolumeTexture8 *src, *dst; unsigned int i; - D3DLOCKED_BOX locked_box; ULONG refcount; D3DCAPS8 caps; BOOL is_warp; - static const struct - { - D3DPOOL src_pool, dst_pool; - HRESULT hr; - } - tests[] = - { - { D3DPOOL_DEFAULT, D3DPOOL_DEFAULT, D3DERR_INVALIDCALL }, - { D3DPOOL_MANAGED, D3DPOOL_DEFAULT, D3DERR_INVALIDCALL }, - { D3DPOOL_SYSTEMMEM, D3DPOOL_DEFAULT, D3D_OK }, - { D3DPOOL_SCRATCH, D3DPOOL_DEFAULT, D3DERR_INVALIDCALL }, - - { D3DPOOL_DEFAULT, D3DPOOL_MANAGED, D3DERR_INVALIDCALL }, - { D3DPOOL_MANAGED, D3DPOOL_MANAGED, D3DERR_INVALIDCALL }, - { D3DPOOL_SYSTEMMEM, D3DPOOL_MANAGED, D3DERR_INVALIDCALL }, - { D3DPOOL_SCRATCH, D3DPOOL_MANAGED, D3DERR_INVALIDCALL }, - - { D3DPOOL_DEFAULT, D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL }, - { D3DPOOL_MANAGED, D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL }, - { D3DPOOL_SYSTEMMEM, D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL }, - { D3DPOOL_SCRATCH, D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL }, - - { D3DPOOL_DEFAULT, D3DPOOL_SCRATCH, D3DERR_INVALIDCALL }, - { D3DPOOL_MANAGED, D3DPOOL_SCRATCH, D3DERR_INVALIDCALL }, - { D3DPOOL_SYSTEMMEM, D3DPOOL_SCRATCH, D3DERR_INVALIDCALL }, - { D3DPOOL_SCRATCH, D3DPOOL_SCRATCH, D3DERR_INVALIDCALL }, - }; + static const struct { UINT src_size, dst_size; UINT src_lvl, dst_lvl; D3DFORMAT src_fmt, dst_fmt; } - tests2[] = + tests[] = { { 8, 8, 0, 0, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, { 8, 8, 4, 4, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, @@ -7093,62 +7210,21 @@ static void test_update_volumetexture(void)
hr = IDirect3DDevice8_GetDeviceCaps(device, &caps); ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr); - if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)) - { - skip("Volume textures not supported, skipping test.\n"); - goto out; - } - - for (i = 0; i < ARRAY_SIZE(tests); i++) - { - DWORD src_usage = tests[i].src_pool == D3DPOOL_DEFAULT ? D3DUSAGE_DYNAMIC : 0; - DWORD dst_usage = tests[i].dst_pool == D3DPOOL_DEFAULT ? D3DUSAGE_DYNAMIC : 0; - - hr = IDirect3DDevice8_CreateVolumeTexture(device, 1, 1, 1, 1, src_usage, - D3DFMT_A8R8G8B8, tests[i].src_pool, &src); - ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr); - hr = IDirect3DDevice8_CreateVolumeTexture(device, 1, 1, 1, 1, dst_usage, - D3DFMT_A8R8G8B8, tests[i].dst_pool, &dst); - ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr); - - hr = IDirect3DVolumeTexture8_LockBox(src, 0, &locked_box, NULL, 0); - ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr); - *((DWORD *)locked_box.pBits) = 0x11223344; - hr = IDirect3DVolumeTexture8_UnlockBox(src, 0); - ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr); - - hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)src, (IDirect3DBaseTexture8 *)dst); - ok(hr == tests[i].hr, "UpdateTexture returned %#lx, expected %#lx, src pool %#x, dst pool %#x.\n", - hr, tests[i].hr, tests[i].src_pool, tests[i].dst_pool); - - if (SUCCEEDED(hr)) - { - unsigned int content = *((unsigned int *)locked_box.pBits); - hr = IDirect3DVolumeTexture8_LockBox(dst, 0, &locked_box, NULL, 0); - ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr); - ok(content == 0x11223344, "Dest texture contained %#x, expected 0x11223344.\n", content); - hr = IDirect3DVolumeTexture8_UnlockBox(dst, 0); - ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr); - } - IDirect3DVolumeTexture8_Release(src); - IDirect3DVolumeTexture8_Release(dst); - } - - if (!(caps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP)) + if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) || !(caps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP)) { skip("Mipmapped volume maps not supported.\n"); goto out; }
- for (i = 0; i < ARRAY_SIZE(tests2); i++) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice8_CreateVolumeTexture(device, - tests2[i].src_size, tests2[i].src_size, tests2[i].src_size, - tests2[i].src_lvl, 0, tests2[i].src_fmt, D3DPOOL_SYSTEMMEM, &src); + tests[i].src_size, tests[i].src_size, tests[i].src_size, + tests[i].src_lvl, 0, tests[i].src_fmt, D3DPOOL_SYSTEMMEM, &src); ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx, case %u.\n", hr, i); hr = IDirect3DDevice8_CreateVolumeTexture(device, - tests2[i].dst_size, tests2[i].dst_size, tests2[i].dst_size, - tests2[i].dst_lvl, 0, tests2[i].dst_fmt, D3DPOOL_DEFAULT, &dst); + tests[i].dst_size, tests[i].dst_size, tests[i].dst_size, + tests[i].dst_lvl, 0, tests[i].dst_fmt, D3DPOOL_DEFAULT, &dst); ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx, case %u.\n", hr, i);
hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)src, (IDirect3DBaseTexture8 *)dst); @@ -10856,6 +10932,7 @@ START_TEST(device) test_pinned_buffers(); test_npot_textures(); test_volume_locking(); + test_update_texture_pool(); test_update_volumetexture(); test_create_rt_ds_fail(); test_volume_blocks();
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/device.c | 229 ++++++++++++++++++++++++++------------- 1 file changed, 153 insertions(+), 76 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index a939b18a5e1..119ab0b3b34 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -10187,6 +10187,150 @@ out: DestroyWindow(window); }
+static void test_update_texture_pool(void) +{ + static const struct + { + D3DPOOL pool; + DWORD usage; + } + tests[] = + { + {D3DPOOL_DEFAULT, D3DUSAGE_DYNAMIC}, + {D3DPOOL_MANAGED, 0}, + {D3DPOOL_SYSTEMMEM, 0}, + {D3DPOOL_SCRATCH, 0}, + }; + + unsigned int expect_colour, colour, i, j; + IDirect3DVolumeTexture9 *src_3d, *dst_3d; + IDirect3DTexture9 *src_2d, *dst_2d; + D3DLOCKED_RECT locked_rect; + IDirect3DDevice9 *device; + D3DLOCKED_BOX locked_box; + IDirect3D9 *d3d9; + ULONG refcount; + D3DCAPS9 caps; + HWND window; + HRESULT hr; + + window = create_window(); + d3d9 = Direct3DCreate9(D3D_SDK_VERSION); + ok(!!d3d9, "Failed to create a D3D object.\n"); + if (!(device = create_device(d3d9, window, NULL))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + IDirect3D9_Release(d3d9); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice9_GetDeviceCaps(device, &caps); + ok(hr == S_OK, "Failed to get caps, hr %#lx.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + for (j = 0; j < ARRAY_SIZE(tests); ++j) + { + winetest_push_context("Source test %u, destination test %u", i, j); + + hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, + tests[i].usage, D3DFMT_A8R8G8B8, tests[i].pool, &src_2d, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, + tests[j].usage, D3DFMT_A8R8G8B8, tests[j].pool, &dst_2d, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DTexture9_LockRect(src_2d, 0, &locked_rect, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + *((DWORD *)locked_rect.pBits) = 0x11223344; + hr = IDirect3DTexture9_UnlockRect(src_2d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DTexture9_LockRect(dst_2d, 0, &locked_rect, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + *((DWORD *)locked_rect.pBits) = 0x44332211; + hr = IDirect3DTexture9_UnlockRect(dst_2d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)src_2d, + (IDirect3DBaseTexture9 *)dst_2d); + if (tests[i].pool == D3DPOOL_SYSTEMMEM && tests[j].pool == D3DPOOL_DEFAULT) + { + expect_colour = 0x11223344; + ok(hr == S_OK, "Got hr %#lx.\n", hr); + } + else + { + expect_colour = 0x44332211; + ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr); + } + + hr = IDirect3DTexture9_LockRect(dst_2d, 0, &locked_rect, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + colour = *((DWORD *)locked_rect.pBits); + ok(colour == expect_colour, "Expected colour %08x, got %08x.\n", expect_colour, colour); + hr = IDirect3DTexture9_UnlockRect(dst_2d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + IDirect3DTexture9_Release(src_2d); + IDirect3DTexture9_Release(dst_2d); + + if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)) + continue; + + hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 1, 1, 1, + tests[i].usage, D3DFMT_A8R8G8B8, tests[i].pool, &src_3d, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 1, 1, 1, + tests[j].usage, D3DFMT_A8R8G8B8, tests[j].pool, &dst_3d, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DVolumeTexture9_LockBox(src_3d, 0, &locked_box, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + *((DWORD *)locked_box.pBits) = 0x11223344; + hr = IDirect3DVolumeTexture9_UnlockBox(src_3d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DVolumeTexture9_LockBox(dst_3d, 0, &locked_box, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + *((DWORD *)locked_box.pBits) = 0x44332211; + hr = IDirect3DVolumeTexture9_UnlockBox(dst_3d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)src_3d, + (IDirect3DBaseTexture9 *)dst_3d); + if (tests[i].pool == D3DPOOL_SYSTEMMEM && tests[j].pool == D3DPOOL_DEFAULT) + { + expect_colour = 0x11223344; + ok(hr == S_OK, "Got hr %#lx.\n", hr); + } + else + { + expect_colour = 0x44332211; + ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr); + } + + hr = IDirect3DVolumeTexture9_LockBox(dst_3d, 0, &locked_box, NULL, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + colour = *((DWORD *)locked_box.pBits); + ok(colour == expect_colour, "Expected colour %08x, got %08x.\n", expect_colour, colour); + hr = IDirect3DVolumeTexture9_UnlockBox(dst_3d, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + IDirect3DVolumeTexture9_Release(src_3d); + IDirect3DVolumeTexture9_Release(dst_3d); + + winetest_pop_context(); + } + } + + refcount = IDirect3DDevice9_Release(device); + ok(!refcount, "Device has %lu references left.\n", refcount); + IDirect3D9_Release(d3d9); + DestroyWindow(window); +} + static void test_update_volumetexture(void) { D3DADAPTER_IDENTIFIER9 identifier; @@ -10196,44 +10340,17 @@ static void test_update_volumetexture(void) HRESULT hr; IDirect3DVolumeTexture9 *src, *dst; unsigned int i; - D3DLOCKED_BOX locked_box; ULONG refcount; D3DCAPS9 caps; BOOL is_warp; - static const struct - { - D3DPOOL src_pool, dst_pool; - HRESULT hr; - } - tests[] = - { - { D3DPOOL_DEFAULT, D3DPOOL_DEFAULT, D3DERR_INVALIDCALL }, - { D3DPOOL_MANAGED, D3DPOOL_DEFAULT, D3DERR_INVALIDCALL }, - { D3DPOOL_SYSTEMMEM, D3DPOOL_DEFAULT, D3D_OK }, - { D3DPOOL_SCRATCH, D3DPOOL_DEFAULT, D3DERR_INVALIDCALL }, - - { D3DPOOL_DEFAULT, D3DPOOL_MANAGED, D3DERR_INVALIDCALL }, - { D3DPOOL_MANAGED, D3DPOOL_MANAGED, D3DERR_INVALIDCALL }, - { D3DPOOL_SYSTEMMEM, D3DPOOL_MANAGED, D3DERR_INVALIDCALL }, - { D3DPOOL_SCRATCH, D3DPOOL_MANAGED, D3DERR_INVALIDCALL }, - - { D3DPOOL_DEFAULT, D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL }, - { D3DPOOL_MANAGED, D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL }, - { D3DPOOL_SYSTEMMEM, D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL }, - { D3DPOOL_SCRATCH, D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL }, - - { D3DPOOL_DEFAULT, D3DPOOL_SCRATCH, D3DERR_INVALIDCALL }, - { D3DPOOL_MANAGED, D3DPOOL_SCRATCH, D3DERR_INVALIDCALL }, - { D3DPOOL_SYSTEMMEM, D3DPOOL_SCRATCH, D3DERR_INVALIDCALL }, - { D3DPOOL_SCRATCH, D3DPOOL_SCRATCH, D3DERR_INVALIDCALL }, - }; + static const struct { UINT src_size, dst_size; UINT src_lvl, dst_lvl; D3DFORMAT src_fmt, dst_fmt; } - tests2[] = + tests[] = { { 8, 8, 0, 0, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, { 8, 8, 4, 4, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8 }, @@ -10261,62 +10378,21 @@ static void test_update_volumetexture(void)
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps); ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr); - if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)) - { - skip("Volume textures not supported, skipping test.\n"); - goto out; - } - - for (i = 0; i < ARRAY_SIZE(tests); i++) - { - DWORD src_usage = tests[i].src_pool == D3DPOOL_DEFAULT ? D3DUSAGE_DYNAMIC : 0; - DWORD dst_usage = tests[i].dst_pool == D3DPOOL_DEFAULT ? D3DUSAGE_DYNAMIC : 0; - - hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 1, 1, 1, src_usage, - D3DFMT_A8R8G8B8, tests[i].src_pool, &src, NULL); - ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr); - hr = IDirect3DDevice9_CreateVolumeTexture(device, 1, 1, 1, 1, dst_usage, - D3DFMT_A8R8G8B8, tests[i].dst_pool, &dst, NULL); - ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx.\n", hr); - - hr = IDirect3DVolumeTexture9_LockBox(src, 0, &locked_box, NULL, 0); - ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr); - *((DWORD *)locked_box.pBits) = 0x11223344; - hr = IDirect3DVolumeTexture9_UnlockBox(src, 0); - ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr); - - hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)src, (IDirect3DBaseTexture9 *)dst); - ok(hr == tests[i].hr, "UpdateTexture returned %#lx, expected %#lx, src pool %x, dst pool %u.\n", - hr, tests[i].hr, tests[i].src_pool, tests[i].dst_pool); - - if (SUCCEEDED(hr)) - { - unsigned int content = *((unsigned int *)locked_box.pBits); - hr = IDirect3DVolumeTexture9_LockBox(dst, 0, &locked_box, NULL, 0); - ok(SUCCEEDED(hr), "Failed to lock volume texture, hr %#lx.\n", hr); - ok(content == 0x11223344, "Dest texture contained %#x, expected 0x11223344.\n", content); - hr = IDirect3DVolumeTexture9_UnlockBox(dst, 0); - ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#lx.\n", hr); - } - IDirect3DVolumeTexture9_Release(src); - IDirect3DVolumeTexture9_Release(dst); - } - - if (!(caps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP)) + if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)|| !(caps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP)) { skip("Mipmapped volume maps not supported.\n"); goto out; }
- for (i = 0; i < ARRAY_SIZE(tests2); i++) + for (i = 0; i < ARRAY_SIZE(tests); i++) { hr = IDirect3DDevice9_CreateVolumeTexture(device, - tests2[i].src_size, tests2[i].src_size, tests2[i].src_size, - tests2[i].src_lvl, 0, tests2[i].src_fmt, D3DPOOL_SYSTEMMEM, &src, NULL); + tests[i].src_size, tests[i].src_size, tests[i].src_size, + tests[i].src_lvl, 0, tests[i].src_fmt, D3DPOOL_SYSTEMMEM, &src, NULL); ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx, case %u.\n", hr, i); hr = IDirect3DDevice9_CreateVolumeTexture(device, - tests2[i].dst_size, tests2[i].dst_size, tests2[i].dst_size, - tests2[i].dst_lvl, 0, tests2[i].dst_fmt, D3DPOOL_DEFAULT, &dst, NULL); + tests[i].dst_size, tests[i].dst_size, tests[i].dst_size, + tests[i].dst_lvl, 0, tests[i].dst_fmt, D3DPOOL_DEFAULT, &dst, NULL); ok(SUCCEEDED(hr), "Failed to create volume texture, hr %#lx, case %u.\n", hr, i);
hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)src, (IDirect3DBaseTexture9 *)dst); @@ -14813,6 +14889,7 @@ START_TEST(device) test_npot_textures(); test_vidmem_accounting(); test_volume_locking(); + test_update_texture_pool(); test_update_volumetexture(); test_create_rt_ds_fail(); test_volume_blocks();
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d8/tests/visual.c | 53 +++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index f77152e1e52..cb2f944b14a 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -101,7 +101,7 @@ struct surface_readback D3DLOCKED_RECT locked_rect; };
-static void get_rt_readback(IDirect3DSurface8 *surface, struct surface_readback *rb) +static void get_surface_readback(IDirect3DSurface8 *surface, struct surface_readback *rb) { IDirect3DTexture8 *tex = NULL; IDirect3DDevice8 *device; @@ -113,15 +113,24 @@ static void get_rt_readback(IDirect3DSurface8 *surface, struct surface_readback ok(SUCCEEDED(hr), "Failed to get device, hr %#lx.\n", hr); hr = IDirect3DSurface8_GetDesc(surface, &desc); ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr); - hr = IDirect3DDevice8_CreateTexture(device, desc.Width, desc.Height, 1, 0, desc.Format, D3DPOOL_SYSTEMMEM, &tex); - ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DTexture8_GetSurfaceLevel(tex, 0, &rb->surface); - ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice8_CopyRects(device, surface, NULL, 0, rb->surface, NULL); - ok(hr == S_OK, "Got hr %#lx.\n", hr); + + if (desc.Pool == D3DPOOL_DEFAULT || (desc.Usage & D3DUSAGE_WRITEONLY)) + { + hr = IDirect3DDevice8_CreateTexture(device, desc.Width, desc.Height, 1, 0, desc.Format, D3DPOOL_SYSTEMMEM, &tex); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DTexture8_GetSurfaceLevel(tex, 0, &rb->surface); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_CopyRects(device, surface, NULL, 0, rb->surface, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + IDirect3DTexture8_Release(tex); + } + else + { + IDirect3DSurface8_AddRef(surface); + rb->surface = surface; + } hr = IDirect3DSurface8_LockRect(rb->surface, &rb->locked_rect, NULL, D3DLOCK_READONLY); ok(hr == S_OK, "Got hr %#lx.\n", hr); - IDirect3DTexture8_Release(tex); IDirect3DDevice8_Release(device); }
@@ -149,7 +158,7 @@ static DWORD getPixelColor(IDirect3DDevice8 *device, UINT x, UINT y) hr = IDirect3DDevice8_GetRenderTarget(device, &rt); ok(hr == S_OK, "Got hr %#lx.\n", hr);
- get_rt_readback(rt, &rb); + get_surface_readback(rt, &rb); /* Remove the X channel for now. DirectX and OpenGL have different ideas how to treat it apparently, and it isn't * really important for these tests */ @@ -242,7 +251,7 @@ static void check_rt_color_(unsigned int line, IDirect3DSurface8 *rt, D3DCOLOR e hr = IDirect3DSurface8_GetDesc(rt, &desc); ok_(__FILE__, line)(hr == S_OK, "Failed to get surface desc, hr %#lx.\n", hr);
- get_rt_readback(rt, &rb); + get_surface_readback(rt, &rb); for (y = 0; y < desc.Height; ++y) { for (x = 0; x < desc.Width; ++x) @@ -3868,7 +3877,7 @@ static void intz_test(void) hr = IDirect3DDevice8_EndScene(device); ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
- get_rt_readback(original_rt, &rb); + get_surface_readback(original_rt, &rb); for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { unsigned int color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y); @@ -3926,7 +3935,7 @@ static void intz_test(void) hr = IDirect3DDevice8_EndScene(device); ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
- get_rt_readback(original_rt, &rb); + get_surface_readback(original_rt, &rb); for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { unsigned int color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y); @@ -3994,7 +4003,7 @@ static void intz_test(void) hr = IDirect3DDevice8_EndScene(device); ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
- get_rt_readback(original_rt, &rb); + get_surface_readback(original_rt, &rb); for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { unsigned int color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y); @@ -4210,7 +4219,7 @@ static void shadow_test(void) ok(SUCCEEDED(hr), "SetTexture failed, hr %#lx.\n", hr); IDirect3DTexture8_Release(texture);
- get_rt_readback(original_rt, &rb); + get_surface_readback(original_rt, &rb); for (j = 0; j < ARRAY_SIZE(expected_colors); ++j) { unsigned int color = get_readback_color(&rb, expected_colors[j].x, expected_colors[j].y); @@ -5175,7 +5184,7 @@ static void volume_dxtn_test(void) hr = IDirect3DDevice8_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
- get_rt_readback(rt, &rb); + get_surface_readback(rt, &rb); for (j = 0; j < ARRAY_SIZE(dxt1_expected_colours); ++j) { colour = get_readback_color(&rb, 40 + 80 * j, 240); @@ -7591,7 +7600,7 @@ static void test_pointsize(void) { struct surface_readback rb;
- get_rt_readback(rt, &rb); + get_surface_readback(rt, &rb); color = get_readback_color(&rb, 64 - size / 2 + 1, 64 - size / 2 + 1); ok(color_match(color, 0x00ff0000, 0), "Got unexpected color 0x%08x (case %u, %u, size %u).\n", color, i, j, size); @@ -8686,7 +8695,7 @@ static void test_uninitialized_varyings(void) hr = IDirect3DDevice8_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
- get_rt_readback(backbuffer, &rb); + get_surface_readback(backbuffer, &rb); color = get_readback_color(&rb, 320, 240); ok(color_match(color, tests[i].expected, 1) || (tests[i].allow_zero_alpha && color_match(color, tests[i].expected & 0x00ffffff, 1)) @@ -8973,7 +8982,7 @@ static void test_multisample_init(void) hr = IDirect3DDevice8_CopyRects(device, multi, NULL, 0, back, NULL); ok(SUCCEEDED(hr), "CopyRects failed, hr %#lx.\n", hr);
- get_rt_readback(back, &rb); + get_surface_readback(back, &rb); for (y = 0; y < 480; ++y) { for (x = 0; x < 640; ++x) @@ -9543,7 +9552,7 @@ static void test_texture_blending(void) hr = IDirect3DDevice8_EndScene(device); ok(SUCCEEDED(hr), "Test %u: EndScene failed, hr %#lx.\n", i, hr);
- get_rt_readback(backbuffer, &rb); + get_surface_readback(backbuffer, &rb); color = get_readback_color(&rb, 320, 240); ok(color_match(color, current_test->expected_color, 1), "Test %u: Got color 0x%08x, expected 0x%08x.\n", i, color, current_test->expected_color); @@ -10528,7 +10537,7 @@ static void test_viewport(void) hr = IDirect3DDevice8_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx (i %u, j %u).\n", hr, i, j);
- get_rt_readback(rt, &rb); + get_surface_readback(rt, &rb); check_rect(&rb, tests[j].expected_rect, tests[j].message); release_surface_readback(&rb); } @@ -11227,7 +11236,7 @@ static void test_sample_mask(void)
hr = IDirect3DDevice8_CopyRects(device, ms_rt, NULL, 0, rt, NULL); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); - get_rt_readback(rt, &rb); + get_surface_readback(rt, &rb); colour = get_readback_color(&rb, 64, 64); /* Multiple generations of Nvidia cards return broken results. * A mask with no bits or all bits set produce the expected results (0x00 / 0xff), @@ -11781,7 +11790,7 @@ static void test_filling_convention(void) hr = IDirect3DDevice8_EndScene(device); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- get_rt_readback(cur, &rb); + get_surface_readback(cur, &rb); for (y = 0; y < 8; y++) { for (x = 0; x < 8; x++)
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d8/tests/visual.c | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index cb2f944b14a..068a29f3847 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -5428,6 +5428,7 @@ static void add_dirty_rect_test(void) *tex_managed, *tex_dynamic; IDirect3DSurface8 *surface_dst2, *surface_src_green, *surface_src_red, *surface_managed0, *surface_managed1, *surface_dynamic; + struct surface_readback rb; D3DLOCKED_RECT locked_rect; IDirect3DDevice8 *device; unsigned int color, i; @@ -5704,6 +5705,29 @@ static void add_dirty_rect_test(void) hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
+ fill_surface(surface_src_green, 0x000000ff, D3DLOCK_NO_DIRTY_UPDATE); + + /* So does drawing directly from the sysmem texture. */ + hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)tex_src_green); + ok(hr == S_OK, "Failed to set texture, hr %#lx.\n", hr); + add_dirty_rect_test_draw(device); + color = getPixelColor(device, 320, 240); + ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color); + + /* Blitting to the sysmem texture adds a dirty rect. */ + fill_surface(surface_src_red, 0x00000000, D3DLOCK_NO_DIRTY_UPDATE); + fill_surface(surface_src_green, 0x00ff00ff, D3DLOCK_NO_DIRTY_UPDATE); + hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)tex_dst1); + ok(hr == S_OK, "Failed to set texture, hr %#lx.\n", hr); + hr = IDirect3DDevice8_CopyRects(device, surface_src_green, NULL, 0, surface_src_red, NULL); + ok(hr == S_OK, "Failed to update surface, hr %#lx.\n", hr); + hr = IDirect3DDevice8_UpdateTexture(device, (IDirect3DBaseTexture8 *)tex_src_red, + (IDirect3DBaseTexture8 *)tex_dst1); + ok(hr == S_OK, "Failed to update texture, hr %#lx.\n", hr); + add_dirty_rect_test_draw(device); + color = getPixelColor(device, 320, 240); + todo_wine ok(color_match(color, 0x00ff00ff, 1), "Got unexpected color 0x%08x.\n", color); + /* Tests with managed textures. */ fill_surface(surface_managed0, 0x00ff0000, 0); fill_surface(surface_managed1, 0x00ff0000, 0); @@ -5801,6 +5825,24 @@ static void add_dirty_rect_test(void) hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); ok(hr == D3D_OK, "Failed to present, hr %#lx.\n", hr);
+ /* Test blitting to a managed texture. */ + fill_surface(surface_managed0, 0x000000ff, 0); + /* Draw so that both the CPU and GPU copies are blue. */ + hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)tex_managed); + ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr); + add_dirty_rect_test_draw(device); + color = getPixelColor(device, 320, 240); + ok(color_match(color, 0x000000ff, 0), "Got unexpected colour 0x%08x.\n", color); + hr = IDirect3DDevice8_CopyRects(device, surface_dst2, NULL, 0, surface_managed0, NULL); + ok(hr == D3D_OK, "Failed to update surface, hr %#lx.\n", hr); + add_dirty_rect_test_draw(device); + color = getPixelColor(device, 320, 240); + ok(color_match(color, 0x0000ff00, 0), "Got unexpected colour 0x%08x.\n", color); + get_surface_readback(surface_managed0, &rb); + color = get_readback_color(&rb, 320, 240) & 0x00ffffff; + ok(color_match(color, 0x0000ff00, 0), "Got unexpected colour 0x%08x.\n", color); + release_surface_readback(&rb); + /* Tests with dynamic textures */ fill_surface(surface_dynamic, 0x0000ffff, 0); hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)tex_dynamic);
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 665702f3206..8be60d5e2fb 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -19624,6 +19624,15 @@ static void add_dirty_rect_test(void) hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr);
+ fill_surface(surface_src_green, 0x000000ff, D3DLOCK_NO_DIRTY_UPDATE); + + /* So does drawing directly from the sysmem texture. */ + hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_src_green); + ok(hr == S_OK, "Failed to set texture, hr %#lx.\n", hr); + add_dirty_rect_test_draw(device); + color = getPixelColor(device, 320, 240); + ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color); + /* Tests with managed textures. */ fill_surface(surface_managed0, 0x00ff0000, 0); fill_surface(surface_managed1, 0x00ff0000, 0);
This merge request was approved by Jan Sikorski.