From: Connor McAdams <cmcadams@codeweavers.com> Signed-off-by: Connor McAdams <cmcadams@codeweavers.com> --- dlls/d3dx10_43/tests/d3dx10.c | 59 ++++++++++++++++++++++++++++++++++- dlls/d3dx11_43/tests/d3dx11.c | 59 ++++++++++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index ae5ed384ba6..d72ff411e04 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -5432,6 +5432,20 @@ static void test_create_texture(void) static void test_image_filters(void) { + static const uint8_t a8r8g8b8_4_4_srgb_in_expected[] = + { + 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x10,0x03,0x03,0x03,0x20,0x06,0x06,0x06,0x30, + 0x0c,0x0c,0x0c,0x40,0x14,0x14,0x14,0x50,0x1e,0x1e,0x1e,0x60,0x2a,0x2a,0x2a,0x70, + 0x38,0x38,0x38,0x80,0x49,0x49,0x49,0x90,0x5b,0x5b,0x5b,0xa0,0x71,0x71,0x71,0xb0, + 0x89,0x89,0x89,0xc0,0xa3,0xa3,0xa3,0xd0,0xc0,0xc0,0xc0,0xe0,0xdf,0xdf,0xdf,0xf0, + }; + static const uint8_t a8r8g8b8_4_4_srgb_out_expected[] = + { + 0x00,0x00,0x00,0x00,0x48,0x48,0x48,0x10,0x63,0x63,0x63,0x20,0x77,0x77,0x77,0x30, + 0x88,0x88,0x88,0x40,0x97,0x97,0x97,0x50,0xa4,0xa4,0xa4,0x60,0xaf,0xaf,0xaf,0x70, + 0xba,0xba,0xba,0x80,0xc5,0xc5,0xc5,0x90,0xce,0xce,0xce,0xa0,0xd7,0xd7,0xd7,0xb0, + 0xe0,0xe0,0xe0,0xc0,0xe8,0xe8,0xe8,0xd0,0xf0,0xf0,0xf0,0xe0,0xf8,0xf8,0xf8,0xf0, + }; static const struct { DWORD filter; @@ -5566,6 +5580,7 @@ static void test_image_filters(void) const uint8_t *expected_dst; struct resource_readback rb; ID3D10Resource *resource; + unsigned int dds_size; ID3D10Device *device; uint32_t src_pitch; unsigned int i, j; @@ -5584,10 +5599,10 @@ static void test_image_filters(void) for (i = 0; i < ARRAY_SIZE(tests); ++i) { const unsigned int fmt_bpp = (get_bpp_from_format(tests[i].format) + 7) / 8; - unsigned int dds_size = sizeof(dds); winetest_push_context("Test %u", i); + dds_size = sizeof(dds); load_info = d3dx10_default_load_info; load_info.Width = tests[i].dst_width; load_info.Height = tests[i].dst_height; @@ -5634,6 +5649,48 @@ static void test_image_filters(void) winetest_pop_context(); } + /* + * Create a 5x4 DXT10 DDS file to test SRGB filter flags. If we did a 4x4 + * image with our 4x4 output texture the filter flags would be ignored. + */ + dds.magic = MAKEFOURCC('D','D','S',' '); + set_dxt10_dds_header(&dds.header, 0, 5, 4, 0, 1, 4 * 5, 0, 0); + set_dds_header_dxt10(&dds.dxt10, DXGI_FORMAT_R8G8B8A8_UNORM, D3D10_RESOURCE_DIMENSION_TEXTURE2D, 0, 1, 0); + memset(dds.data, 0, sizeof(dds.data)); + for (i = 0; i < 4; i++) + { + BYTE *dst = &dds.data[i * dds.header.pitch_or_linear_size]; + + memcpy(dst, &a8r8g8b8_4_4[i * 4 * 4], 4 * 4); + } + dds_size = (sizeof(dds) - sizeof(dds.data)) + dds.header.pitch_or_linear_size * dds.header.height; + + /* Test conversion from SRGB to non-SRGB. */ + load_info = d3dx10_default_load_info; + load_info.Filter = D3DX10_FILTER_NONE | D3DX10_FILTER_SRGB_IN; + load_info.Width = load_info.Height = 4; + load_info.MipLevels = 1; + hr = D3DX10CreateTextureFromMemory(device, &dds, dds_size, &load_info, NULL, &resource, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + get_resource_readback(resource, 0, &rb); + todo_wine check_test_readback(&rb, a8r8g8b8_4_4_srgb_in_expected, 4, 4, 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0); + release_resource_readback(&rb); + ID3D10Resource_Release(resource); + + /* Test conversion from non-SRGB to SRGB. */ + load_info = d3dx10_default_load_info; + load_info.Filter = D3DX10_FILTER_NONE | D3DX10_FILTER_SRGB_OUT; + load_info.Width = load_info.Height = 4; + load_info.MipLevels = 1; + hr = D3DX10CreateTextureFromMemory(device, &dds, dds_size, &load_info, NULL, &resource, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + get_resource_readback(resource, 0, &rb); + todo_wine check_test_readback(&rb, a8r8g8b8_4_4_srgb_out_expected, 4, 4, 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0); + release_resource_readback(&rb); + ID3D10Resource_Release(resource); + CoUninitialize(); ok(!ID3D10Device_Release(device), "Unexpected refcount.\n"); } diff --git a/dlls/d3dx11_43/tests/d3dx11.c b/dlls/d3dx11_43/tests/d3dx11.c index adf3ca79511..d94dedfef04 100644 --- a/dlls/d3dx11_43/tests/d3dx11.c +++ b/dlls/d3dx11_43/tests/d3dx11.c @@ -4250,6 +4250,20 @@ static void test_create_texture(void) static void test_image_filters(void) { + static const uint8_t a8r8g8b8_4_4_srgb_in_expected[] = + { + 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x10,0x03,0x03,0x03,0x20,0x06,0x06,0x06,0x30, + 0x0c,0x0c,0x0c,0x40,0x14,0x14,0x14,0x50,0x1e,0x1e,0x1e,0x60,0x2a,0x2a,0x2a,0x70, + 0x38,0x38,0x38,0x80,0x49,0x49,0x49,0x90,0x5b,0x5b,0x5b,0xa0,0x71,0x71,0x71,0xb0, + 0x89,0x89,0x89,0xc0,0xa3,0xa3,0xa3,0xd0,0xc0,0xc0,0xc0,0xe0,0xdf,0xdf,0xdf,0xf0, + }; + static const uint8_t a8r8g8b8_4_4_srgb_out_expected[] = + { + 0x00,0x00,0x00,0x00,0x48,0x48,0x48,0x10,0x63,0x63,0x63,0x20,0x77,0x77,0x77,0x30, + 0x88,0x88,0x88,0x40,0x97,0x97,0x97,0x50,0xa4,0xa4,0xa4,0x60,0xaf,0xaf,0xaf,0x70, + 0xba,0xba,0xba,0x80,0xc5,0xc5,0xc5,0x90,0xce,0xce,0xce,0xa0,0xd7,0xd7,0xd7,0xb0, + 0xe0,0xe0,0xe0,0xc0,0xe8,0xe8,0xe8,0xd0,0xf0,0xf0,0xf0,0xe0,0xf8,0xf8,0xf8,0xf0, + }; static const struct { DWORD filter; @@ -4384,6 +4398,7 @@ static void test_image_filters(void) const uint8_t *expected_dst; struct resource_readback rb; ID3D11Resource *resource; + unsigned int dds_size; ID3D11Device *device; uint32_t src_pitch; unsigned int i, j; @@ -4402,10 +4417,10 @@ static void test_image_filters(void) for (i = 0; i < ARRAY_SIZE(tests); ++i) { const unsigned int fmt_bpp = (get_bpp_from_format(tests[i].format) + 7) / 8; - unsigned int dds_size = sizeof(dds); winetest_push_context("Test %u", i); + dds_size = sizeof(dds); load_info = d3dx11_default_load_info; load_info.Width = tests[i].dst_width; load_info.Height = tests[i].dst_height; @@ -4452,6 +4467,48 @@ static void test_image_filters(void) winetest_pop_context(); } + /* + * Create a 5x4 DXT10 DDS file to test SRGB filter flags. If we did a 4x4 + * image with our 4x4 output texture the filter flags would be ignored. + */ + dds.magic = MAKEFOURCC('D','D','S',' '); + set_dxt10_dds_header(&dds.header, 0, 5, 4, 0, 1, 4 * 5, 0, 0); + set_dds_header_dxt10(&dds.dxt10, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, 0, 1, 0); + memset(dds.data, 0, sizeof(dds.data)); + for (i = 0; i < 4; i++) + { + BYTE *dst = &dds.data[i * dds.header.pitch_or_linear_size]; + + memcpy(dst, &a8r8g8b8_4_4[i * 4 * 4], 4 * 4); + } + dds_size = (sizeof(dds) - sizeof(dds.data)) + dds.header.pitch_or_linear_size * dds.header.height; + + /* Test conversion from SRGB to non-SRGB. */ + load_info = d3dx11_default_load_info; + load_info.Filter = D3DX11_FILTER_NONE | D3DX11_FILTER_SRGB_IN; + load_info.Width = load_info.Height = 4; + load_info.MipLevels = 1; + hr = D3DX11CreateTextureFromMemory(device, &dds, dds_size, &load_info, NULL, &resource, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + get_resource_readback(resource, 0, &rb); + todo_wine check_test_readback(&rb, a8r8g8b8_4_4_srgb_in_expected, 4, 4, 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0); + release_resource_readback(&rb); + ID3D11Resource_Release(resource); + + /* Test conversion from non-SRGB to SRGB. */ + load_info = d3dx11_default_load_info; + load_info.Filter = D3DX11_FILTER_NONE | D3DX11_FILTER_SRGB_OUT; + load_info.Width = load_info.Height = 4; + load_info.MipLevels = 1; + hr = D3DX11CreateTextureFromMemory(device, &dds, dds_size, &load_info, NULL, &resource, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + get_resource_readback(resource, 0, &rb); + todo_wine check_test_readback(&rb, a8r8g8b8_4_4_srgb_out_expected, 4, 4, 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0); + release_resource_readback(&rb); + ID3D11Resource_Release(resource); + CoUninitialize(); ok(!ID3D11Device_Release(device), "Unexpected refcount.\n"); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10513