This series of patches are pretty small, with the biggest ones being the ones that add support for DDS files containing a color palette.
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/surface.c | 6 +++--- dlls/d3dx9_36/util.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index b6eabe16983..85f66c3dbcb 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -738,7 +738,7 @@ static void test_D3DXGetImageInfo(void) check_dds_pixel_format(DDS_PF_LUMINANCE | DDS_PF_ALPHA, 0, 16, 0x00ff, 0, 0, 0xff00, D3DFMT_A8L8); check_dds_pixel_format(DDS_PF_LUMINANCE | DDS_PF_ALPHA, 0, 8, 0x0f, 0, 0, 0xf0, D3DFMT_A4L4); check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0, D3DFMT_V8U8); - todo_wine check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0, D3DFMT_V16U16); + check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0, D3DFMT_V16U16); check_dds_pixel_format(DDS_PF_BUMPLUMINANCE, 0, 32, 0x0000ff, 0x00ff00, 0xff0000, 0, D3DFMT_X8L8V8U8);
test_dds_header_handling(); @@ -1005,8 +1005,8 @@ static void test_format_conversion(IDirect3DDevice9 *device) } tests[] = { { D3DFMT_P8, test_palette, { 0, 0, 2, 2 }, p8_2_2, D3DFMT_A8R8G8B8, p8_2_2_expected }, { D3DFMT_A16B16G16R16, NULL, { 0, 0, 2, 2 }, a16b16g16r16_2_2, D3DFMT_A32B32G32R32F, a16b16g16r16_2_2_expected }, - { D3DFMT_V16U16, NULL, { 0, 0, 2, 2 }, v16u16_2_2, D3DFMT_G16R16, v16u16_2_2_expected, .todo = TRUE }, - { D3DFMT_V16U16, NULL, { 0, 0, 2, 2 }, v16u16_2_2, D3DFMT_A32B32G32R32F, v16u16_2_2_expected2, .todo = TRUE }, + { D3DFMT_V16U16, NULL, { 0, 0, 2, 2 }, v16u16_2_2, D3DFMT_G16R16, v16u16_2_2_expected }, + { D3DFMT_V16U16, NULL, { 0, 0, 2, 2 }, v16u16_2_2, D3DFMT_A32B32G32R32F, v16u16_2_2_expected2 }, { D3DFMT_V8U8, NULL, { 0, 0, 2, 2 }, v8u8_2_2, D3DFMT_A32B32G32R32F, v8u8_2_2_expected }, { D3DFMT_Q16W16V16U16, NULL, { 0, 0, 2, 2 }, q16w16v16u16_2_2, D3DFMT_A32B32G32R32F, q16w16v16u16_2_2_expected, .todo = TRUE }, { D3DFMT_A8P8, test_palette, { 0, 0, 2, 2 }, a8p8_2_2, D3DFMT_A8R8G8B8, a8p8_2_2_expected }, diff --git a/dlls/d3dx9_36/util.c b/dlls/d3dx9_36/util.c index de9f2d9771e..b59747456d1 100644 --- a/dlls/d3dx9_36/util.c +++ b/dlls/d3dx9_36/util.c @@ -67,6 +67,7 @@ static const struct pixel_format_desc formats[] = {D3DFMT_A8P8, { 8, 8, 8, 8}, { 8, 0, 0, 0}, 2, 1, 1, 2, CTYPE_UNORM, CTYPE_INDEX, 0 }, {D3DFMT_Q8W8V8U8, { 8, 8, 8, 8}, {24, 0, 8, 16}, 4, 1, 1, 4, CTYPE_SNORM, CTYPE_SNORM, 0 }, {D3DFMT_V8U8, { 0, 8, 8, 0}, { 0, 0, 8, 0}, 2, 1, 1, 2, CTYPE_EMPTY, CTYPE_SNORM, 0 }, + {D3DFMT_V16U16, { 0, 16, 16, 0}, { 0, 0, 16, 0}, 4, 1, 1, 4, CTYPE_EMPTY, CTYPE_SNORM, 0 }, {D3DFMT_X8L8V8U8, { 8, 8, 8, 0}, {16, 0, 8, 0}, 4, 1, 1, 4, CTYPE_UNORM, CTYPE_SNORM, 0 }, {D3DFMT_A2W10V10U10, { 2, 10, 10, 10}, {30, 0, 10, 20}, 4, 1, 1, 4, CTYPE_UNORM, CTYPE_SNORM, 0 }, /* marks last element */
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/surface.c | 2 +- dlls/d3dx9_36/util.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 85f66c3dbcb..d1f3a153c18 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -1008,7 +1008,7 @@ static void test_format_conversion(IDirect3DDevice9 *device) { D3DFMT_V16U16, NULL, { 0, 0, 2, 2 }, v16u16_2_2, D3DFMT_G16R16, v16u16_2_2_expected }, { D3DFMT_V16U16, NULL, { 0, 0, 2, 2 }, v16u16_2_2, D3DFMT_A32B32G32R32F, v16u16_2_2_expected2 }, { D3DFMT_V8U8, NULL, { 0, 0, 2, 2 }, v8u8_2_2, D3DFMT_A32B32G32R32F, v8u8_2_2_expected }, - { D3DFMT_Q16W16V16U16, NULL, { 0, 0, 2, 2 }, q16w16v16u16_2_2, D3DFMT_A32B32G32R32F, q16w16v16u16_2_2_expected, .todo = TRUE }, + { D3DFMT_Q16W16V16U16, NULL, { 0, 0, 2, 2 }, q16w16v16u16_2_2, D3DFMT_A32B32G32R32F, q16w16v16u16_2_2_expected }, { D3DFMT_A8P8, test_palette, { 0, 0, 2, 2 }, a8p8_2_2, D3DFMT_A8R8G8B8, a8p8_2_2_expected }, }; uint32_t i; diff --git a/dlls/d3dx9_36/util.c b/dlls/d3dx9_36/util.c index b59747456d1..09bd4cd3e59 100644 --- a/dlls/d3dx9_36/util.c +++ b/dlls/d3dx9_36/util.c @@ -66,6 +66,7 @@ static const struct pixel_format_desc formats[] = {D3DFMT_P8, { 8, 8, 8, 8}, { 0, 0, 0, 0}, 1, 1, 1, 1, CTYPE_INDEX, CTYPE_INDEX, 0 }, {D3DFMT_A8P8, { 8, 8, 8, 8}, { 8, 0, 0, 0}, 2, 1, 1, 2, CTYPE_UNORM, CTYPE_INDEX, 0 }, {D3DFMT_Q8W8V8U8, { 8, 8, 8, 8}, {24, 0, 8, 16}, 4, 1, 1, 4, CTYPE_SNORM, CTYPE_SNORM, 0 }, + {D3DFMT_Q16W16V16U16, {16, 16, 16, 16}, {48, 0, 16, 32}, 8, 1, 1, 8, CTYPE_SNORM, CTYPE_SNORM, 0 }, {D3DFMT_V8U8, { 0, 8, 8, 0}, { 0, 0, 8, 0}, 2, 1, 1, 2, CTYPE_EMPTY, CTYPE_SNORM, 0 }, {D3DFMT_V16U16, { 0, 16, 16, 0}, { 0, 0, 16, 0}, 4, 1, 1, 4, CTYPE_EMPTY, CTYPE_SNORM, 0 }, {D3DFMT_X8L8V8U8, { 8, 8, 8, 0}, {16, 0, 8, 0}, 4, 1, 1, 4, CTYPE_UNORM, CTYPE_SNORM, 0 },
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/d3dx9_test_images.h | 79 +++++++++++++++++++++++++ dlls/d3dx9_36/tests/surface.c | 37 ++++++++++++ 2 files changed, 116 insertions(+)
diff --git a/dlls/d3dx9_36/tests/d3dx9_test_images.h b/dlls/d3dx9_36/tests/d3dx9_test_images.h index 605e4a0b860..266c0c201cf 100644 --- a/dlls/d3dx9_36/tests/d3dx9_test_images.h +++ b/dlls/d3dx9_36/tests/d3dx9_test_images.h @@ -226,6 +226,85 @@ static const uint8_t dds_8bit[] = 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 };
+/* 4x4 A8P8 dds file. */ +static const uint8_t dds_a8p8[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x47,0x49,0x4d,0x50,0x2d,0x44,0x44,0x53,0x5a,0x09,0x03,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x00,0x80,0x00,0x02,0x00,0x80,0x80,0x03, + 0x80,0x00,0x00,0x04,0x80,0x00,0x80,0x05,0x80,0x80,0x00,0x06,0xc0,0xc0,0xc0,0x07, + 0xc0,0xdc,0xc0,0x08,0xf0,0xca,0xa6,0x09,0x00,0x20,0x40,0x0a,0x00,0x20,0x60,0x0b, + 0x00,0x20,0x80,0x0c,0x00,0x20,0xa0,0x0d,0x00,0x20,0xc0,0x0e,0x00,0x20,0xe0,0x0f, + 0x00,0x40,0x00,0x10,0x00,0x40,0x20,0x11,0x00,0x40,0x40,0x12,0x00,0x40,0x60,0x13, + 0x00,0x40,0x80,0x14,0x00,0x40,0xa0,0x15,0x00,0x40,0xc0,0x16,0x00,0x40,0xe0,0x17, + 0x00,0x60,0x00,0x18,0x00,0x60,0x20,0x19,0x00,0x60,0x40,0x1a,0x00,0x60,0x60,0x1b, + 0x00,0x60,0x80,0x1c,0x00,0x60,0xa0,0x1d,0x00,0x60,0xc0,0x1e,0x00,0x60,0xe0,0x1f, + 0x00,0x80,0x00,0x20,0x00,0x80,0x20,0x21,0x00,0x80,0x40,0x22,0x00,0x80,0x60,0x23, + 0x00,0x80,0x80,0x24,0x00,0x80,0xa0,0x25,0x00,0x80,0xc0,0x26,0x00,0x80,0xe0,0x27, + 0x00,0xa0,0x00,0x28,0x00,0xa0,0x20,0x29,0x00,0xa0,0x40,0x2a,0x00,0xa0,0x60,0x2b, + 0x00,0xa0,0x80,0x2c,0x00,0xa0,0xa0,0x2d,0x00,0xa0,0xc0,0x2e,0x00,0xa0,0xe0,0x2f, + 0x00,0xc0,0x00,0x30,0x00,0xc0,0x20,0x31,0x00,0xc0,0x40,0x32,0x00,0xc0,0x60,0x33, + 0x00,0xc0,0x80,0x34,0x00,0xc0,0xa0,0x35,0x00,0xc0,0xc0,0x36,0x00,0xc0,0xe0,0x37, + 0x00,0xe0,0x00,0x38,0x00,0xe0,0x20,0x39,0x00,0xe0,0x40,0x3a,0x00,0xe0,0x60,0x3b, + 0x00,0xe0,0x80,0x3c,0x00,0xe0,0xa0,0x3d,0x00,0xe0,0xc0,0x3e,0x00,0xe0,0xe0,0x3f, + 0x40,0x00,0x00,0x40,0x40,0x00,0x20,0x41,0x40,0x00,0x40,0x42,0x40,0x00,0x60,0x43, + 0x40,0x00,0x80,0x44,0x40,0x00,0xa0,0x45,0x40,0x00,0xc0,0x46,0x40,0x00,0xe0,0x47, + 0x40,0x20,0x00,0x48,0x40,0x20,0x20,0x49,0x40,0x20,0x40,0x4a,0x40,0x20,0x60,0x4b, + 0x40,0x20,0x80,0x4c,0x40,0x20,0xa0,0x4d,0x40,0x20,0xc0,0x4e,0x40,0x20,0xe0,0x4f, + 0x40,0x40,0x00,0x50,0x40,0x40,0x20,0x51,0x40,0x40,0x40,0x52,0x40,0x40,0x60,0x53, + 0x40,0x40,0x80,0x54,0x40,0x40,0xa0,0x55,0x40,0x40,0xc0,0x56,0x40,0x40,0xe0,0x57, + 0x40,0x60,0x00,0x58,0x40,0x60,0x20,0x59,0x40,0x60,0x40,0x5a,0x40,0x60,0x60,0x5b, + 0x40,0x60,0x80,0x5c,0x40,0x60,0xa0,0x5d,0x40,0x60,0xc0,0x5e,0x40,0x60,0xe0,0x5f, + 0x40,0x80,0x00,0x60,0x40,0x80,0x20,0x61,0x40,0x80,0x40,0x62,0x40,0x80,0x60,0x63, + 0x40,0x80,0x80,0x64,0x40,0x80,0xa0,0x65,0x40,0x80,0xc0,0x66,0x40,0x80,0xe0,0x67, + 0x40,0xa0,0x00,0x68,0x40,0xa0,0x20,0x69,0x40,0xa0,0x40,0x6a,0x40,0xa0,0x60,0x6b, + 0x40,0xa0,0x80,0x6c,0x40,0xa0,0xa0,0x6d,0x40,0xa0,0xc0,0x6e,0x40,0xa0,0xe0,0x6f, + 0x40,0xc0,0x00,0x70,0x40,0xc0,0x20,0x71,0x40,0xc0,0x40,0x72,0x40,0xc0,0x60,0x73, + 0x40,0xc0,0x80,0x74,0x40,0xc0,0xa0,0x75,0x40,0xc0,0xc0,0x76,0x40,0xc0,0xe0,0x77, + 0x40,0xe0,0x00,0x78,0x40,0xe0,0x20,0x79,0x40,0xe0,0x40,0x7a,0x40,0xe0,0x60,0x7b, + 0x40,0xe0,0x80,0x7c,0x40,0xe0,0xa0,0x7d,0x40,0xe0,0xc0,0x7e,0x40,0xe0,0xe0,0x7f, + 0x80,0x00,0x00,0x80,0x80,0x00,0x20,0x81,0x80,0x00,0x40,0x82,0x80,0x00,0x60,0x83, + 0x80,0x00,0x80,0x84,0x80,0x00,0xa0,0x85,0x80,0x00,0xc0,0x86,0x80,0x00,0xe0,0x87, + 0x80,0x20,0x00,0x88,0x80,0x20,0x20,0x89,0x80,0x20,0x40,0x8a,0x80,0x20,0x60,0x8b, + 0x80,0x20,0x80,0x8c,0x80,0x20,0xa0,0x8d,0x80,0x20,0xc0,0x8e,0x80,0x20,0xe0,0x8f, + 0x80,0x40,0x00,0x90,0x80,0x40,0x20,0x91,0x80,0x40,0x40,0x92,0x80,0x40,0x60,0x93, + 0x80,0x40,0x80,0x94,0x80,0x40,0xa0,0x95,0x80,0x40,0xc0,0x96,0x80,0x40,0xe0,0x97, + 0x80,0x60,0x00,0x98,0x80,0x60,0x20,0x99,0x80,0x60,0x40,0x9a,0x80,0x60,0x60,0x9b, + 0x80,0x60,0x80,0x9c,0x80,0x60,0xa0,0x9d,0x80,0x60,0xc0,0x9e,0x80,0x60,0xe0,0x9f, + 0x80,0x80,0x00,0xa0,0x80,0x80,0x20,0xa1,0x80,0x80,0x40,0xa2,0x80,0x80,0x60,0xa3, + 0x80,0x80,0x80,0xa4,0x80,0x80,0xa0,0xa5,0x80,0x80,0xc0,0xa6,0x80,0x80,0xe0,0xa7, + 0x80,0xa0,0x00,0xa8,0x80,0xa0,0x20,0xa9,0x80,0xa0,0x40,0xaa,0x80,0xa0,0x60,0xab, + 0x80,0xa0,0x80,0xac,0x80,0xa0,0xa0,0xad,0x80,0xa0,0xc0,0xae,0x80,0xa0,0xe0,0xaf, + 0x80,0xc0,0x00,0xb0,0x80,0xc0,0x20,0xb1,0x80,0xc0,0x40,0xb2,0x80,0xc0,0x60,0xb3, + 0x80,0xc0,0x80,0xb4,0x80,0xc0,0xa0,0xb5,0x80,0xc0,0xc0,0xb6,0x80,0xc0,0xe0,0xb7, + 0x80,0xe0,0x00,0xb8,0x80,0xe0,0x20,0xb9,0x80,0xe0,0x40,0xba,0x80,0xe0,0x60,0xbb, + 0x80,0xe0,0x80,0xbc,0x80,0xe0,0xa0,0xbd,0x80,0xe0,0xc0,0xbe,0x80,0xe0,0xe0,0xbf, + 0xc0,0x00,0x00,0xc0,0xc0,0x00,0x20,0xc1,0xc0,0x00,0x40,0xc2,0xc0,0x00,0x60,0xc3, + 0xc0,0x00,0x80,0xc4,0xc0,0x00,0xa0,0xc5,0xc0,0x00,0xc0,0xc6,0xc0,0x00,0xe0,0xc7, + 0xc0,0x20,0x00,0xc8,0xc0,0x20,0x20,0xc9,0xc0,0x20,0x40,0xca,0xc0,0x20,0x60,0xcb, + 0xc0,0x20,0x80,0xcc,0xc0,0x20,0xa0,0xcd,0xc0,0x20,0xc0,0xce,0xc0,0x20,0xe0,0xcf, + 0xc0,0x40,0x00,0xd0,0xc0,0x40,0x20,0xd1,0xc0,0x40,0x40,0xd2,0xc0,0x40,0x60,0xd3, + 0xc0,0x40,0x80,0xd4,0xc0,0x40,0xa0,0xd5,0xc0,0x40,0xc0,0xd6,0xc0,0x40,0xe0,0xd7, + 0xc0,0x60,0x00,0xd8,0xc0,0x60,0x20,0xd9,0xc0,0x60,0x40,0xda,0xc0,0x60,0x60,0xdb, + 0xc0,0x60,0x80,0xdc,0xc0,0x60,0xa0,0xdd,0xc0,0x60,0xc0,0xde,0xc0,0x60,0xe0,0xdf, + 0xc0,0x80,0x00,0xe0,0xc0,0x80,0x20,0xe1,0xc0,0x80,0x40,0xe2,0xc0,0x80,0x60,0xe3, + 0xc0,0x80,0x80,0xe4,0xc0,0x80,0xa0,0xe5,0xc0,0x80,0xc0,0xe6,0xc0,0x80,0xe0,0xe7, + 0xc0,0xa0,0x00,0xe8,0xc0,0xa0,0x20,0xe9,0xc0,0xa0,0x40,0xea,0xc0,0xa0,0x60,0xeb, + 0xc0,0xa0,0x80,0xec,0xc0,0xa0,0xa0,0xed,0xc0,0xa0,0xc0,0xee,0xc0,0xa0,0xe0,0xef, + 0xc0,0xc0,0x00,0xf0,0xc0,0xc0,0x20,0xf1,0xc0,0xc0,0x40,0xf2,0xc0,0xc0,0x60,0xf3, + 0xc0,0xc0,0x80,0xf4,0xc0,0xc0,0xa0,0xf5,0xf0,0xfb,0xff,0xf6,0xa4,0xa0,0xa0,0xf7, + 0x80,0x80,0x80,0xf8,0x00,0x00,0xff,0xf9,0x00,0xff,0x00,0xfa,0x00,0xff,0xff,0xfb, + 0xff,0x00,0x00,0xfc,0xff,0x00,0xff,0xfd,0xff,0xff,0x00,0xfe,0xff,0xff,0xff,0xff, + 0x00,0xf0,0x10,0xe0,0x20,0xd0,0x30,0xc0,0x40,0xb0,0x50,0xa0,0x60,0x90,0x70,0x80, + 0x80,0x70,0x90,0x60,0xa0,0x50,0xb0,0x40,0xc0,0x30,0xd0,0x20,0xe0,0x10,0xf0,0x00, +}; + /* 2x2 24-bit dds, 2 mipmaps */ static const uint8_t dds_24bit[] = { diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index d1f3a153c18..1128a67423c 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -172,6 +172,7 @@ static HRESULT create_file(const char *filename, const unsigned char *data, cons #define DDS_PF_ALPHA 0x00000001 #define DDS_PF_ALPHA_ONLY 0x00000002 #define DDS_PF_FOURCC 0x00000004 +#define DDS_PF_INDEXED 0x00000020 #define DDS_PF_RGB 0x00000040 #define DDS_PF_LUMINANCE 0x00020000 #define DDS_PF_BUMPLUMINANCE 0x00040000 @@ -241,6 +242,7 @@ static void check_dds_pixel_format_(unsigned int line, { DWORD magic; struct dds_header header; + PALETTEENTRY palette[256]; BYTE data[256]; } dds;
@@ -740,6 +742,8 @@ static void test_D3DXGetImageInfo(void) check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0, D3DFMT_V8U8); check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0, D3DFMT_V16U16); check_dds_pixel_format(DDS_PF_BUMPLUMINANCE, 0, 32, 0x0000ff, 0x00ff00, 0xff0000, 0, D3DFMT_X8L8V8U8); + check_dds_pixel_format(DDS_PF_INDEXED, 0, 8, 0, 0, 0, 0, D3DFMT_P8); + todo_wine check_dds_pixel_format(DDS_PF_INDEXED | DDS_PF_ALPHA, 0, 16, 0, 0, 0, 0xff00, D3DFMT_A8P8);
test_dds_header_handling();
@@ -755,6 +759,9 @@ static void test_D3DXGetImageInfo(void) hr = D3DXGetImageInfoFromFileInMemory(dds_volume_map, sizeof(dds_volume_map) - 1, &info); ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromFileInMemory returned %#lx, expected %#x\n", hr, D3DXERR_INVALIDDATA);
+ /* Size includes the size of the color palette. */ + hr = D3DXGetImageInfoFromFileInMemory(dds_8bit, (sizeof(dds_8bit) - (sizeof(PALETTEENTRY) * 256)), &info); + todo_wine ok(hr == D3DXERR_INVALIDDATA, "Unexpected hr %#lx.\n", hr);
/* cleanup */ if(testdummy_ok) DeleteFileA("testdummy.bmp"); @@ -1732,6 +1739,36 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) winetest_pop_context(); }
+ /* Test D3DXLoadSurfaceFromFileInMemory with indexed pixel format DDS files. */ + if (!strcmp(winetest_platform, "windows")) + { + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_8bit, sizeof(dds_8bit), &rect, D3DX_FILTER_NONE, 0, NULL); + ok(hr == D3D_OK, "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, 0xffec2700); + check_pixel_4bpp(&lockrect, 1, 0, 0xffec2700); + check_pixel_4bpp(&lockrect, 0, 1, 0xffec2700); + check_pixel_4bpp(&lockrect, 1, 1, 0xffec2700); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + } + else + { + skip("Skipping test on wine to avoid access violation.\n"); + } + + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_a8p8, sizeof(dds_a8p8), &rect, D3DX_FILTER_NONE, 0, NULL); + todo_wine ok(hr == D3D_OK, "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); + todo_wine check_pixel_4bpp(&lockrect, 0, 0, 0xf0000000); + todo_wine check_pixel_4bpp(&lockrect, 1, 0, 0xe0004000); + todo_wine check_pixel_4bpp(&lockrect, 0, 1, 0xb0400000); + todo_wine check_pixel_4bpp(&lockrect, 1, 1, 0xa0404000); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + check_release((IUnknown*)surf, 0); }
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/surface.c | 11 ++++++++--- dlls/d3dx9_36/tests/surface.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 2439bc7f8bd..85a11ef90c1 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -588,17 +588,22 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur return D3D_OK; }
+#define DDS_PALETTE_SIZE (sizeof(PALETTEENTRY) * 256) static HRESULT d3dx_initialize_image_from_dds(const void *src_data, uint32_t src_data_size, struct d3dx_image *image, uint32_t starting_mip_level) { + uint32_t expected_src_data_size, header_size; const struct dds_header *header = src_data; - uint32_t expected_src_data_size; + BOOL is_indexed_fmt; HRESULT hr;
if (src_data_size < sizeof(*header) || header->pixel_format.size != sizeof(header->pixel_format)) return D3DXERR_INVALIDDATA;
TRACE("File type is DDS.\n"); + is_indexed_fmt = !!(header->pixel_format.flags & DDS_PF_INDEXED); + header_size = is_indexed_fmt ? sizeof(*header) + DDS_PALETTE_SIZE : sizeof(*header); + set_volume_struct(&image->size, header->width, header->height, 1); image->mip_levels = header->miplevels ? header->miplevels : 1; image->format = dds_pixel_format_to_d3dformat(&header->pixel_format); @@ -631,14 +636,14 @@ static HRESULT d3dx_initialize_image_from_dds(const void *src_data, uint32_t src image->size.depth, image->mip_levels); if (!image->layer_pitch) return D3DXERR_INVALIDDATA; - expected_src_data_size = (image->layer_pitch * image->layer_count) + sizeof(*header); + expected_src_data_size = (image->layer_pitch * image->layer_count) + header_size; if (src_data_size < expected_src_data_size) { WARN("File is too short %u, expected at least %u bytes.\n", src_data_size, expected_src_data_size); return D3DXERR_INVALIDDATA; }
- image->pixels = ((BYTE *)src_data) + sizeof(*header); + image->pixels = ((BYTE *)src_data) + header_size; image->image_file_format = D3DXIFF_DDS; if (starting_mip_level && (image->mip_levels > 1)) { diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 1128a67423c..7fc4328d74c 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -761,7 +761,7 @@ static void test_D3DXGetImageInfo(void)
/* Size includes the size of the color palette. */ hr = D3DXGetImageInfoFromFileInMemory(dds_8bit, (sizeof(dds_8bit) - (sizeof(PALETTEENTRY) * 256)), &info); - todo_wine ok(hr == D3DXERR_INVALIDDATA, "Unexpected hr %#lx.\n", hr); + ok(hr == D3DXERR_INVALIDDATA, "Unexpected hr %#lx.\n", hr);
/* cleanup */ if(testdummy_ok) DeleteFileA("testdummy.bmp");
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/d3dx9_private.h | 5 +++-- dlls/d3dx9_36/surface.c | 7 ++++--- dlls/d3dx9_36/tests/surface.c | 27 ++++++++++----------------- 3 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 503dbfdc924..303489374f8 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -153,15 +153,16 @@ struct d3dx_image uint32_t layer_count;
BYTE *pixels; + PALETTEENTRY *palette; uint32_t layer_pitch;
/* - * image_buf and palette are pointers to allocated memory used to store + * image_buf and image_palette are pointers to allocated memory used to store * image data. If they are non-NULL, they need to be freed when no longer * in use. */ void *image_buf; - PALETTEENTRY *palette; + PALETTEENTRY *image_palette;
D3DXIMAGE_FILEFORMAT image_file_format; }; diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 85a11ef90c1..c75573cd34a 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -643,6 +643,7 @@ static HRESULT d3dx_initialize_image_from_dds(const void *src_data, uint32_t src return D3DXERR_INVALIDDATA; }
+ image->palette = (is_indexed_fmt) ? (PALETTEENTRY *)(((uint8_t *)src_data) + sizeof(*header)) : NULL; image->pixels = ((BYTE *)src_data) + header_size; image->image_file_format = D3DXIFF_DDS; if (starting_mip_level && (image->mip_levels > 1)) @@ -891,13 +892,13 @@ static HRESULT d3dx_image_wic_frame_decode(struct d3dx_image *image, }
image->image_buf = image->pixels = buffer; - image->palette = palette; + image->image_palette = image->palette = palette;
exit: free(colors); if (image->image_buf != buffer) free(buffer); - if (image->palette != palette) + if (image->image_palette != palette) free(palette); if (wic_palette) IWICPalette_Release(wic_palette); @@ -1033,7 +1034,7 @@ HRESULT d3dx_image_init(const void *src_data, uint32_t src_data_size, struct d3d void d3dx_image_cleanup(struct d3dx_image *image) { free(image->image_buf); - free(image->palette); + free(image->image_palette); }
HRESULT d3dx_image_get_pixels(struct d3dx_image *image, uint32_t layer, uint32_t mip_level, diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 7fc4328d74c..b0d166eb36a 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -1740,23 +1740,16 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) }
/* Test D3DXLoadSurfaceFromFileInMemory with indexed pixel format DDS files. */ - if (!strcmp(winetest_platform, "windows")) - { - hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_8bit, sizeof(dds_8bit), &rect, D3DX_FILTER_NONE, 0, NULL); - ok(hr == D3D_OK, "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, 0xffec2700); - check_pixel_4bpp(&lockrect, 1, 0, 0xffec2700); - check_pixel_4bpp(&lockrect, 0, 1, 0xffec2700); - check_pixel_4bpp(&lockrect, 1, 1, 0xffec2700); - hr = IDirect3DSurface9_UnlockRect(surf); - ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); - } - else - { - skip("Skipping test on wine to avoid access violation.\n"); - } + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_8bit, sizeof(dds_8bit), &rect, D3DX_FILTER_NONE, 0, NULL); + ok(hr == D3D_OK, "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, 0xffec2700); + check_pixel_4bpp(&lockrect, 1, 0, 0xffec2700); + check_pixel_4bpp(&lockrect, 0, 1, 0xffec2700); + check_pixel_4bpp(&lockrect, 1, 1, 0xffec2700); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr);
hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_a8p8, sizeof(dds_a8p8), &rect, D3DX_FILTER_NONE, 0, NULL); todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/surface.c | 2 ++ dlls/d3dx9_36/tests/surface.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index c75573cd34a..59e18ed952c 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -355,6 +355,8 @@ static D3DFORMAT dds_indexed_to_d3dformat(const struct dds_pixel_format *pixel_f { if (pixel_format->bpp == 8) return D3DFMT_P8; + if (pixel_format->bpp == 16 && pixel_format->amask == 0xff00) + return D3DFMT_A8P8;
WARN("Unknown indexed pixel format (bpp %lu).\n", pixel_format->bpp); return D3DFMT_UNKNOWN; diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index b0d166eb36a..3a85a7d949f 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -743,7 +743,7 @@ static void test_D3DXGetImageInfo(void) check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0, D3DFMT_V16U16); check_dds_pixel_format(DDS_PF_BUMPLUMINANCE, 0, 32, 0x0000ff, 0x00ff00, 0xff0000, 0, D3DFMT_X8L8V8U8); check_dds_pixel_format(DDS_PF_INDEXED, 0, 8, 0, 0, 0, 0, D3DFMT_P8); - todo_wine check_dds_pixel_format(DDS_PF_INDEXED | DDS_PF_ALPHA, 0, 16, 0, 0, 0, 0xff00, D3DFMT_A8P8); + check_dds_pixel_format(DDS_PF_INDEXED | DDS_PF_ALPHA, 0, 16, 0, 0, 0, 0xff00, D3DFMT_A8P8);
test_dds_header_handling();
@@ -1752,13 +1752,13 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr);
hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_a8p8, sizeof(dds_a8p8), &rect, D3DX_FILTER_NONE, 0, NULL); - todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + ok(hr == D3D_OK, "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); - todo_wine check_pixel_4bpp(&lockrect, 0, 0, 0xf0000000); - todo_wine check_pixel_4bpp(&lockrect, 1, 0, 0xe0004000); - todo_wine check_pixel_4bpp(&lockrect, 0, 1, 0xb0400000); - todo_wine check_pixel_4bpp(&lockrect, 1, 1, 0xa0404000); + check_pixel_4bpp(&lockrect, 0, 0, 0xf0000000); + check_pixel_4bpp(&lockrect, 1, 0, 0xe0004000); + check_pixel_4bpp(&lockrect, 0, 1, 0xb0400000); + check_pixel_4bpp(&lockrect, 1, 1, 0xa0404000); hr = IDirect3DSurface9_UnlockRect(surf); ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr);
Matteo Bruni (@Mystral) commented about dlls/d3dx9_36/surface.c:
return D3DXERR_INVALIDDATA; }
- image->palette = (is_indexed_fmt) ? (PALETTEENTRY *)(((uint8_t *)src_data) + sizeof(*header)) : NULL; image->pixels = ((BYTE *)src_data) + header_size; image->image_file_format = D3DXIFF_DDS; if (starting_mip_level && (image->mip_levels > 1))
I find all those unnecessary parentheses kinda ugly...
Matteo Bruni (@Mystral) commented about dlls/d3dx9_36/surface.c:
{ if (pixel_format->bpp == 8) return D3DFMT_P8;
- if (pixel_format->bpp == 16 && pixel_format->amask == 0xff00)
Maybe also check that the other masks are 0? Ideally this should be tested.
This merge request was approved by Matteo Bruni.
Looks good. I proposed an optional additional test for the interested reader...