Add support for D3DFMT_CxV8U8, which is required for the game Biorage.
Also add support for loading DDS files with header flag values of `DDS_PF_FOURCC` alongside other flag values.
-- v3: d3dx11/tests: Add more DDS pixel format tests. d3dx10/tests: Add more DDS pixel format tests. d3dx9: Ignore all other DDS pixel format flags if DDS_PF_FOURCC is set. d3dx9/tests: Add a test for DDS_PF_FOURCC flag handling. d3dx9/tests: Add tests for ATI{1,2} DDS files. d3dx9: Replace D3DFMT_CxV8U8 with D3DFMT_X8L8V8U8 when creating textures. d3dx9: Add support for D3DFMT_CxV8U8. d3dx9/tests: Add tests for D3DFMT_CxV8U8.
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/surface.c | 67 +++++++++++++++++++++++++++++++++++ dlls/d3dx9_36/tests/texture.c | 12 +++++++ 2 files changed, 79 insertions(+)
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 84fcda0fa0a..9b88e635c12 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -1001,6 +1001,7 @@ static void test_D3DXGetImageInfo(void) check_dds_pixel_format(DDS_PF_FOURCC, D3DFMT_R32F, 0, 0, 0, 0, 0, D3DFMT_R32F); check_dds_pixel_format(DDS_PF_FOURCC, D3DFMT_G32R32F, 0, 0, 0, 0, 0, D3DFMT_G32R32F); check_dds_pixel_format(DDS_PF_FOURCC, D3DFMT_A32B32G32R32F, 0, 0, 0, 0, 0, D3DFMT_A32B32G32R32F); + todo_wine check_dds_pixel_format(DDS_PF_FOURCC, D3DFMT_CxV8U8, 0, 0, 0, 0, 0, D3DFMT_CxV8U8); check_dds_pixel_format(DDS_PF_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0, D3DFMT_R5G6B5); check_dds_pixel_format(DDS_PF_RGB | DDS_PF_ALPHA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000, D3DFMT_A1R5G5B5); check_dds_pixel_format(DDS_PF_RGB | DDS_PF_ALPHA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000, D3DFMT_A4R4G4B4); @@ -2518,6 +2519,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) static const uint32_t pixdata_q8w8v8u8[] = { 0x30201000, 0x7f605040, 0xb0a08180, 0xffe0d0c0 }; static const float pixdata_a32b32g32r32f[] = { 0.0f, 0.1f, NAN, INFINITY, 1.0f, 1.1f, 1.2f, 1.3f, -0.1f, -0.2f, -NAN, -INFINITY, -1.0f, -1.1f, -1.2f, -1.3f }; + static const uint16_t pixdata_cxv8u8[] = { 0x7f7f, 0x8181, 0x0000, 0x006d }; static const uint16_t pixdata_v8u8[] = { 0x3000, 0x7f40, 0x8180, 0xffc0 }; BYTE buffer[4 * 8 * 4]; D3DXIMAGE_INFO info; @@ -2953,6 +2955,22 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) hr = IDirect3DSurface9_UnlockRect(surf); ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr);
+ /* D3DFMT_CxV8U8. */ + hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_cxv8u8, D3DFMT_CxV8U8, 4, NULL, &rect, + D3DX_FILTER_NONE, 0); + todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_4bpp(&lockrect, 0, 0, 0xffffff80); + check_pixel_4bpp(&lockrect, 1, 0, 0xff000080); + check_pixel_4bpp(&lockrect, 0, 1, 0xff8080ff); + check_pixel_4bpp(&lockrect, 1, 1, 0xffed80c1); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + } + hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a32b32g32r32f, D3DFMT_A32B32G32R32F, 32, NULL, &rect, D3DX_FILTER_NONE, 0); ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); @@ -3557,6 +3575,23 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) hr = IDirect3DSurface9_UnlockRect(surf); ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr);
+ /* D3DFMT_CxV8U8. */ + hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_cxv8u8, D3DFMT_CxV8U8, 4, NULL, &rect, + D3DX_FILTER_NONE, 0); + todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + /* The calculated Cx value goes into the blue channel. */ + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_float4(&lockrect, 0, 0, 1.0f, 1.0f, 0.0f, 1.0f, 0, FALSE); + check_pixel_float4(&lockrect, 1, 0, -1.0f, -1.0f, 0.0f, 1.0f, 0, FALSE); + check_pixel_float4(&lockrect, 0, 1, 0.0f, 0.0f, 1.0f, 1.0f, 0, FALSE); + check_pixel_float4(&lockrect, 1, 1, 8.58267725e-001, 0.0f, 5.13202250e-001, 1.0f, 0, FALSE); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + } + check_release((IUnknown*)surf, 0); }
@@ -3672,6 +3707,21 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) hr = IDirect3DSurface9_UnlockRect(surf); ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr);
+ /* D3DFMT_CxV8U8. */ + hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_cxv8u8, D3DFMT_CxV8U8, 4, NULL, &rect, + D3DX_FILTER_NONE, 0); + todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_4bpp(&lockrect, 0, 0, 0x00ff7f7f); + check_pixel_4bpp(&lockrect, 1, 0, 0x00ff8282); + check_pixel_4bpp(&lockrect, 0, 1, 0x00ff0000); + check_pixel_4bpp(&lockrect, 1, 1, 0x00ff006d); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + } check_release((IUnknown*)surf, 1); check_release((IUnknown*)tex, 0); } @@ -4101,6 +4151,12 @@ static void test_save_surface_to_dds(IDirect3DDevice9 *device) DDS_FILE_HEADER_SIZE + (4 * 2 * 4) } }, + { D3DFMT_CxV8U8, 4, 4, NULL, + { D3D_OK, { 32, DDS_PF_FOURCC, D3DFMT_CxV8U8, 0, 0, 0, 0, 0 }, + DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT, 4, 4, 0, 0, 0, DDSCAPS_TEXTURE, 0, + DDS_FILE_HEADER_SIZE + (4 * 2 * 4) + }, .todo_hr = TRUE + }, }; struct { @@ -4771,6 +4827,17 @@ static void test_save_surface_iffs(IDirect3DDevice9 *device) { D3D_OK, D3DFMT_A32B32G32R32F, .todo_hr = TRUE }, }, }, + { D3DFMT_CxV8U8, NULL, 0x00, + { { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + }, + }, }; IDirect3DSurface9 *surface; ID3DXBuffer *buffer; diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index 219c5bcb1d4..0964d38037f 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -628,6 +628,18 @@ static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device) ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format); }
+ /* D3DFMT CxV8U8, unsupported by modern cards, replaced with D3DFMT_X8L8V8U8. */ + if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType, + mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_X8L8V8U8))) + expected = D3DFMT_X8L8V8U8; + else + expected = D3DFMT_V8U8; + + format = D3DFMT_CxV8U8; + hr = D3DXCheckTextureRequirements(device, NULL, NULL, NULL, 0, &format, D3DPOOL_DEFAULT); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(format == expected, "Unexpected format %u.\n", format); + IDirect3D9_Release(d3d); }
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx10_43/texture.c | 1 + dlls/d3dx11_43/texture.c | 1 + dlls/d3dx9_36/d3dx_helpers.c | 21 ++++++++- dlls/d3dx9_36/d3dx_helpers.h | 10 ++++- dlls/d3dx9_36/tests/surface.c | 82 ++++++++++++++++------------------- dlls/d3dx9_36/util.c | 2 + 6 files changed, 70 insertions(+), 47 deletions(-)
diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index ab488dcfa2f..9d0d6063a0b 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -90,6 +90,7 @@ static DXGI_FORMAT dxgi_format_from_legacy_dds_d3dx_pixel_format_id(enum d3dx_pi /* These formats are known and explicitly unsupported on d3dx10+. */ case D3DX_PIXEL_FORMAT_U8V8W8Q8_SNORM: case D3DX_PIXEL_FORMAT_U8V8_SNORM: + case D3DX_PIXEL_FORMAT_U8V8_SNORM_Cx: case D3DX_PIXEL_FORMAT_U16V16_SNORM: case D3DX_PIXEL_FORMAT_U8V8_SNORM_L8X8_UNORM: case D3DX_PIXEL_FORMAT_U10V10W10_SNORM_A2_UNORM: diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c index cbf3b630f58..b7c9761ad18 100644 --- a/dlls/d3dx11_43/texture.c +++ b/dlls/d3dx11_43/texture.c @@ -85,6 +85,7 @@ static DXGI_FORMAT dxgi_format_from_legacy_dds_d3dx_pixel_format_id(enum d3dx_pi /* These formats are known and explicitly unsupported on d3dx10+. */ case D3DX_PIXEL_FORMAT_U8V8W8Q8_SNORM: case D3DX_PIXEL_FORMAT_U8V8_SNORM: + case D3DX_PIXEL_FORMAT_U8V8_SNORM_Cx: case D3DX_PIXEL_FORMAT_U16V16_SNORM: case D3DX_PIXEL_FORMAT_U8V8_SNORM_L8X8_UNORM: case D3DX_PIXEL_FORMAT_U10V10W10_SNORM_A2_UNORM: diff --git a/dlls/d3dx9_36/d3dx_helpers.c b/dlls/d3dx9_36/d3dx_helpers.c index 60394ca1d9b..952a7d7d9ea 100644 --- a/dlls/d3dx9_36/d3dx_helpers.c +++ b/dlls/d3dx9_36/d3dx_helpers.c @@ -113,6 +113,7 @@ static const struct pixel_format_desc formats[] = {D3DX_PIXEL_FORMAT_U8V8W8Q8_SNORM, { 8, 8, 8, 8}, {24, 0, 8, 16}, 4, 1, 1, 4, CTYPE_SNORM, CTYPE_SNORM, 0 }, {D3DX_PIXEL_FORMAT_U16V16W16Q16_SNORM, {16, 16, 16, 16}, {48, 0, 16, 32}, 8, 1, 1, 8, CTYPE_SNORM, CTYPE_SNORM, 0 }, {D3DX_PIXEL_FORMAT_U8V8_SNORM, { 0, 8, 8, 0}, { 0, 0, 8, 0}, 2, 1, 1, 2, CTYPE_EMPTY, CTYPE_SNORM, 0 }, + {D3DX_PIXEL_FORMAT_U8V8_SNORM_Cx, { 0, 8, 8, 0}, { 0, 0, 8, 0}, 2, 1, 1, 2, CTYPE_EMPTY, CTYPE_SHILO, 0 }, {D3DX_PIXEL_FORMAT_U16V16_SNORM, { 0, 16, 16, 0}, { 0, 0, 16, 0}, 4, 1, 1, 4, CTYPE_EMPTY, CTYPE_SNORM, 0 }, {D3DX_PIXEL_FORMAT_U8V8_SNORM_L8X8_UNORM, { 8, 8, 8, 0}, {16, 0, 8, 0}, 4, 1, 1, 4, CTYPE_UNORM, CTYPE_SNORM, 0 }, {D3DX_PIXEL_FORMAT_U10V10W10_SNORM_A2_UNORM, { 2, 10, 10, 10}, {30, 0, 10, 20}, 4, 1, 1, 4, CTYPE_UNORM, CTYPE_SNORM, 0 }, @@ -240,6 +241,7 @@ static const struct { { 32, DDS_PF_FOURCC, 0x72 }, D3DX_PIXEL_FORMAT_R32_FLOAT }, { { 32, DDS_PF_FOURCC, 0x73 }, D3DX_PIXEL_FORMAT_R32G32_FLOAT }, { { 32, DDS_PF_FOURCC, 0x74 }, D3DX_PIXEL_FORMAT_R32G32B32A32_FLOAT }, + { { 32, DDS_PF_FOURCC, 0x75 }, D3DX_PIXEL_FORMAT_U8V8_SNORM_Cx }, /* DDS_PF_RGB. */ { { 32, DDS_PF_RGB, 0, 8, 0xe0, 0x1c, 0x03, 0x00 }, D3DX_PIXEL_FORMAT_B2G3R3_UNORM }, { { 32, DDS_PF_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0x0000 }, D3DX_PIXEL_FORMAT_B5G6R5_UNORM }, @@ -781,7 +783,8 @@ static enum d3dx_pixel_format_id d3dx_get_closest_d3dx_pixel_format_id(const enu continue; if (rgb_only && curfmt->rgb_type == CTYPE_EMPTY) continue; - if (fmt->rgb_type == CTYPE_SNORM && curfmt->rgb_type != CTYPE_SNORM) + if ((fmt->rgb_type == CTYPE_SNORM && curfmt->rgb_type != CTYPE_SNORM) + || (fmt->rgb_type == CTYPE_SHILO && curfmt->rgb_type != CTYPE_SHILO)) continue;
cur_rgb_channels = !!curfmt->bits[1] + !!curfmt->bits[2] + !!curfmt->bits[3]; @@ -2069,6 +2072,7 @@ static enum range get_range_for_component_type(enum component_type type) switch (type) { case CTYPE_SNORM: + case CTYPE_SHILO: return RANGE_SNORM;
case CTYPE_LUMA: @@ -2127,6 +2131,7 @@ void format_to_d3dx_color(const struct pixel_format_desc *format, const BYTE *sr *dst_component = (float)tmp / mask; break;
+ case CTYPE_SHILO: case CTYPE_SNORM: { const uint32_t sign_bit = (1u << (format->bits[c] - 1)); @@ -2152,6 +2157,17 @@ void format_to_d3dx_color(const struct pixel_format_desc *format, const BYTE *sr assert(format->bits[1]); *dst_component = dst->value.x; } + else if (dst_ctype == CTYPE_SHILO) + { + float cx_val; + + assert(format->bits[1] && format->bits[2] && c == 3); + cx_val = 1.0f - dst->value.x * dst->value.x - dst->value.y * dst->value.y; + if (cx_val <= 0.0f || cx_val > 1.0f) + *dst_component = 0.0f; + else + *dst_component = sqrtf(cx_val); + } else { *dst_component = 1.0f; @@ -2222,8 +2238,9 @@ void format_from_d3dx_color(const struct pixel_format_desc *format, const struct break; }
- /* We shouldn't be trying to output to CTYPE_INDEX. */ + /* We shouldn't be trying to output to CTYPE_INDEX or CTYPE_SHILO. */ case CTYPE_INDEX: + case CTYPE_SHILO: assert(0); break;
diff --git a/dlls/d3dx9_36/d3dx_helpers.h b/dlls/d3dx9_36/d3dx_helpers.h index 8263d832bfa..a840f99b46e 100644 --- a/dlls/d3dx9_36/d3dx_helpers.h +++ b/dlls/d3dx9_36/d3dx_helpers.h @@ -220,6 +220,7 @@ enum d3dx_pixel_format_id D3DX_PIXEL_FORMAT_U8V8W8Q8_SNORM, D3DX_PIXEL_FORMAT_U16V16W16Q16_SNORM, D3DX_PIXEL_FORMAT_U8V8_SNORM, + D3DX_PIXEL_FORMAT_U8V8_SNORM_Cx, D3DX_PIXEL_FORMAT_U16V16_SNORM, D3DX_PIXEL_FORMAT_U8V8_SNORM_L8X8_UNORM, D3DX_PIXEL_FORMAT_U10V10W10_SNORM_A2_UNORM, @@ -248,6 +249,7 @@ enum component_type CTYPE_FLOAT, CTYPE_LUMA, CTYPE_INDEX, + CTYPE_SHILO, /* Signed HILO. */ };
enum format_flag @@ -351,6 +353,11 @@ static inline BOOL is_packed_format(const struct pixel_format_desc *format) return !!(format->flags & FMT_FLAG_PACKED); }
+static inline BOOL is_signed_hilo_format(const struct pixel_format_desc *format) +{ + return format->rgb_type == CTYPE_SHILO; +} + static inline BOOL format_types_match(const struct pixel_format_desc *src, const struct pixel_format_desc *dst) { if ((src->a_type && dst->a_type) && (src->a_type != dst->a_type)) @@ -382,7 +389,8 @@ static inline BOOL is_conversion_from_supported(const struct pixel_format_desc *
static inline BOOL is_conversion_to_supported(const struct pixel_format_desc *format) { - return !is_index_format(format) && !is_packed_format(format) && !is_unknown_format(format); + return !is_index_format(format) && !is_packed_format(format) && !is_signed_hilo_format(format) + && !is_unknown_format(format); }
const struct pixel_format_desc *get_d3dx_pixel_format_info(enum d3dx_pixel_format_id format); diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 9b88e635c12..a3fda2fa136 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -1001,7 +1001,7 @@ static void test_D3DXGetImageInfo(void) check_dds_pixel_format(DDS_PF_FOURCC, D3DFMT_R32F, 0, 0, 0, 0, 0, D3DFMT_R32F); check_dds_pixel_format(DDS_PF_FOURCC, D3DFMT_G32R32F, 0, 0, 0, 0, 0, D3DFMT_G32R32F); check_dds_pixel_format(DDS_PF_FOURCC, D3DFMT_A32B32G32R32F, 0, 0, 0, 0, 0, D3DFMT_A32B32G32R32F); - todo_wine check_dds_pixel_format(DDS_PF_FOURCC, D3DFMT_CxV8U8, 0, 0, 0, 0, 0, D3DFMT_CxV8U8); + check_dds_pixel_format(DDS_PF_FOURCC, D3DFMT_CxV8U8, 0, 0, 0, 0, 0, D3DFMT_CxV8U8); check_dds_pixel_format(DDS_PF_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0, D3DFMT_R5G6B5); check_dds_pixel_format(DDS_PF_RGB | DDS_PF_ALPHA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000, D3DFMT_A1R5G5B5); check_dds_pixel_format(DDS_PF_RGB | DDS_PF_ALPHA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000, D3DFMT_A4R4G4B4); @@ -2958,18 +2958,15 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) /* D3DFMT_CxV8U8. */ hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_cxv8u8, D3DFMT_CxV8U8, 4, NULL, &rect, D3DX_FILTER_NONE, 0); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { - hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); - ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); - check_pixel_4bpp(&lockrect, 0, 0, 0xffffff80); - check_pixel_4bpp(&lockrect, 1, 0, 0xff000080); - check_pixel_4bpp(&lockrect, 0, 1, 0xff8080ff); - check_pixel_4bpp(&lockrect, 1, 1, 0xffed80c1); - hr = IDirect3DSurface9_UnlockRect(surf); - ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); - } + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_4bpp(&lockrect, 0, 0, 0xffffff80); + check_pixel_4bpp(&lockrect, 1, 0, 0xff000080); + check_pixel_4bpp(&lockrect, 0, 1, 0xff8080ff); + check_pixel_4bpp(&lockrect, 1, 1, 0xffed80c1); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a32b32g32r32f, D3DFMT_A32B32G32R32F, 32, NULL, &rect, D3DX_FILTER_NONE, 0); @@ -3578,19 +3575,17 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) /* D3DFMT_CxV8U8. */ hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_cxv8u8, D3DFMT_CxV8U8, 4, NULL, &rect, D3DX_FILTER_NONE, 0); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { - /* The calculated Cx value goes into the blue channel. */ - hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); - ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); - check_pixel_float4(&lockrect, 0, 0, 1.0f, 1.0f, 0.0f, 1.0f, 0, FALSE); - check_pixel_float4(&lockrect, 1, 0, -1.0f, -1.0f, 0.0f, 1.0f, 0, FALSE); - check_pixel_float4(&lockrect, 0, 1, 0.0f, 0.0f, 1.0f, 1.0f, 0, FALSE); - check_pixel_float4(&lockrect, 1, 1, 8.58267725e-001, 0.0f, 5.13202250e-001, 1.0f, 0, FALSE); - hr = IDirect3DSurface9_UnlockRect(surf); - ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); - } + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + + /* The calculated Cx value goes into the blue channel. */ + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_float4(&lockrect, 0, 0, 1.0f, 1.0f, 0.0f, 1.0f, 0, FALSE); + check_pixel_float4(&lockrect, 1, 0, -1.0f, -1.0f, 0.0f, 1.0f, 0, FALSE); + check_pixel_float4(&lockrect, 0, 1, 0.0f, 0.0f, 1.0f, 1.0f, 0, FALSE); + check_pixel_float4(&lockrect, 1, 1, 8.58267725e-001, 0.0f, 5.13202250e-001, 1.0f, 0, FALSE); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr);
check_release((IUnknown*)surf, 0); } @@ -3710,18 +3705,17 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) /* D3DFMT_CxV8U8. */ hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_cxv8u8, D3DFMT_CxV8U8, 4, NULL, &rect, D3DX_FILTER_NONE, 0); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { - hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); - ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); - check_pixel_4bpp(&lockrect, 0, 0, 0x00ff7f7f); - check_pixel_4bpp(&lockrect, 1, 0, 0x00ff8282); - check_pixel_4bpp(&lockrect, 0, 1, 0x00ff0000); - check_pixel_4bpp(&lockrect, 1, 1, 0x00ff006d); - hr = IDirect3DSurface9_UnlockRect(surf); - ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); - } + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_4bpp(&lockrect, 0, 0, 0x00ff7f7f); + check_pixel_4bpp(&lockrect, 1, 0, 0x00ff8282); + check_pixel_4bpp(&lockrect, 0, 1, 0x00ff0000); + check_pixel_4bpp(&lockrect, 1, 1, 0x00ff006d); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + check_release((IUnknown*)surf, 1); check_release((IUnknown*)tex, 0); } @@ -4155,7 +4149,7 @@ static void test_save_surface_to_dds(IDirect3DDevice9 *device) { D3D_OK, { 32, DDS_PF_FOURCC, D3DFMT_CxV8U8, 0, 0, 0, 0, 0 }, DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT, 4, 4, 0, 0, 0, DDSCAPS_TEXTURE, 0, DDS_FILE_HEADER_SIZE + (4 * 2 * 4) - }, .todo_hr = TRUE + } }, }; struct @@ -4828,12 +4822,12 @@ static void test_save_surface_iffs(IDirect3DDevice9 *device) }, }, { D3DFMT_CxV8U8, NULL, 0x00, - { { D3DERR_INVALIDCALL, .todo_hr = TRUE }, - { D3DERR_INVALIDCALL, .todo_hr = TRUE }, - { D3DERR_INVALIDCALL, .todo_hr = TRUE }, - { D3DERR_INVALIDCALL, .todo_hr = TRUE }, - { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + { { D3DERR_INVALIDCALL }, + { D3DERR_INVALIDCALL }, + { D3DERR_INVALIDCALL }, + { D3DERR_INVALIDCALL }, { D3DERR_INVALIDCALL, .todo_hr = TRUE }, + { D3DERR_INVALIDCALL }, { D3DERR_INVALIDCALL, .todo_hr = TRUE }, { D3DERR_INVALIDCALL, .todo_hr = TRUE }, }, diff --git a/dlls/d3dx9_36/util.c b/dlls/d3dx9_36/util.c index dd2162d9f6e..7f1fc24e1cd 100644 --- a/dlls/d3dx9_36/util.c +++ b/dlls/d3dx9_36/util.c @@ -62,6 +62,7 @@ D3DFORMAT d3dformat_from_d3dx_pixel_format_id(enum d3dx_pixel_format_id format) case D3DX_PIXEL_FORMAT_P8_UINT_A8_UNORM: return D3DFMT_A8P8; case D3DX_PIXEL_FORMAT_U8V8W8Q8_SNORM: return D3DFMT_Q8W8V8U8; case D3DX_PIXEL_FORMAT_U8V8_SNORM: return D3DFMT_V8U8; + case D3DX_PIXEL_FORMAT_U8V8_SNORM_Cx: return D3DFMT_CxV8U8; case D3DX_PIXEL_FORMAT_U16V16_SNORM: return D3DFMT_V16U16; case D3DX_PIXEL_FORMAT_U8V8_SNORM_L8X8_UNORM: return D3DFMT_X8L8V8U8; case D3DX_PIXEL_FORMAT_U10V10W10_SNORM_A2_UNORM: return D3DFMT_A2W10V10U10; @@ -121,6 +122,7 @@ enum d3dx_pixel_format_id d3dx_pixel_format_id_from_d3dformat(D3DFORMAT format) case D3DFMT_A8P8: return D3DX_PIXEL_FORMAT_P8_UINT_A8_UNORM; case D3DFMT_Q8W8V8U8: return D3DX_PIXEL_FORMAT_U8V8W8Q8_SNORM; case D3DFMT_V8U8: return D3DX_PIXEL_FORMAT_U8V8_SNORM; + case D3DFMT_CxV8U8: return D3DX_PIXEL_FORMAT_U8V8_SNORM_Cx; case D3DFMT_V16U16: return D3DX_PIXEL_FORMAT_U16V16_SNORM; case D3DFMT_X8L8V8U8: return D3DX_PIXEL_FORMAT_U8V8_SNORM_L8X8_UNORM; case D3DFMT_A2W10V10U10: return D3DX_PIXEL_FORMAT_U10V10W10_SNORM_A2_UNORM;
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/texture.c | 2 +- dlls/d3dx9_36/texture.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index 0964d38037f..ed3ddd07e53 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -638,7 +638,7 @@ static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device) format = D3DFMT_CxV8U8; hr = D3DXCheckTextureRequirements(device, NULL, NULL, NULL, 0, &format, D3DPOOL_DEFAULT); ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(format == expected, "Unexpected format %u.\n", format); + ok(format == expected, "Unexpected format %u.\n", format);
IDirect3D9_Release(d3d); } diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 02bfbca2cc6..2896bd1f2b6 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -186,6 +186,7 @@ static D3DFORMAT get_replacement_format(D3DFORMAT format) {D3DFMT_DXT3, D3DFMT_A8R8G8B8}, {D3DFMT_DXT4, D3DFMT_A8R8G8B8}, {D3DFMT_DXT5, D3DFMT_A8R8G8B8}, + {D3DFMT_CxV8U8, D3DFMT_X8L8V8U8}, }; unsigned int i;
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/surface.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index a3fda2fa136..057dda4eac1 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -194,12 +194,10 @@ static void fill_dds_header(struct dds_header *header) header->caps = DDSCAPS_TEXTURE; }
-#define check_dds_pixel_format(flags, fourcc, bpp, rmask, gmask, bmask, amask, format) \ - check_dds_pixel_format_(__LINE__, flags, fourcc, bpp, rmask, gmask, bmask, amask, format) -static void check_dds_pixel_format_(unsigned int line, +static void check_dds_pixel_format_image_info(unsigned int line, DWORD flags, DWORD fourcc, DWORD bpp, DWORD rmask, DWORD gmask, DWORD bmask, DWORD amask, - D3DFORMAT expected_format) + HRESULT expected_hr, D3DFORMAT expected_format) { HRESULT hr; D3DXIMAGE_INFO info; @@ -223,9 +221,9 @@ static void check_dds_pixel_format_(unsigned int line, memset(dds.data, 0, sizeof(dds.data));
hr = D3DXGetImageInfoFromFileInMemory(&dds, sizeof(dds), &info); - ok_(__FILE__, line)(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#lx for pixel format %#x, expected %#lx\n", - hr, expected_format, D3D_OK); - if (SUCCEEDED(hr)) + ok_(__FILE__, line)(hr == expected_hr, "D3DXGetImageInfoFromFileInMemory returned %#lx for pixel format %#x, expected %#lx\n", + hr, expected_format, expected_hr); + if (SUCCEEDED(hr) && hr == expected_hr) { ok_(__FILE__, line)(info.Format == expected_format, "D3DXGetImageInfoFromFileInMemory returned format %#x, expected %#x\n", info.Format, expected_format); @@ -260,11 +258,18 @@ static void check_dds_pixel_format_(unsigned int line, dds.header.pixel_format.bmask = bmask; dds.header.pixel_format.amask = amask; hr = D3DXGetImageInfoFromFileInMemory(&dds, sizeof(dds), &info); - ok_(__FILE__, line)(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) + ok_(__FILE__, line)(hr == expected_hr, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr) && hr == expected_hr) ok_(__FILE__, line)(info.Format == expected_format, "Unexpected format %#x.\n", info.Format); }
+#define check_dds_pixel_format(flags, fourcc, bpp, rmask, gmask, bmask, amask, format) \ + check_dds_pixel_format_image_info(__LINE__, flags, fourcc, bpp, rmask, gmask, bmask, amask, D3D_OK, format) + +#define check_dds_pixel_format_unsupported(flags, fourcc, bpp, rmask, gmask, bmask, amask, expected_hr) \ + check_dds_pixel_format_image_info(__LINE__, flags, fourcc, bpp, rmask, gmask, bmask, amask, expected_hr, \ + D3DFMT_UNKNOWN) + static void test_dds_header_handling(void) { int i; @@ -1032,6 +1037,13 @@ static void test_D3DXGetImageInfo(void) check_dds_pixel_format(DDS_PF_INDEXED, 0, 8, 0, 0, 0, 0, D3DFMT_P8); check_dds_pixel_format(DDS_PF_INDEXED | DDS_PF_ALPHA, 0, 16, 0, 0, 0, 0xff00, D3DFMT_A8P8);
+ /* + * ATI{1,2} are unsupported, but some games (Secret World Legends) attempt + * to use them on d3dx9. + */ + check_dds_pixel_format_unsupported(DDS_PF_FOURCC, MAKEFOURCC('A','T','I','1'), 0, 0, 0, 0, 0, D3DXERR_INVALIDDATA); + check_dds_pixel_format_unsupported(DDS_PF_FOURCC, MAKEFOURCC('A','T','I','2'), 0, 0, 0, 0, 0, D3DXERR_INVALIDDATA); + test_dds_header_handling(); test_tga_header_handling();
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/surface.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 057dda4eac1..2baeeba0f41 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -231,7 +231,7 @@ static void check_dds_pixel_format_image_info(unsigned int line,
/* Test again with unused fields set. */ if (flags & DDS_PF_FOURCC) - rmask = gmask = bmask = amask = bpp = ~0u; + rmask = gmask = bmask = amask = bpp = flags = ~0u; else if ((flags & (DDS_PF_INDEXED | DDS_PF_ALPHA)) == (DDS_PF_INDEXED | DDS_PF_ALPHA)) rmask = gmask = bmask = fourcc = ~0u; else if (flags & DDS_PF_INDEXED) @@ -251,6 +251,7 @@ static void check_dds_pixel_format_image_info(unsigned int line, else if (flags & DDS_PF_BUMPLUMINANCE) fourcc = amask = ~0u;
+ dds.header.pixel_format.flags = flags; dds.header.pixel_format.fourcc = fourcc; dds.header.pixel_format.bpp = bpp; dds.header.pixel_format.rmask = rmask; @@ -258,7 +259,7 @@ static void check_dds_pixel_format_image_info(unsigned int line, dds.header.pixel_format.bmask = bmask; dds.header.pixel_format.amask = amask; hr = D3DXGetImageInfoFromFileInMemory(&dds, sizeof(dds), &info); - ok_(__FILE__, line)(hr == expected_hr, "Unexpected hr %#lx.\n", hr); + todo_wine_if(flags == ~0u) ok_(__FILE__, line)(hr == expected_hr, "Unexpected hr %#lx.\n", hr); if (SUCCEEDED(hr) && hr == expected_hr) ok_(__FILE__, line)(info.Format == expected_format, "Unexpected format %#x.\n", info.Format); }
From: Connor McAdams cmcadams@codeweavers.com
Fixes a crash in Just Cause 2, which loads a DDS file with a flags value of DDS_PF_ALPHA | DDS_PF_FOURCC.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/d3dx_helpers.c | 8 ++++++-- dlls/d3dx9_36/tests/surface.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx_helpers.c b/dlls/d3dx9_36/d3dx_helpers.c index 952a7d7d9ea..57ca8f1c0a7 100644 --- a/dlls/d3dx9_36/d3dx_helpers.c +++ b/dlls/d3dx9_36/d3dx_helpers.c @@ -289,6 +289,7 @@ static BOOL dds_pixel_format_compare(const struct dds_pixel_format *pf_a, const
static enum d3dx_pixel_format_id d3dx_pixel_format_id_from_dds_pixel_format(const struct dds_pixel_format *pixel_format) { + DWORD flags = pixel_format->flags; uint32_t i;
TRACE("pixel_format: size %lu, flags %#lx, fourcc %#lx, bpp %lu.\n", pixel_format->size, @@ -296,14 +297,17 @@ static enum d3dx_pixel_format_id d3dx_pixel_format_id_from_dds_pixel_format(cons TRACE("rmask %#lx, gmask %#lx, bmask %#lx, amask %#lx.\n", pixel_format->rmask, pixel_format->gmask, pixel_format->bmask, pixel_format->amask);
+ /* DDS_PF_FOURCC overrides all other flags. */ + if (flags & DDS_PF_FOURCC) + flags = DDS_PF_FOURCC; for (i = 0; i < ARRAY_SIZE(dds_pixel_formats); ++i) { const struct dds_pixel_format *dds_pf = &dds_pixel_formats[i].dds_pixel_format;
- if (pixel_format->flags != dds_pf->flags) + if (flags != dds_pf->flags) continue;
- switch (pixel_format->flags & ~DDS_PF_ALPHA) + switch (flags & ~DDS_PF_ALPHA) { case DDS_PF_ALPHA_ONLY: if (dds_pixel_format_compare(pixel_format, dds_pf, FALSE, FALSE, FALSE, TRUE)) diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 2baeeba0f41..7789a709e84 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -259,7 +259,7 @@ static void check_dds_pixel_format_image_info(unsigned int line, dds.header.pixel_format.bmask = bmask; dds.header.pixel_format.amask = amask; hr = D3DXGetImageInfoFromFileInMemory(&dds, sizeof(dds), &info); - todo_wine_if(flags == ~0u) ok_(__FILE__, line)(hr == expected_hr, "Unexpected hr %#lx.\n", hr); + ok_(__FILE__, line)(hr == expected_hr, "Unexpected hr %#lx.\n", hr); if (SUCCEEDED(hr) && hr == expected_hr) ok_(__FILE__, line)(info.Format == expected_format, "Unexpected format %#x.\n", info.Format); }
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 75e4b4023d8..1b8fd85be15 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2884,6 +2884,40 @@ static void check_dds_pixel_format_image_info(unsigned int line, DWORD flags, DW ok_(__FILE__, line)(hr == expected_hr, "Unexpected hr %#lx.\n", hr); if (SUCCEEDED(hr) && hr == expected_hr) ok_(__FILE__, line)(info.Format == expected_format, "Unexpected format %#x.\n", info.Format); + + /* Test again with unused fields set. */ + if (flags & DDS_PF_FOURCC) + rmask = gmask = bmask = amask = bpp = flags = ~0u; + else if ((flags & (DDS_PF_INDEXED | DDS_PF_ALPHA)) == (DDS_PF_INDEXED | DDS_PF_ALPHA)) + rmask = gmask = bmask = fourcc = ~0u; + else if (flags & DDS_PF_INDEXED) + rmask = gmask = bmask = amask = fourcc = ~0u; + else if ((flags & (DDS_PF_RGB | DDS_PF_ALPHA)) == (DDS_PF_RGB | DDS_PF_ALPHA)) + fourcc = ~0u; + else if (flags & DDS_PF_RGB) + fourcc = amask = ~0u; + else if ((flags & (DDS_PF_LUMINANCE | DDS_PF_ALPHA)) == (DDS_PF_LUMINANCE | DDS_PF_ALPHA)) + gmask = bmask = fourcc = ~0u; + else if (flags & DDS_PF_LUMINANCE) + gmask = bmask = amask = fourcc = ~0u; + else if (flags & DDS_PF_ALPHA_ONLY) + rmask = gmask = bmask = fourcc = ~0u; + else if (flags & DDS_PF_BUMPDUDV) + fourcc = ~0u; + else if (flags & DDS_PF_BUMPLUMINANCE) + fourcc = amask = ~0u; + + dds.header.pixel_format.flags = flags; + dds.header.pixel_format.fourcc = fourcc; + dds.header.pixel_format.bpp = bpp; + dds.header.pixel_format.rmask = rmask; + dds.header.pixel_format.gmask = gmask; + dds.header.pixel_format.bmask = bmask; + dds.header.pixel_format.amask = amask; + hr = D3DX10GetImageInfoFromMemory(&dds, sizeof(dds), NULL, &info, NULL); + ok_(__FILE__, line)(hr == expected_hr, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr) && hr == expected_hr) + ok_(__FILE__, line)(info.Format == expected_format, "Unexpected format %#x.\n", info.Format); }
#define check_dds_pixel_format(flags, fourcc, bpp, rmask, gmask, bmask, amask, format) \ @@ -3387,6 +3421,7 @@ static void test_get_image_info(void) check_dds_pixel_format(DDS_PF_FOURCC, 0x74, 0, 0, 0, 0, 0, DXGI_FORMAT_R32G32B32A32_FLOAT); /* D3DFMT_A32B32G32R32F */
/* Test for DDS pixel formats that are valid on d3dx9, but not d3dx10. */ + check_dds_pixel_format_unsupported(DDS_PF_FOURCC, 0x75, 0, 0, 0, 0, 0, E_FAIL); /* D3DFMT_CxV8U8 */ check_dds_pixel_format_unsupported(DDS_PF_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0, E_FAIL); check_dds_pixel_format_unsupported(DDS_PF_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0, E_FAIL); /* Bumpmap formats aren't supported. */
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx11_43/tests/d3dx11.c | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx11_43/tests/d3dx11.c b/dlls/d3dx11_43/tests/d3dx11.c index 5e2d28824c3..bb840bd80e5 100644 --- a/dlls/d3dx11_43/tests/d3dx11.c +++ b/dlls/d3dx11_43/tests/d3dx11.c @@ -950,6 +950,40 @@ static void check_dds_pixel_format_image_info(unsigned int line, DWORD flags, DW ok_(__FILE__, line)(hr == expected_hr, "Unexpected hr %#lx.\n", hr); if (SUCCEEDED(hr) && hr == expected_hr) ok_(__FILE__, line)(info.Format == expected_format, "Unexpected format %#x.\n", info.Format); + + /* Test again with unused fields set. */ + if (flags & DDS_PF_FOURCC) + rmask = gmask = bmask = amask = bpp = flags = ~0u; + else if ((flags & (DDS_PF_INDEXED | DDS_PF_ALPHA)) == (DDS_PF_INDEXED | DDS_PF_ALPHA)) + rmask = gmask = bmask = fourcc = ~0u; + else if (flags & DDS_PF_INDEXED) + rmask = gmask = bmask = amask = fourcc = ~0u; + else if ((flags & (DDS_PF_RGB | DDS_PF_ALPHA)) == (DDS_PF_RGB | DDS_PF_ALPHA)) + fourcc = ~0u; + else if (flags & DDS_PF_RGB) + fourcc = amask = ~0u; + else if ((flags & (DDS_PF_LUMINANCE | DDS_PF_ALPHA)) == (DDS_PF_LUMINANCE | DDS_PF_ALPHA)) + gmask = bmask = fourcc = ~0u; + else if (flags & DDS_PF_LUMINANCE) + gmask = bmask = amask = fourcc = ~0u; + else if (flags & DDS_PF_ALPHA_ONLY) + rmask = gmask = bmask = fourcc = ~0u; + else if (flags & DDS_PF_BUMPDUDV) + fourcc = ~0u; + else if (flags & DDS_PF_BUMPLUMINANCE) + fourcc = amask = ~0u; + + dds.header.pixel_format.flags = flags; + dds.header.pixel_format.fourcc = fourcc; + dds.header.pixel_format.bpp = bpp; + dds.header.pixel_format.rmask = rmask; + dds.header.pixel_format.gmask = gmask; + dds.header.pixel_format.bmask = bmask; + dds.header.pixel_format.amask = amask; + hr = D3DX11GetImageInfoFromMemory(&dds, sizeof(dds), NULL, &info, NULL); + ok_(__FILE__, line)(hr == expected_hr, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr) && hr == expected_hr) + ok_(__FILE__, line)(info.Format == expected_format, "Unexpected format %#x.\n", info.Format); }
#define check_dds_pixel_format(flags, fourcc, bpp, rmask, gmask, bmask, amask, format) \ @@ -1474,7 +1508,8 @@ static void test_D3DX11GetImageInfoFromMemory(void) check_dds_pixel_format(DDS_PF_FOURCC, 0x73, 0, 0, 0, 0, 0, DXGI_FORMAT_R32G32_FLOAT); /* D3DFMT_G32R32F */ check_dds_pixel_format(DDS_PF_FOURCC, 0x74, 0, 0, 0, 0, 0, DXGI_FORMAT_R32G32B32A32_FLOAT); /* D3DFMT_A32B32G32R32F */
- /* Test for DDS pixel formats that are valid on d3dx9, but not d3dx10. */ + /* Test for DDS pixel formats that are valid on d3dx9, but not d3dx10+. */ + check_dds_pixel_format_unsupported(DDS_PF_FOURCC, 0x75, 0, 0, 0, 0, 0, E_FAIL); /* D3DFMT_CxV8U8 */ check_dds_pixel_format_unsupported(DDS_PF_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0, E_FAIL); check_dds_pixel_format_unsupported(DDS_PF_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0, E_FAIL); /* Bumpmap formats aren't supported. */
On Fri Sep 19 12:19:16 2025 +0000, Connor McAdams wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/8966/diffs?diff_id=210701&start_sha=a25fee9ab10ea63bda0985ef749426933309f6a8#d49071753fdf2ab21d518dbd8c720b48c7c732fc_3718_3718)
Woops, fixed :)
On Fri Sep 19 12:19:16 2025 +0000, Connor McAdams wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/8966/diffs?diff_id=210701&start_sha=a25fee9ab10ea63bda0985ef749426933309f6a8#af9ebd4e3d9dd014b2a67b9698d3718153bc2269_2169_2169)
No reason not to, I just hadn't thought about it that way. There was some documentation I'm having trouble finding now that showed the formula using a `pow` so I just copied that. :) Fixed in the current revision.
On Thu Sep 18 17:44:15 2025 +0000, Matteo Bruni wrote:
Not new, but I just realized that `dst_ctype` is a misnomer and a bit confusing. Not something to be changed in this patch though.
I _think_ I used that name because it matches with `dst_component` which already existed when I added this. Is the confusion that it comes from the source format? I guess it could make more sense as just `cur_ctype` or `ctype`.
On Fri Sep 19 13:45:19 2025 +0000, Connor McAdams wrote:
I _think_ I used that name because it matches with `dst_component` which already existed when I added this. Is the confusion that it comes from the source format? I guess it could make more sense as just `cur_ctype` or `ctype`.
Yeah, exactly. `ctype` works for me :slight_smile:
This merge request was approved by Matteo Bruni.