From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/d3dx9_test_images.h | 381 ++++++++++++++++++++++++ dlls/d3dx9_36/tests/surface.c | 267 +---------------- dlls/d3dx9_36/tests/texture.c | 186 +----------- dlls/d3dx9_36/tests/volume.c | 18 +- 4 files changed, 384 insertions(+), 468 deletions(-) create mode 100644 dlls/d3dx9_36/tests/d3dx9_test_images.h
diff --git a/dlls/d3dx9_36/tests/d3dx9_test_images.h b/dlls/d3dx9_36/tests/d3dx9_test_images.h new file mode 100644 index 00000000000..ca20ed6954d --- /dev/null +++ b/dlls/d3dx9_36/tests/d3dx9_test_images.h @@ -0,0 +1,381 @@ +/* + * Test images used across the surface, texture and volume test files. + * + * Copyright 2024 Connor McAdams for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdint.h> + +/* 1x1 bmp (1 bpp) */ +static const uint8_t bmp_1bpp[] = +{ + 0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00, + 0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00, + 0x00,0x00 +}; + +/* 1x1 bmp (2 bpp) */ +static const uint8_t bmp_2bpp[] = +{ + 0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x00,0x00, + 0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00, + 0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00, + 0x00,0x00 +}; + +/* 1x1 bmp (4 bpp) */ +static const uint8_t bmp_4bpp[] = +{ + 0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00, + 0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00, + 0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00, + 0x00,0x00 +}; + +/* 1x1 bmp (8 bpp) */ +static const uint8_t bmp_8bpp[] = +{ + 0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0x00, + 0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00, + 0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00, + 0x00,0x00 +}; + +/* 2x2 bmp (32 bpp XRGB) */ +static const uint8_t bmp_32bpp_xrgb[] = +{ + 0x42,0x4d,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, + 0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00, + 0x00,0x00,0x10,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb0,0xc0,0x00,0xa1,0xb1,0xc1,0x00,0xa2,0xb2, + 0xc2,0x00,0xa3,0xb3,0xc3,0x00 +}; + +/* 2x2 bmp (32 bpp ARGB) */ +static const uint8_t bmp_32bpp_argb[] = +{ + 0x42,0x4d,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, + 0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00, + 0x00,0x00,0x10,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb0,0xc0,0x00,0xa1,0xb1,0xc1,0x00,0xa2,0xb2, + 0xc2,0x00,0xa3,0xb3,0xc3,0x01 +}; + +static const uint8_t png_grayscale[] = +{ + 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, + 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x3a,0x7e,0x9b, + 0x55,0x00,0x00,0x00,0x0a,0x49,0x44,0x41,0x54,0x08,0xd7,0x63,0xf8,0x0f,0x00,0x01, + 0x01,0x01,0x00,0x1b,0xb6,0xee,0x56,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae, + 0x42,0x60,0x82 +}; + +/* 2x2 A8R8G8B8 pixel data */ +static const uint8_t pixdata[] = +{ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +}; + +/* invalid image file */ +static const uint8_t noimage[4] = +{ + 0x11,0x22,0x33,0x44 +}; + +/* 16x4 8-bit dds */ +static const uint8_t dds_8bit[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x04,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x10,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, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0x8c,0xcd,0x12,0xff, + 0x78,0x01,0x14,0xff,0x50,0xcd,0x12,0xff,0x00,0x3d,0x8c,0xff,0x02,0x00,0x00,0xff, + 0x47,0x00,0x00,0xff,0xda,0x07,0x02,0xff,0x50,0xce,0x12,0xff,0xea,0x11,0x01,0xff, + 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x08,0x3d,0x8c,0xff,0x08,0x01,0x00,0xff, + 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x60,0xcc,0x12,0xff, + 0xa1,0xb2,0xd4,0xff,0xda,0x07,0x02,0xff,0x47,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x50,0xce,0x12,0xff,0x00,0x00,0x14,0xff,0xa8,0xcc,0x12,0xff,0x3c,0xb2,0xd4,0xff, + 0xda,0x07,0x02,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0xff, + 0x21,0x00,0x00,0xff,0xd8,0xcb,0x12,0xff,0x54,0xcd,0x12,0xff,0x8b,0x4f,0xd5,0xff, + 0x00,0x04,0xda,0xff,0x00,0x00,0x00,0xff,0x3d,0x04,0x91,0xff,0x70,0xce,0x18,0xff, + 0xb4,0xcc,0x12,0xff,0x6b,0x4e,0xd5,0xff,0xb0,0xcc,0x12,0xff,0x00,0x00,0x00,0xff, + 0xc8,0x05,0x91,0xff,0x98,0xc7,0xcc,0xff,0x7c,0xcd,0x12,0xff,0x51,0x05,0x91,0xff, + 0x48,0x07,0x14,0xff,0x6d,0x05,0x91,0xff,0x00,0x07,0xda,0xff,0xa0,0xc7,0xcc,0xff, + 0x00,0x07,0xda,0xff,0x3a,0x77,0xd5,0xff,0xda,0x07,0x02,0xff,0x7c,0x94,0xd4,0xff, + 0xe0,0xce,0xd6,0xff,0x0a,0x80,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x78,0x9a,0xab,0xff,0xde,0x08,0x18,0xff,0xda,0x07,0x02,0xff,0x30,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x50,0xce,0x12,0xff,0x8c,0xcd,0x12,0xff,0xd0,0xb7,0xd8,0xff, + 0x00,0x00,0x00,0xff,0x60,0x32,0xd9,0xff,0x30,0xc1,0x1a,0xff,0xa8,0xcd,0x12,0xff, + 0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff,0x46,0x71,0x0e,0xff,0xc0,0x1d,0x4b,0xff, + 0x09,0x87,0xd4,0xff,0x00,0x00,0x00,0xff,0xf6,0x22,0x00,0xff,0x64,0xcd,0x12,0xff, + 0x00,0x00,0x00,0xff,0xca,0x1d,0x4b,0xff,0x09,0x87,0xd4,0xff,0xaa,0x02,0x05,0xff, + 0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0xc0,0x1d,0x4b,0xff, + 0xcd,0xab,0xba,0xff,0x00,0x00,0x00,0xff,0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff, + 0xd4,0xcd,0x12,0xff,0xa6,0x4c,0xd5,0xff,0x00,0xf0,0xfd,0xff,0xd4,0xcd,0x12,0xff, + 0xf4,0x4c,0xd5,0xff,0x90,0xcd,0x12,0xff,0xc2,0x4c,0xd5,0xff,0x82,0x00,0x00,0xff, + 0xaa,0x02,0x05,0xff,0x88,0xd4,0xba,0xff,0x14,0x00,0x00,0xff,0x01,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x0c,0x08,0x13,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0xd0,0xcd,0x12,0xff,0xc6,0x84,0xf1,0xff,0x7c,0x84,0xf1,0xff,0x20,0x20,0xf5,0xff, + 0x00,0x00,0x0a,0xff,0xf0,0xb0,0x94,0xff,0x64,0x6c,0xf1,0xff,0x85,0x6c,0xf1,0xff, + 0x8b,0x4f,0xd5,0xff,0x00,0x04,0xda,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff, + 0x39,0xde,0xd4,0xff,0x10,0x50,0xd5,0xff,0xaa,0x02,0x05,0xff,0x00,0x00,0x00,0xff, + 0x4f,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff,0x00,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff, + 0xaa,0x02,0x05,0xff,0x4c,0xce,0x12,0xff,0x39,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff, + 0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5b,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x68,0x50,0xcd,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0xe3,0xea,0x90,0xff,0x5c,0xce,0x12,0xff, + 0x18,0x00,0x00,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 +}; + +/* 2x2 24-bit dds, 2 mipmaps */ +static const uint8_t dds_24bit[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x02,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +}; + +/* 2x2 16-bit dds, no mipmaps */ +static const uint8_t dds_16bit[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x08,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,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, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x7c,0x00,0x00, + 0xe0,0x03,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f +}; + +/* 4x4 cube map dds */ +static const uint8_t dds_cube_map[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x04,0x00,0x00,0x00, + 0x04,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,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, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, + 0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x51, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x52, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x53, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x54, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x55 +}; + +/* 4x4x2 volume map dds, 2 mipmaps */ +static const uint8_t dds_volume_map[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c, + 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab +}; + +/* 4x2 dxt5 */ +static const uint8_t dds_dxt5[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, +}; + +/* 8x8 dxt5 */ +static const uint8_t dds_dxt5_8_8[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x08,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0xe0,0x07,0x05,0x05,0x50,0x50, + 0x3f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x07,0x05,0x05,0x50,0x50, + 0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xf8,0xe0,0xff,0x05,0x05,0x50,0x50, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x05,0x05,0x50,0x50, +}; + +/* + * 8x8 dxt5 image data, four 4x4 blocks: + * +-----+-----+ + * |Blue |Green| + * | | | + * +-----+-----+ + * |Red |Black| + * | | | + * +-----+-----+ + */ +static const uint8_t dxt5_8_8[] = +{ + 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x1f,0x00,0x00,0x00,0x00,0x00, + 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x07,0xe0,0x07,0x00,0x00,0x00,0x00, + 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00,0x00, + 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; + +/* + * 4x4x4 24-bit volume dds, 3 mipmaps. Level 0 is red, level 1 is green, level 2 is + * blue. + */ +static const uint8_t dds_volume_24bit_4_4_4[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x82,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00 +}; + +/* + * 4x4x4 DXT3 volume dds. 3 mipmaps. Level 0 is red, level 1 is green, level 2 is + * blue. + */ +static const uint8_t dds_volume_dxt3_4_4_4[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x04,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x07,0xe0,0x07,0xaa,0xaa,0xaa,0xaa, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x07,0xe0,0x07,0xaa,0xaa,0xaa,0xaa, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x1f,0x00,0xaa,0xaa,0xaa,0xaa, +}; + +/* + * 8x8 24-bit dds, 4 mipmaps. Level 0 is red, level 1 is green, level 2 is + * blue, and level 3 is black. + */ +static const uint8_t dds_24bit_8_8[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x08,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00 +}; diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 3c88eec5dcb..7d9b79c5727 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -24,6 +24,7 @@ #include "d3dx9tex.h" #include "resources.h" #include <stdint.h> +#include "d3dx9_test_images.h"
#define check_release(obj, exp) _check_release(__LINE__, obj, exp) static inline void _check_release(unsigned int line, IUnknown *obj, int exp) @@ -32,272 +33,6 @@ static inline void _check_release(unsigned int line, IUnknown *obj, int exp) ok_(__FILE__, line)(ref == exp, "Invalid refcount. Expected %d, got %d\n", exp, ref); }
-/* 1x1 bmp (1 bpp) */ -static const unsigned char bmp_1bpp[] = { -0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00, -0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00, -0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00, -0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00, -0x00,0x00 -}; - -/* 1x1 bmp (2 bpp) */ -static const unsigned char bmp_2bpp[] = { -0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00, -0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x00,0x00, -0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00, -0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00, -0x00,0x00 -}; - -/* 1x1 bmp (4 bpp) */ -static const unsigned char bmp_4bpp[] = { -0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00, -0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00, -0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00, -0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00, -0x00,0x00 -}; - -/* 1x1 bmp (8 bpp) */ -static const unsigned char bmp_8bpp[] = { -0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00, -0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0x00, -0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00, -0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00, -0x00,0x00 -}; - -/* 2x2 bmp (32 bpp XRGB) */ -static const unsigned char bmp_32bpp_xrgb[] = -{ - 0x42,0x4d,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, - 0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00, - 0x00,0x00,0x10,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb0,0xc0,0x00,0xa1,0xb1,0xc1,0x00,0xa2,0xb2, - 0xc2,0x00,0xa3,0xb3,0xc3,0x00 -}; - -/* 2x2 bmp (32 bpp ARGB) */ -static const unsigned char bmp_32bpp_argb[] = -{ - 0x42,0x4d,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, - 0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00, - 0x00,0x00,0x10,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb0,0xc0,0x00,0xa1,0xb1,0xc1,0x00,0xa2,0xb2, - 0xc2,0x00,0xa3,0xb3,0xc3,0x01 -}; - -static const unsigned char png_grayscale[] = -{ - 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, - 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x3a, 0x7e, 0x9b, 0x55, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, - 0x41, 0x54, 0x08, 0xd7, 0x63, 0xf8, 0x0f, 0x00, 0x01, 0x01, 0x01, 0x00, 0x1b, - 0xb6, 0xee, 0x56, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, - 0x60, 0x82 -}; - -/* 2x2 A8R8G8B8 pixel data */ -static const unsigned char pixdata[] = { -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff -}; - -/* invalid image file */ -static const unsigned char noimage[4] = { -0x11,0x22,0x33,0x44 -}; - -/* 16x4 8-bit dds */ -static const unsigned char dds_8bit[] = -{ - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x04,0x00,0x00,0x00, - 0x10,0x00,0x00,0x00,0x10,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, - 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0x8c,0xcd,0x12,0xff, - 0x78,0x01,0x14,0xff,0x50,0xcd,0x12,0xff,0x00,0x3d,0x8c,0xff,0x02,0x00,0x00,0xff, - 0x47,0x00,0x00,0xff,0xda,0x07,0x02,0xff,0x50,0xce,0x12,0xff,0xea,0x11,0x01,0xff, - 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x08,0x3d,0x8c,0xff,0x08,0x01,0x00,0xff, - 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x60,0xcc,0x12,0xff, - 0xa1,0xb2,0xd4,0xff,0xda,0x07,0x02,0xff,0x47,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x50,0xce,0x12,0xff,0x00,0x00,0x14,0xff,0xa8,0xcc,0x12,0xff,0x3c,0xb2,0xd4,0xff, - 0xda,0x07,0x02,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0xff, - 0x21,0x00,0x00,0xff,0xd8,0xcb,0x12,0xff,0x54,0xcd,0x12,0xff,0x8b,0x4f,0xd5,0xff, - 0x00,0x04,0xda,0xff,0x00,0x00,0x00,0xff,0x3d,0x04,0x91,0xff,0x70,0xce,0x18,0xff, - 0xb4,0xcc,0x12,0xff,0x6b,0x4e,0xd5,0xff,0xb0,0xcc,0x12,0xff,0x00,0x00,0x00,0xff, - 0xc8,0x05,0x91,0xff,0x98,0xc7,0xcc,0xff,0x7c,0xcd,0x12,0xff,0x51,0x05,0x91,0xff, - 0x48,0x07,0x14,0xff,0x6d,0x05,0x91,0xff,0x00,0x07,0xda,0xff,0xa0,0xc7,0xcc,0xff, - 0x00,0x07,0xda,0xff,0x3a,0x77,0xd5,0xff,0xda,0x07,0x02,0xff,0x7c,0x94,0xd4,0xff, - 0xe0,0xce,0xd6,0xff,0x0a,0x80,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x78,0x9a,0xab,0xff,0xde,0x08,0x18,0xff,0xda,0x07,0x02,0xff,0x30,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x50,0xce,0x12,0xff,0x8c,0xcd,0x12,0xff,0xd0,0xb7,0xd8,0xff, - 0x00,0x00,0x00,0xff,0x60,0x32,0xd9,0xff,0x30,0xc1,0x1a,0xff,0xa8,0xcd,0x12,0xff, - 0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff,0x46,0x71,0x0e,0xff,0xc0,0x1d,0x4b,0xff, - 0x09,0x87,0xd4,0xff,0x00,0x00,0x00,0xff,0xf6,0x22,0x00,0xff,0x64,0xcd,0x12,0xff, - 0x00,0x00,0x00,0xff,0xca,0x1d,0x4b,0xff,0x09,0x87,0xd4,0xff,0xaa,0x02,0x05,0xff, - 0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0xc0,0x1d,0x4b,0xff, - 0xcd,0xab,0xba,0xff,0x00,0x00,0x00,0xff,0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff, - 0xd4,0xcd,0x12,0xff,0xa6,0x4c,0xd5,0xff,0x00,0xf0,0xfd,0xff,0xd4,0xcd,0x12,0xff, - 0xf4,0x4c,0xd5,0xff,0x90,0xcd,0x12,0xff,0xc2,0x4c,0xd5,0xff,0x82,0x00,0x00,0xff, - 0xaa,0x02,0x05,0xff,0x88,0xd4,0xba,0xff,0x14,0x00,0x00,0xff,0x01,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x0c,0x08,0x13,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0xd0,0xcd,0x12,0xff,0xc6,0x84,0xf1,0xff,0x7c,0x84,0xf1,0xff,0x20,0x20,0xf5,0xff, - 0x00,0x00,0x0a,0xff,0xf0,0xb0,0x94,0xff,0x64,0x6c,0xf1,0xff,0x85,0x6c,0xf1,0xff, - 0x8b,0x4f,0xd5,0xff,0x00,0x04,0xda,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff, - 0x39,0xde,0xd4,0xff,0x10,0x50,0xd5,0xff,0xaa,0x02,0x05,0xff,0x00,0x00,0x00,0xff, - 0x4f,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff,0x00,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff, - 0xaa,0x02,0x05,0xff,0x4c,0xce,0x12,0xff,0x39,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff, - 0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5b,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x68,0x50,0xcd,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0xe3,0xea,0x90,0xff,0x5c,0xce,0x12,0xff, - 0x18,0x00,0x00,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 -}; - -/* 2x2 24-bit dds, 2 mipmaps */ -static const unsigned char dds_24bit[] = { -0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x02,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,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,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, -0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, -0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff -}; - -/* 2x2 16-bit dds, no mipmaps */ -static const unsigned char dds_16bit[] = { -0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x08,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,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, -0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x7c,0x00,0x00, -0xe0,0x03,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f -}; - -/* 4x4 cube map dds */ -static const unsigned char dds_cube_map[] = { -0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x04,0x00,0x00,0x00, -0x04,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,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, -0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, -0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50 -}; - -/* 4x4x2 volume map dds, 2 mipmaps */ -static const unsigned char dds_volume_map[] = { -0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00, -0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,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,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, -0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, -0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c, -0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab -}; - -/* 4x2 dxt5 */ -static const BYTE dds_dxt5[] = -{ - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,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,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -}; - -/* 8x8 dxt5 */ -static const BYTE dds_dxt5_8_8[] = -{ - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x08,0x00,0x00,0x00, - 0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,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,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0xe0,0x07,0x05,0x05,0x50,0x50, - 0x3f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x07,0x05,0x05,0x50,0x50, - 0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xf8,0xe0,0xff,0x05,0x05,0x50,0x50, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x05,0x05,0x50,0x50, -}; - -/* - * 8x8 dxt5 image data, four 4x4 blocks: - * +-----+-----+ - * |Blue |Green| - * | | | - * +-----+-----+ - * |Red |Black| - * | | | - * +-----+-----+ - */ -static const BYTE dxt5_8_8[] = -{ - 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x1f,0x00,0x00,0x00,0x00,0x00, - 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x07,0xe0,0x07,0x00,0x00,0x00,0x00, - 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00,0x00, - 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -}; - struct surface_readback { IDirect3DSurface9 *surface; diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index 4da8f56f834..f32aa4eaad9 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -25,194 +25,10 @@ #include "d3dx9tex.h" #include "resources.h" #include <stdint.h> +#include "d3dx9_test_images.h"
static int has_2d_dxt1, has_2d_dxt3, has_2d_dxt5, has_cube_dxt5, has_3d_dxt3;
-/* 2x2 16-bit dds, no mipmaps */ -static const unsigned char dds_16bit[] = { -0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x08,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,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, -0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x7c,0x00,0x00, -0xe0,0x03,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f -}; - -/* 2x2 24-bit dds, 2 mipmaps */ -static const unsigned char dds_24bit[] = { -0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x02,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,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,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, -0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, -0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff -}; - -/* 4x4 cube map dds */ -static const unsigned char dds_cube_map[] = { -0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x04,0x00,0x00,0x00, -0x04,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,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, -0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, -0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x51, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x52, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x53, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x54, -0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x55 -}; - -/* 4x4x2 volume map dds, 2 mipmaps */ -static const unsigned char dds_volume_map[] = { -0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00, -0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,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,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, -0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, -0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c, -0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab -}; - -/* 4x2 dxt5 */ -static const BYTE dds_dxt5[] = -{ - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,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,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, -}; - -static const BYTE dds_dxt5_8_8[] = -{ - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x08,0x00,0x00,0x00, - 0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,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,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0xe0,0x07,0x05,0x05,0x50,0x50, - 0x3f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x07,0x05,0x05,0x50,0x50, - 0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xf8,0xe0,0xff,0x05,0x05,0x50,0x50, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x05,0x05,0x50,0x50, -}; - -static const unsigned char png_grayscale[] = -{ - 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, - 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x3a, 0x7e, 0x9b, 0x55, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, - 0x41, 0x54, 0x08, 0xd7, 0x63, 0xf8, 0x0f, 0x00, 0x01, 0x01, 0x01, 0x00, 0x1b, - 0xb6, 0xee, 0x56, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, - 0x60, 0x82 -}; - -/* - * 4x4x4 24-bit volume dds, 3 mipmaps. Level 0 is red, level 1 is green, level 2 is - * blue. - */ -static const BYTE dds_volume_24bit_4_4_4[] = -{ - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x82,0x00,0x04,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,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,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, - 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, - 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, - 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, - 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, - 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00 -}; - -/* - * 4x4x4 DXT3 volume dds. 3 mipmaps. Level 0 is red, level 1 is green, level 2 is - * blue. - */ -static const BYTE dds_volume_dxt3_4_4_4[] = -{ - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x04,0x00,0x00,0x00,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,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, - 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x07,0xe0,0x07,0xaa,0xaa,0xaa,0xaa, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x07,0xe0,0x07,0xaa,0xaa,0xaa,0xaa, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x1f,0x00,0xaa,0xaa,0xaa,0xaa, -}; - -/* - * 8x8 24-bit dds, 4 mipmaps. Level 0 is red, level 1 is green, level 2 is - * blue, and level 3 is black. - */ -static const BYTE dds_24bit_8_8[] = -{ - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x08,0x00,0x00,0x00, - 0x08,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,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,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, - 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, - 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, - 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, - 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, - 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, - 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00 -}; - #define ADMITTED_ERROR 0.0001f
static inline float relative_error(float expected, float got) diff --git a/dlls/d3dx9_36/tests/volume.c b/dlls/d3dx9_36/tests/volume.c index f990221f06b..0c101157d30 100644 --- a/dlls/d3dx9_36/tests/volume.c +++ b/dlls/d3dx9_36/tests/volume.c @@ -21,23 +21,7 @@ #define COBJMACROS #include "wine/test.h" #include "d3dx9tex.h" - -/* 4x4x2 volume map dds, 2 mipmaps */ -static const unsigned char dds_volume_map[] = -{ - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,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,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, - 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, - 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c, - 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab -}; +#include "d3dx9_test_images.h"
#define check_pixel_4bpp(box, x, y, z, color) _check_pixel_4bpp(__LINE__, box, x, y, z, color) static inline void _check_pixel_4bpp(unsigned int line, const D3DLOCKED_BOX *box, int x, int y, int z, DWORD expected_color)
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/d3dx9_test_images.h | 56 +++++++- dlls/d3dx9_36/tests/texture.c | 31 ----- dlls/d3dx9_36/tests/volume.c | 175 ++++++++++++++++++++++++ 3 files changed, 230 insertions(+), 32 deletions(-)
diff --git a/dlls/d3dx9_36/tests/d3dx9_test_images.h b/dlls/d3dx9_36/tests/d3dx9_test_images.h index ca20ed6954d..1034700c22e 100644 --- a/dlls/d3dx9_36/tests/d3dx9_test_images.h +++ b/dlls/d3dx9_36/tests/d3dx9_test_images.h @@ -1,5 +1,6 @@ /* - * Test images used across the surface, texture and volume test files. + * Test images and functions used across the surface, texture and volume + * test files. * * Copyright 2024 Connor McAdams for CodeWeavers * @@ -80,6 +81,28 @@ static const uint8_t bmp_32bpp_argb[] = 0xc2,0x00,0xa3,0xb3,0xc3,0x01 };
+/* + * 4x4 bmp (32 bpp ARGB) four 2x2 blocks: + * +-----+-----+ + * |Red |Green| + * | | | + * +-----+-----+ + * |Blue |Black| + * | | | + * +-----+-----+ + */ +static const uint8_t bmp_32bpp_4_4_argb[] = +{ + 0x42,0x4d,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, + 0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00, + 0x00,0x00,0x40,0x00,0x00,0x00,0x24,0x16,0x00,0x00,0x24,0x16,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0x00,0x00, + 0x00,0xff,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0x00,0x00, + 0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0xff, + 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0xff, + 0x00,0xff,0x00,0xff,0x00,0xff, +}; + static const uint8_t png_grayscale[] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, @@ -379,3 +402,34 @@ static const uint8_t dds_24bit_8_8[] = 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00 }; + +#define check_image_info(info, width, height, depth, mip_levels, format, resource_type, image_file_format, wine_todo) \ + check_image_info_(__FILE__, __LINE__, info, width, height, depth, mip_levels, format, resource_type, \ + image_file_format, wine_todo) +static inline void check_image_info_(const char *file, uint32_t line, const D3DXIMAGE_INFO *info, uint32_t width, + uint32_t height, uint32_t depth, uint32_t mip_levels, D3DFORMAT format, D3DRESOURCETYPE resource_type, + D3DXIMAGE_FILEFORMAT image_file_format, BOOL wine_todo) +{ + const D3DXIMAGE_INFO expected_info = { width, height, depth, mip_levels, format, resource_type, image_file_format }; + BOOL matched; + + matched = !memcmp(&expected_info, info, sizeof(*info)); + todo_wine_if(wine_todo) ok_(file, line)(matched, "Got unexpected image info values.\n"); + if (matched) + return; + + todo_wine_if(wine_todo && info->Width != width) + ok_(file, line)(info->Width == width, "Expected width %u, got %u.\n", width, info->Width); + todo_wine_if(wine_todo && info->Height != height) + ok_(file, line)(info->Height == height, "Expected height %u, got %u.\n", height, info->Height); + todo_wine_if(wine_todo && info->Depth != depth) + ok_(file, line)(info->Depth == depth, "Expected depth %u, got %u.\n", depth, info->Depth); + todo_wine_if(wine_todo && info->MipLevels != mip_levels) + ok_(file, line)(info->MipLevels == mip_levels, "Expected mip_levels %u, got %u.\n", mip_levels, + info->MipLevels); + ok_(file, line)(info->Format == format, "Expected texture format %d, got %d.\n", format, info->Format); + ok_(file, line)(info->ResourceType == resource_type, "Expected resource_type %d, got %d.\n", resource_type, + info->ResourceType); + ok_(file, line)(info->ImageFileFormat == image_file_format, "Expected image_file_format %d, got %d.\n", + image_file_format, info->ImageFileFormat); +} diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index f32aa4eaad9..847d55bafea 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -48,37 +48,6 @@ static inline void expect_vec4_(unsigned int line, const D3DXVECTOR4 *expected, got->x, got->y, got->z, got->w); }
-#define check_image_info(info, width, height, depth, mip_levels, format, resource_type, image_file_format, wine_todo) \ - check_image_info_(__LINE__, info, width, height, depth, mip_levels, format, resource_type, image_file_format, \ - wine_todo) -static inline void check_image_info_(uint32_t line, const D3DXIMAGE_INFO *info, uint32_t width, uint32_t height, - uint32_t depth, uint32_t mip_levels, D3DFORMAT format, D3DRESOURCETYPE resource_type, - D3DXIMAGE_FILEFORMAT image_file_format, BOOL wine_todo) -{ - const D3DXIMAGE_INFO expected_info = { width, height, depth, mip_levels, format, resource_type, image_file_format }; - BOOL matched; - - matched = !memcmp(&expected_info, info, sizeof(*info)); - todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected image info values.\n"); - if (matched) - return; - - todo_wine_if(wine_todo && info->Width != width) - ok_(__FILE__, line)(info->Width == width, "Expected width %u, got %u.\n", width, info->Width); - todo_wine_if(wine_todo && info->Height != height) - ok_(__FILE__, line)(info->Height == height, "Expected height %u, got %u.\n", height, info->Height); - todo_wine_if(wine_todo && info->Depth != depth) - ok_(__FILE__, line)(info->Depth == depth, "Expected depth %u, got %u.\n", depth, info->Depth); - todo_wine_if(wine_todo && info->MipLevels != mip_levels) - ok_(__FILE__, line)(info->MipLevels == mip_levels, "Expected mip_levels %u, got %u.\n", mip_levels, - info->MipLevels); - ok_(__FILE__, line)(info->Format == format, "Expected texture format %d, got %d.\n", format, info->Format); - ok_(__FILE__, line)(info->ResourceType == resource_type, "Expected resource_type %d, got %d.\n", resource_type, - info->ResourceType); - ok_(__FILE__, line)(info->ImageFileFormat == image_file_format, "Expected image_file_format %d, got %d.\n", - image_file_format, info->ImageFileFormat); -} - #define check_texture_level_desc(tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, width, \ height, wine_todo) \ check_texture_level_desc_(__LINE__, tex, level, format, usage, pool, multi_sample_type, multi_sample_quality, \ diff --git a/dlls/d3dx9_36/tests/volume.c b/dlls/d3dx9_36/tests/volume.c index 0c101157d30..83d832b08c7 100644 --- a/dlls/d3dx9_36/tests/volume.c +++ b/dlls/d3dx9_36/tests/volume.c @@ -23,6 +23,106 @@ #include "d3dx9tex.h" #include "d3dx9_test_images.h"
+struct volume_readback +{ + IDirect3DVolume9 *volume; + D3DLOCKED_BOX locked_box; +}; + +static inline uint32_t get_volume_readback_color(struct volume_readback *rb, uint32_t x, uint32_t y, uint32_t z) +{ + const uint32_t *pixels = rb->locked_box.pBits; + const D3DLOCKED_BOX *box = &rb->locked_box; + + if (!box->pBits) + return 0xdeadbeef; + return pixels[(z * (box->SlicePitch / sizeof(uint32_t)) + (y * (box->RowPitch / sizeof(uint32_t))) + x)]; +} + +#define release_volume_readback(rb) release_volume_readback_(__FILE__, __LINE__, rb) +static inline void release_volume_readback_(const char *file, uint32_t line, struct volume_readback *rb) +{ + HRESULT hr; + + if (!rb->volume) + return; + if (rb->locked_box.pBits && FAILED(hr = IDirect3DVolume9_UnlockBox(rb->volume))) + trace_(file, line)("Can't unlock the readback volume, hr %#lx.\n", hr); + IDirect3DVolume9_Release(rb->volume); +} + +#define get_texture_volume_readback(device, volume_tex, mip_level, rb) \ + get_texture_volume_readback_(__FILE__, __LINE__, device, volume_tex, mip_level, rb) +static inline void get_texture_volume_readback_(const char *file, uint32_t line, IDirect3DDevice9 *device, + IDirect3DVolumeTexture9 *volume_tex, uint32_t mip_level, struct volume_readback *rb) +{ + IDirect3DVolumeTexture9 *rb_tex; + IDirect3DVolume9 *volume = NULL; + D3DVOLUME_DESC desc; + HRESULT hr; + + memset(rb, 0, sizeof(*rb)); + hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_tex, mip_level, &desc); + if (FAILED(hr)) + { + trace_(file, line)("Failed to get volume description for mip level %d, hr %#lx.\n", mip_level, hr); + return; + } + + hr = IDirect3DDevice9_CreateVolumeTexture(device, desc.Width, desc.Height, desc.Depth, 1, 0, D3DFMT_A8R8G8B8, + D3DPOOL_SYSTEMMEM, &rb_tex, NULL); + if (FAILED(hr)) + { + trace_(file, line)("Can't create the readback volume texture, hr %#lx.\n", hr); + return; + } + + hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_tex, mip_level, &volume); + if (FAILED(hr)) + { + trace_(file, line)("Failed to get the volume for mip_level %d, hr %#lx.\n", mip_level, hr); + goto exit; + } + + hr = IDirect3DVolumeTexture9_GetVolumeLevel(rb_tex, 0, &rb->volume); + if (FAILED(hr)) + { + trace_(file, line)("Failed to get readback volume, hr %#lx.\n", hr); + goto exit; + } + + hr = D3DXLoadVolumeFromVolume(rb->volume, NULL, NULL, volume, NULL, NULL, D3DX_FILTER_NONE, 0); + if (FAILED(hr)) + { + trace_(file, line)("Can't load the source volume into the readback, hr %#lx.\n", hr); + goto exit; + } + + hr = IDirect3DVolume9_LockBox(rb->volume, &rb->locked_box, NULL, D3DLOCK_READONLY); + if (FAILED(hr)) + trace_(file, line)("Can't lock the readback volume, hr %#lx.\n", hr); + +exit: + IDirect3DVolumeTexture9_Release(rb_tex); + if (volume) + IDirect3DVolume9_Release(volume); + if (FAILED(hr)) + { + if (rb->volume) + IDirect3DVolume9_Release(rb->volume); + rb->volume = NULL; + } +} + +#define check_volume_readback_pixel_4bpp(rb, x, y, z, color, todo) \ + _check_volume_readback_pixel_4bpp(__FILE__, __LINE__, rb, x, y, z, color, todo) +static inline void _check_volume_readback_pixel_4bpp(const char *file, uint32_t line, struct volume_readback *rb, + uint32_t x, uint32_t y, uint32_t z, uint32_t expected_color, BOOL todo) +{ + uint32_t color = get_volume_readback_color(rb, x, y, z); + todo_wine_if(todo) ok_(file, line)(color == expected_color, "Got color 0x%08x, expected 0x%08x.\n", color, expected_color); +} + #define check_pixel_4bpp(box, x, y, z, color) _check_pixel_4bpp(__LINE__, box, x, y, z, color) static inline void _check_pixel_4bpp(unsigned int line, const D3DLOCKED_BOX *box, int x, int y, int z, DWORD expected_color) { @@ -199,8 +299,16 @@ static void test_D3DXLoadVolumeFromFileInMemory(IDirect3DDevice9 *device) { HRESULT hr; D3DBOX src_box; + uint32_t x, y, z; + D3DVOLUME_DESC desc; + D3DXIMAGE_INFO img_info; IDirect3DVolume9 *volume; + struct volume_readback volume_rb; IDirect3DVolumeTexture9 *volume_texture; + static const uint32_t bmp_32bpp_4_4_argb_expected[] = + { + 0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000, + };
hr = IDirect3DDevice9_CreateVolumeTexture(device, 4, 4, 2, 1, D3DUSAGE_DYNAMIC, D3DFMT_DXT3, D3DPOOL_DEFAULT, &volume_texture, NULL); @@ -245,6 +353,73 @@ static void test_D3DXLoadVolumeFromFileInMemory(IDirect3DDevice9 *device)
IDirect3DVolume9_Release(volume); IDirect3DVolumeTexture9_Release(volume_texture); + + /* Load 2D DDS image into a volume. */ + hr = IDirect3DDevice9_CreateVolumeTexture(device, 8, 8, 8, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, + &volume_texture, NULL); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + + IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, 0, &volume); + hr = D3DXLoadVolumeFromFileInMemory(volume, NULL, NULL, dds_24bit_8_8, sizeof(dds_24bit_8_8), NULL, + D3DX_FILTER_POINT, 0, &img_info); + todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE); + + IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); + get_texture_volume_readback(device, volume_texture, 0, &volume_rb); + for (z = 0; z < desc.Depth; ++z) + { + for (y = 0; y < desc.Height; ++y) + { + for (x = 0; x < desc.Width; ++x) + { + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, 0xffff0000, FALSE); + } + } + } + release_volume_readback(&volume_rb); + } + + IDirect3DVolume9_Release(volume); + IDirect3DVolumeTexture9_Release(volume_texture); + + /* Load a BMP image into a volume. */ + hr = IDirect3DDevice9_CreateVolumeTexture(device, 4, 4, 4, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, + &volume_texture, NULL); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + + IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, 0, &volume); + hr = D3DXLoadVolumeFromFileInMemory(volume, NULL, NULL, bmp_32bpp_4_4_argb, sizeof(bmp_32bpp_4_4_argb), NULL, + D3DX_FILTER_POINT, 0, &img_info); + todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE); + + IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); + get_texture_volume_readback(device, volume_texture, 0, &volume_rb); + for (z = 0; z < desc.Depth; ++z) + { + for (y = 0; y < desc.Height; ++y) + { + const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2]; + + for (x = 0; x < desc.Width; ++x) + { + if (x < (desc.Width / 2)) + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE); + else + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE); + } + } + } + release_volume_readback(&volume_rb); + } + + IDirect3DVolume9_Release(volume); + IDirect3DVolumeTexture9_Release(volume_texture); }
START_TEST(volume)
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/d3dx9_private.h | 3 -- dlls/d3dx9_36/surface.c | 18 ----------- dlls/d3dx9_36/tests/volume.c | 56 ++++++++++++++++------------------- dlls/d3dx9_36/volume.c | 38 +++++++++++------------- 4 files changed, 42 insertions(+), 73 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 701afffd046..26e4a1560d6 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -174,9 +174,6 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info); -HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, - const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, - const D3DXIMAGE_INFO *src_info); HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info); HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock, diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 3e0b880eec4..a97112a3562 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -566,24 +566,6 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur return D3D_OK; }
-HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, - const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, - const D3DXIMAGE_INFO *src_info) -{ - UINT row_pitch, slice_pitch; - const struct dds_header *header = src_data; - const BYTE *pixels = (BYTE *)(header + 1); - - if (src_info->ResourceType != D3DRTYPE_VOLUMETEXTURE) - return D3DXERR_INVALIDDATA; - - if (FAILED(d3dx_calculate_pixels_size(src_info->Format, src_info->Width, src_info->Height, &row_pitch, &slice_pitch))) - return E_NOTIMPL; - - return D3DXLoadVolumeFromMemory(dst_volume, dst_palette, dst_box, pixels, src_info->Format, - row_pitch, slice_pitch, NULL, src_box, filter, color_key); -} - HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) { diff --git a/dlls/d3dx9_36/tests/volume.c b/dlls/d3dx9_36/tests/volume.c index 83d832b08c7..9ffc487078c 100644 --- a/dlls/d3dx9_36/tests/volume.c +++ b/dlls/d3dx9_36/tests/volume.c @@ -362,25 +362,22 @@ static void test_D3DXLoadVolumeFromFileInMemory(IDirect3DDevice9 *device) IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, 0, &volume); hr = D3DXLoadVolumeFromFileInMemory(volume, NULL, NULL, dds_24bit_8_8, sizeof(dds_24bit_8_8), NULL, D3DX_FILTER_POINT, 0, &img_info); - todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { - check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE);
- IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); - get_texture_volume_readback(device, volume_texture, 0, &volume_rb); - for (z = 0; z < desc.Depth; ++z) + IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); + get_texture_volume_readback(device, volume_texture, 0, &volume_rb); + for (z = 0; z < desc.Depth; ++z) + { + for (y = 0; y < desc.Height; ++y) { - for (y = 0; y < desc.Height; ++y) + for (x = 0; x < desc.Width; ++x) { - for (x = 0; x < desc.Width; ++x) - { - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, 0xffff0000, FALSE); - } + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, 0xffff0000, FALSE); } } - release_volume_readback(&volume_rb); } + release_volume_readback(&volume_rb);
IDirect3DVolume9_Release(volume); IDirect3DVolumeTexture9_Release(volume_texture); @@ -393,30 +390,27 @@ static void test_D3DXLoadVolumeFromFileInMemory(IDirect3DDevice9 *device) IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, 0, &volume); hr = D3DXLoadVolumeFromFileInMemory(volume, NULL, NULL, bmp_32bpp_4_4_argb, sizeof(bmp_32bpp_4_4_argb), NULL, D3DX_FILTER_POINT, 0, &img_info); - todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { - check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE);
- IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); - get_texture_volume_readback(device, volume_texture, 0, &volume_rb); - for (z = 0; z < desc.Depth; ++z) + IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &desc); + get_texture_volume_readback(device, volume_texture, 0, &volume_rb); + for (z = 0; z < desc.Depth; ++z) + { + for (y = 0; y < desc.Height; ++y) { - for (y = 0; y < desc.Height; ++y) + const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2]; + + for (x = 0; x < desc.Width; ++x) { - const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2]; - - for (x = 0; x < desc.Width; ++x) - { - if (x < (desc.Width / 2)) - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE); - else - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE); - } + if (x < (desc.Width / 2)) + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE); + else + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE); } } - release_volume_readback(&volume_rb); } + release_volume_readback(&volume_rb);
IDirect3DVolume9_Release(volume); IDirect3DVolumeTexture9_Release(volume_texture); diff --git a/dlls/d3dx9_36/volume.c b/dlls/d3dx9_36/volume.c index 0006a521532..10073fb31e0 100644 --- a/dlls/d3dx9_36/volume.c +++ b/dlls/d3dx9_36/volume.c @@ -168,6 +168,8 @@ HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume, cons { HRESULT hr; D3DBOX box; + struct d3dx_image image; + struct d3dx_pixels pixels; D3DXIMAGE_INFO image_info;
TRACE("dst_volume %p, dst_palette %p, dst_box %p, src_data %p, src_data_size %u, src_box %p, " @@ -175,12 +177,14 @@ HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume, cons dst_volume, dst_palette, dst_box, src_data, src_data_size, src_box, filter, color_key, src_info);
- if (!dst_volume || !src_data) + if (!dst_volume || !src_data || !src_data_size) return D3DERR_INVALIDCALL;
- if (FAILED(hr = D3DXGetImageInfoFromFileInMemory(src_data, src_data_size, &image_info))) - return hr; + hr = d3dx_image_init(src_data, src_data_size, &image, 0, 0); + if (FAILED(hr)) + return D3DXERR_INVALIDDATA;
+ d3dximage_info_from_d3dx_image(&image_info, &image); if (src_box) { if (src_box->Right > image_info.Width @@ -192,29 +196,21 @@ HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume, cons } else { - box.Left = 0; - box.Top = 0; - box.Right = image_info.Width; - box.Bottom = image_info.Height; - box.Front = 0; - box.Back = image_info.Depth; - + set_d3dbox(&box, 0, 0, image_info.Width, image_info.Height, 0, image_info.Depth); }
- if (image_info.ImageFileFormat != D3DXIFF_DDS) - { - FIXME("File format %#x is not supported yet\n", image_info.ImageFileFormat); - return E_NOTIMPL; - } - - hr = load_volume_from_dds(dst_volume, dst_palette, dst_box, src_data, &box, - filter, color_key, &image_info); - if (FAILED(hr)) return hr; + hr = d3dx_image_get_pixels(&image, 0, &pixels); + if (FAILED(hr)) + goto exit;
- if (src_info) + hr = D3DXLoadVolumeFromMemory(dst_volume, dst_palette, dst_box, pixels.data, image_info.Format, + pixels.row_pitch, pixels.slice_pitch, pixels.palette, &box, filter, color_key); + if (SUCCEEDED(hr) && src_info) *src_info = image_info;
- return D3D_OK; +exit: + d3dx_image_cleanup(&image); + return FAILED(hr) ? hr : D3D_OK; }
HRESULT WINAPI D3DXLoadVolumeFromVolume(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette,
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/d3dx9_test_images.h | 102 ++++++++++++++ dlls/d3dx9_36/tests/texture.c | 170 +++++++++++++++++++++++- dlls/d3dx9_36/tests/volume.c | 100 -------------- 3 files changed, 271 insertions(+), 101 deletions(-)
diff --git a/dlls/d3dx9_36/tests/d3dx9_test_images.h b/dlls/d3dx9_36/tests/d3dx9_test_images.h index 1034700c22e..f1e8ffb94bf 100644 --- a/dlls/d3dx9_36/tests/d3dx9_test_images.h +++ b/dlls/d3dx9_36/tests/d3dx9_test_images.h @@ -20,6 +20,8 @@ */
#include <stdint.h> +#define COBJMACROS +#include "d3dx9tex.h"
/* 1x1 bmp (1 bpp) */ static const uint8_t bmp_1bpp[] = @@ -433,3 +435,103 @@ static inline void check_image_info_(const char *file, uint32_t line, const D3DX ok_(file, line)(info->ImageFileFormat == image_file_format, "Expected image_file_format %d, got %d.\n", image_file_format, info->ImageFileFormat); } + +struct volume_readback +{ + IDirect3DVolume9 *volume; + D3DLOCKED_BOX locked_box; +}; + +static inline uint32_t get_volume_readback_color(struct volume_readback *rb, uint32_t x, uint32_t y, uint32_t z) +{ + const uint32_t *pixels = rb->locked_box.pBits; + const D3DLOCKED_BOX *box = &rb->locked_box; + + if (!box->pBits) + return 0xdeadbeef; + return pixels[(z * (box->SlicePitch / sizeof(uint32_t)) + (y * (box->RowPitch / sizeof(uint32_t))) + x)]; +} + +#define release_volume_readback(rb) release_volume_readback_(__FILE__, __LINE__, rb) +static inline void release_volume_readback_(const char *file, uint32_t line, struct volume_readback *rb) +{ + HRESULT hr; + + if (!rb->volume) + return; + if (rb->locked_box.pBits && FAILED(hr = IDirect3DVolume9_UnlockBox(rb->volume))) + trace_(file, line)("Can't unlock the readback volume, hr %#lx.\n", hr); + IDirect3DVolume9_Release(rb->volume); +} + +#define get_texture_volume_readback(device, volume_tex, mip_level, rb) \ + get_texture_volume_readback_(__FILE__, __LINE__, device, volume_tex, mip_level, rb) +static inline void get_texture_volume_readback_(const char *file, uint32_t line, IDirect3DDevice9 *device, + IDirect3DVolumeTexture9 *volume_tex, uint32_t mip_level, struct volume_readback *rb) +{ + IDirect3DVolumeTexture9 *rb_tex; + IDirect3DVolume9 *volume = NULL; + D3DVOLUME_DESC desc; + HRESULT hr; + + memset(rb, 0, sizeof(*rb)); + hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_tex, mip_level, &desc); + if (FAILED(hr)) + { + trace_(file, line)("Failed to get volume description for mip level %d, hr %#lx.\n", mip_level, hr); + return; + } + + hr = IDirect3DDevice9_CreateVolumeTexture(device, desc.Width, desc.Height, desc.Depth, 1, 0, D3DFMT_A8R8G8B8, + D3DPOOL_SYSTEMMEM, &rb_tex, NULL); + if (FAILED(hr)) + { + trace_(file, line)("Can't create the readback volume texture, hr %#lx.\n", hr); + return; + } + + hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_tex, mip_level, &volume); + if (FAILED(hr)) + { + trace_(file, line)("Failed to get the volume for mip_level %d, hr %#lx.\n", mip_level, hr); + goto exit; + } + + hr = IDirect3DVolumeTexture9_GetVolumeLevel(rb_tex, 0, &rb->volume); + if (FAILED(hr)) + { + trace_(file, line)("Failed to get readback volume, hr %#lx.\n", hr); + goto exit; + } + + hr = D3DXLoadVolumeFromVolume(rb->volume, NULL, NULL, volume, NULL, NULL, D3DX_FILTER_NONE, 0); + if (FAILED(hr)) + { + trace_(file, line)("Can't load the source volume into the readback, hr %#lx.\n", hr); + goto exit; + } + + hr = IDirect3DVolume9_LockBox(rb->volume, &rb->locked_box, NULL, D3DLOCK_READONLY); + if (FAILED(hr)) + trace_(file, line)("Can't lock the readback volume, hr %#lx.\n", hr); + +exit: + IDirect3DVolumeTexture9_Release(rb_tex); + if (volume) + IDirect3DVolume9_Release(volume); + if (FAILED(hr)) + { + if (rb->volume) + IDirect3DVolume9_Release(rb->volume); + rb->volume = NULL; + } +} + +#define check_volume_readback_pixel_4bpp(rb, x, y, z, color, todo) \ + _check_volume_readback_pixel_4bpp(__FILE__, __LINE__, rb, x, y, z, color, todo) +static inline void _check_volume_readback_pixel_4bpp(const char *file, uint32_t line, struct volume_readback *rb, + uint32_t x, uint32_t y, uint32_t z, uint32_t expected_color, BOOL todo) +{ + uint32_t color = get_volume_readback_color(rb, x, y, z); + todo_wine_if(todo) ok_(file, line)(color == expected_color, "Got color 0x%08x, expected 0x%08x.\n", color, expected_color); +} diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index 847d55bafea..4787bb6ada4 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -92,6 +92,42 @@ static inline void check_texture_level_desc_(uint32_t line, IDirect3DTexture9 *t ok_(__FILE__, line)(desc.Height == height, "Expected height %u, got %u.\n", height, desc.Height); }
+#define check_volume_texture_level_desc(tex, level, format, usage, pool, width, height, depth, wine_todo) \ + check_volume_texture_level_desc_(__LINE__, tex, level, format, usage, pool, width, height, depth, wine_todo) +static inline void check_volume_texture_level_desc_(uint32_t line, IDirect3DVolumeTexture9 *tex, uint32_t level, + D3DFORMAT format, uint32_t usage, D3DPOOL pool, uint32_t width, uint32_t height, uint32_t depth, BOOL wine_todo) +{ + const D3DVOLUME_DESC expected_desc = { format, D3DRTYPE_VOLUME, usage, pool, width, height, depth }; + D3DVOLUME_DESC desc; + BOOL matched; + HRESULT hr; + + hr = IDirect3DVolumeTexture9_GetLevelDesc(tex, level, &desc); + todo_wine_if(wine_todo && FAILED(hr)) + ok_(__FILE__, line)(hr == S_OK, "Failed to get texture level desc with hr %#lx.\n", hr); + if (FAILED(hr)) + return; + + matched = !memcmp(&expected_desc, &desc, sizeof(desc)); + todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected volume desc values.\n"); + if (matched) + return; + + todo_wine_if(wine_todo && desc.Format != format) + ok_(__FILE__, line)(desc.Format == format, "Expected volume format %d, got %d.\n", format, desc.Format); + ok_(__FILE__, line)(desc.Type == D3DRTYPE_VOLUME, "Expected D3DRTYPE_VOLUME, got %d.\n", desc.Type); + todo_wine_if(wine_todo && desc.Usage != usage) + ok_(__FILE__, line)(desc.Usage == usage, "Expected usage %u, got %lu.\n", usage, desc.Usage); + todo_wine_if(wine_todo && desc.Pool != pool) + ok_(__FILE__, line)(desc.Pool == pool, "Expected pool %d, got %d.\n", pool, desc.Pool); + todo_wine_if(wine_todo && desc.Width != width) + ok_(__FILE__, line)(desc.Width == width, "Expected width %u, got %u.\n", width, desc.Width); + todo_wine_if(wine_todo && desc.Height != height) + ok_(__FILE__, line)(desc.Height == height, "Expected height %u, got %u.\n", height, desc.Height); + todo_wine_if(wine_todo && desc.Depth != depth) + ok_(__FILE__, line)(desc.Depth == depth, "Expected depth %u, got %u.\n", depth, desc.Depth); +} + #define check_texture_mip_levels(tex, expected_mip_levels, wine_todo) \ check_texture_mip_levels_(__LINE__, ((IDirect3DBaseTexture9 *)tex), expected_mip_levels, wine_todo) static inline void check_texture_mip_levels_(uint32_t line, IDirect3DBaseTexture9 *tex, uint32_t expected_mip_levels, @@ -2406,7 +2442,23 @@ static void test_D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *devic
static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device) { - IDirect3DVolumeTexture9 *volume_texture; + static const uint32_t dds_volume_dxt3_4_4_4_expected_uncompressed[] = + { + 0xffff0000, 0xff00ff00, 0xff0000ff, + }; + static const uint32_t dds_24bit_8_8_expected[] = + { + 0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000, + }; + static const uint32_t bmp_32bpp_4_4_argb_expected[] = + { + 0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000, + }; + IDirect3DVolumeTexture9 *volume_texture, *texture; + struct volume_readback volume_rb; + uint32_t mip_level, x, y, z; + D3DXIMAGE_INFO img_info; + D3DVOLUME_DESC desc; HRESULT hr;
hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, dds_volume_map, sizeof(dds_volume_map), D3DX_DEFAULT, @@ -2418,6 +2470,122 @@ static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *dev D3DX_DEFAULT, D3DX_DEFAULT, 1, D3DUSAGE_DEPTHSTENCIL, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &volume_texture); ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#lx.\n", hr); + + /* Load a 2D texture DDS file with multiple mips into a volume texture. */ + hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, dds_24bit_8_8, sizeof(dds_24bit_8_8), + D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, + D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture); + todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_texture_mip_levels(texture, 4, FALSE); + check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE); + check_volume_texture_level_desc(texture, 0, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 8, 8, 1, FALSE); + check_volume_texture_level_desc(texture, 1, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 4, 4, 1, FALSE); + check_volume_texture_level_desc(texture, 2, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 1, FALSE); + check_volume_texture_level_desc(texture, 3, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, FALSE); + + for (mip_level = 0; mip_level < 4; ++mip_level) + { + const uint32_t expected_color = dds_24bit_8_8_expected[mip_level]; + uint32_t x, y, z; + + IDirect3DVolumeTexture9_GetLevelDesc(texture, mip_level, &desc); + get_texture_volume_readback(device, texture, mip_level, &volume_rb); + for (z = 0; z < desc.Depth; ++z) + { + for (y = 0; y < desc.Height; ++y) + { + for (x = 0; x < desc.Width; ++x) + { + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color, FALSE); + } + } + } + release_volume_readback(&volume_rb); + } + IDirect3DVolumeTexture9_Release(texture); + } + + /* Multi-mip compressed volume texture file. */ + if (has_3d_dxt3) + { + hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, dds_volume_dxt3_4_4_4, sizeof(dds_volume_dxt3_4_4_4), + D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, + D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + check_texture_mip_levels(texture, 3, FALSE); + check_image_info(&img_info, 4, 4, 4, 3, D3DFMT_DXT3, D3DRTYPE_VOLUMETEXTURE, D3DXIFF_DDS, FALSE); + check_volume_texture_level_desc(texture, 0, D3DFMT_DXT3, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 4, 4, 4, FALSE); + check_volume_texture_level_desc(texture, 1, D3DFMT_DXT3, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 2, FALSE); + check_volume_texture_level_desc(texture, 2, D3DFMT_DXT3, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, FALSE); + + for (mip_level = 0; mip_level < 3; ++mip_level) + { + const uint32_t expected_color = dds_volume_dxt3_4_4_4_expected_uncompressed[mip_level]; + uint32_t x, y, z; + + IDirect3DVolumeTexture9_GetLevelDesc(texture, mip_level, &desc); + get_texture_volume_readback(device, texture, mip_level, &volume_rb); + for (z = 0; z < desc.Depth; ++z) + { + for (y = 0; y < desc.Height; ++y) + { + for (x = 0; x < desc.Width; ++x) + { + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color, FALSE); + } + } + } + release_volume_readback(&volume_rb); + } + IDirect3DVolumeTexture9_Release(texture); + } + else + { + skip("D3DFMT_DXT3 volume textures are not supported, skipping tests.\n"); + } + + /* Load a BMP file into a volume texture. */ + hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, bmp_32bpp_4_4_argb, sizeof(bmp_32bpp_4_4_argb), + D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, + D3DX_DEFAULT, D3DX_FILTER_POINT, 0, &img_info, NULL, &texture); + todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_texture_mip_levels(texture, 3, FALSE); + check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE); + check_volume_texture_level_desc(texture, 0, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 4, 4, 1, FALSE); + check_volume_texture_level_desc(texture, 1, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 1, FALSE); + check_volume_texture_level_desc(texture, 2, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, FALSE); + + /* + * Check that the values actually get set. Only checking 4x4 and 2x2, 1x1 + * will vary based on filter implementation. + */ + for (mip_level = 0; mip_level < 2; ++mip_level) + { + IDirect3DVolumeTexture9_GetLevelDesc(texture, mip_level, &desc); + get_texture_volume_readback(device, texture, mip_level, &volume_rb); + for (z = 0; z < desc.Depth; ++z) + { + for (y = 0; y < desc.Height; ++y) + { + const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2]; + + for (x = 0; x < desc.Width; ++x) + { + if (x < (desc.Width / 2)) + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE); + else + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE); + } + } + } + release_volume_readback(&volume_rb); + } + IDirect3DVolumeTexture9_Release(texture); + } }
/* fills positive x face with red color */ diff --git a/dlls/d3dx9_36/tests/volume.c b/dlls/d3dx9_36/tests/volume.c index 9ffc487078c..c0bad638597 100644 --- a/dlls/d3dx9_36/tests/volume.c +++ b/dlls/d3dx9_36/tests/volume.c @@ -23,106 +23,6 @@ #include "d3dx9tex.h" #include "d3dx9_test_images.h"
-struct volume_readback -{ - IDirect3DVolume9 *volume; - D3DLOCKED_BOX locked_box; -}; - -static inline uint32_t get_volume_readback_color(struct volume_readback *rb, uint32_t x, uint32_t y, uint32_t z) -{ - const uint32_t *pixels = rb->locked_box.pBits; - const D3DLOCKED_BOX *box = &rb->locked_box; - - if (!box->pBits) - return 0xdeadbeef; - return pixels[(z * (box->SlicePitch / sizeof(uint32_t)) + (y * (box->RowPitch / sizeof(uint32_t))) + x)]; -} - -#define release_volume_readback(rb) release_volume_readback_(__FILE__, __LINE__, rb) -static inline void release_volume_readback_(const char *file, uint32_t line, struct volume_readback *rb) -{ - HRESULT hr; - - if (!rb->volume) - return; - if (rb->locked_box.pBits && FAILED(hr = IDirect3DVolume9_UnlockBox(rb->volume))) - trace_(file, line)("Can't unlock the readback volume, hr %#lx.\n", hr); - IDirect3DVolume9_Release(rb->volume); -} - -#define get_texture_volume_readback(device, volume_tex, mip_level, rb) \ - get_texture_volume_readback_(__FILE__, __LINE__, device, volume_tex, mip_level, rb) -static inline void get_texture_volume_readback_(const char *file, uint32_t line, IDirect3DDevice9 *device, - IDirect3DVolumeTexture9 *volume_tex, uint32_t mip_level, struct volume_readback *rb) -{ - IDirect3DVolumeTexture9 *rb_tex; - IDirect3DVolume9 *volume = NULL; - D3DVOLUME_DESC desc; - HRESULT hr; - - memset(rb, 0, sizeof(*rb)); - hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_tex, mip_level, &desc); - if (FAILED(hr)) - { - trace_(file, line)("Failed to get volume description for mip level %d, hr %#lx.\n", mip_level, hr); - return; - } - - hr = IDirect3DDevice9_CreateVolumeTexture(device, desc.Width, desc.Height, desc.Depth, 1, 0, D3DFMT_A8R8G8B8, - D3DPOOL_SYSTEMMEM, &rb_tex, NULL); - if (FAILED(hr)) - { - trace_(file, line)("Can't create the readback volume texture, hr %#lx.\n", hr); - return; - } - - hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_tex, mip_level, &volume); - if (FAILED(hr)) - { - trace_(file, line)("Failed to get the volume for mip_level %d, hr %#lx.\n", mip_level, hr); - goto exit; - } - - hr = IDirect3DVolumeTexture9_GetVolumeLevel(rb_tex, 0, &rb->volume); - if (FAILED(hr)) - { - trace_(file, line)("Failed to get readback volume, hr %#lx.\n", hr); - goto exit; - } - - hr = D3DXLoadVolumeFromVolume(rb->volume, NULL, NULL, volume, NULL, NULL, D3DX_FILTER_NONE, 0); - if (FAILED(hr)) - { - trace_(file, line)("Can't load the source volume into the readback, hr %#lx.\n", hr); - goto exit; - } - - hr = IDirect3DVolume9_LockBox(rb->volume, &rb->locked_box, NULL, D3DLOCK_READONLY); - if (FAILED(hr)) - trace_(file, line)("Can't lock the readback volume, hr %#lx.\n", hr); - -exit: - IDirect3DVolumeTexture9_Release(rb_tex); - if (volume) - IDirect3DVolume9_Release(volume); - if (FAILED(hr)) - { - if (rb->volume) - IDirect3DVolume9_Release(rb->volume); - rb->volume = NULL; - } -} - -#define check_volume_readback_pixel_4bpp(rb, x, y, z, color, todo) \ - _check_volume_readback_pixel_4bpp(__FILE__, __LINE__, rb, x, y, z, color, todo) -static inline void _check_volume_readback_pixel_4bpp(const char *file, uint32_t line, struct volume_readback *rb, - uint32_t x, uint32_t y, uint32_t z, uint32_t expected_color, BOOL todo) -{ - uint32_t color = get_volume_readback_color(rb, x, y, z); - todo_wine_if(todo) ok_(file, line)(color == expected_color, "Got color 0x%08x, expected 0x%08x.\n", color, expected_color); -} - #define check_pixel_4bpp(box, x, y, z, color) _check_pixel_4bpp(__LINE__, box, x, y, z, color) static inline void _check_pixel_4bpp(unsigned int line, const D3DLOCKED_BOX *box, int x, int y, int z, DWORD expected_color) {
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/texture.c | 59 ++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 19 deletions(-)
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 5a68b2dd1c4..f122e62170b 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -1104,7 +1104,7 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic BOOL file_depth = FALSE; BOOL file_format = FALSE; BOOL file_mip_levels = FALSE; - IDirect3DVolumeTexture9 *tex, *buftex; + IDirect3DVolumeTexture9 *tex, *staging_tex;
TRACE("device %p, data %p, data_size %u, width %u, height %u, depth %u, mip_levels %u, " "usage %#lx, format %#x, pool %#x, filter %#lx, mip_filter %#lx, color_key 0x%08lx, " @@ -1115,6 +1115,7 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic if (!device || !data || !data_size || !volume_texture) return D3DERR_INVALIDCALL;
+ staging_tex = tex = *volume_texture = NULL; hr = D3DXGetImageInfoFromFileInMemory(data, data_size, &image_info); if (FAILED(hr)) return hr;
@@ -1170,7 +1171,11 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic }
hr = D3DXCheckVolumeTextureRequirements(device, &width, &height, &depth, &mip_levels, usage, &format, pool); - if (FAILED(hr)) return hr; + if (FAILED(hr)) + { + FIXME("Couldn't find suitable texture parameters.\n"); + goto err; + }
if ((file_width && width != image_info.Width) || (file_height && height != image_info.Height) @@ -1181,7 +1186,10 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps); if (FAILED(hr)) - return D3DERR_INVALIDCALL; + { + hr = D3DERR_INVALIDCALL; + goto err; + }
if (mip_levels > image_info.MipLevels) { @@ -1192,41 +1200,54 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC); if (pool == D3DPOOL_DEFAULT && !dynamic_texture) { - hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, 0, format, D3DPOOL_SYSTEMMEM, &buftex); - tex = buftex; + TRACE("Creating staging texture.\n"); + hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, 0, format, D3DPOOL_SYSTEMMEM, &staging_tex); + tex = staging_tex; } else { hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, usage, format, pool, &tex); - buftex = NULL; } - if (FAILED(hr)) return hr;
+ if (FAILED(hr)) + { + FIXME("Texture creation failed.\n"); + goto err; + } + + TRACE("Texture created correctly. Now loading the texture data into it.\n"); hr = load_volume_texture_from_dds(tex, data, palette, filter, color_key, &image_info); if (FAILED(hr)) { - IDirect3DVolumeTexture9_Release(tex); - return hr; + FIXME("Texture loading failed.\n"); + goto err; }
- if (buftex) + /* Move the data to the actual texture if necessary. */ + if (staging_tex) { - hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, usage, format, pool, &tex); + hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, usage, format, pool, volume_texture); if (FAILED(hr)) - { - IDirect3DVolumeTexture9_Release(buftex); - return hr; - } + goto err;
- IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)buftex, (IDirect3DBaseTexture9 *)tex); - IDirect3DVolumeTexture9_Release(buftex); + IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)staging_tex, (IDirect3DBaseTexture9 *)(*volume_texture)); + IDirect3DVolumeTexture9_Release(staging_tex); + } + else + { + *volume_texture = tex; }
if (info) *info = image_info;
- *volume_texture = tex; - return D3D_OK; + return hr; + +err: + if (tex) + IDirect3DVolumeTexture9_Release(tex); + + return hr; }
static inline void fill_texture(const struct pixel_format_desc *format, BYTE *pos, const D3DXVECTOR4 *value)
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/texture.c | 72 ++++++++--------------------------------- 1 file changed, 14 insertions(+), 58 deletions(-)
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index f122e62170b..4050115c6df 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -1098,13 +1098,8 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic HRESULT hr; D3DCAPS9 caps; D3DXIMAGE_INFO image_info; - BOOL dynamic_texture; - BOOL file_width = FALSE; - BOOL file_height = FALSE; - BOOL file_depth = FALSE; - BOOL file_format = FALSE; - BOOL file_mip_levels = FALSE; IDirect3DVolumeTexture9 *tex, *staging_tex; + BOOL dynamic_texture, format_specified = FALSE;
TRACE("device %p, data %p, data_size %u, width %u, height %u, depth %u, mip_levels %u, " "usage %#lx, format %#x, pool %#x, filter %#lx, mip_filter %#lx, color_key 0x%08lx, " @@ -1122,53 +1117,18 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic if (image_info.ImageFileFormat != D3DXIFF_DDS) return D3DXERR_INVALIDDATA;
- if (width == 0 || width == D3DX_DEFAULT_NONPOW2) - width = image_info.Width; - if (width == D3DX_DEFAULT) - width = make_pow2(image_info.Width); - - if (height == 0 || height == D3DX_DEFAULT_NONPOW2) - height = image_info.Height; - if (height == D3DX_DEFAULT) - height = make_pow2(image_info.Height); - - if (depth == 0 || depth == D3DX_DEFAULT_NONPOW2) - depth = image_info.Depth; - if (depth == D3DX_DEFAULT) - depth = make_pow2(image_info.Depth); - - if (format == D3DFMT_UNKNOWN || format == D3DX_DEFAULT) - format = image_info.Format; - - if (width == D3DX_FROM_FILE) - { - file_width = TRUE; - width = image_info.Width; - } - - if (height == D3DX_FROM_FILE) - { - file_height = TRUE; - height = image_info.Height; - } - - if (depth == D3DX_FROM_FILE) - { - file_depth = TRUE; - depth = image_info.Depth; - } - - if (format == D3DFMT_FROM_FILE) - { - file_format = TRUE; - format = image_info.Format; - } + /* Handle default values. */ + if (!width || width == D3DX_DEFAULT_NONPOW2 || width == D3DX_FROM_FILE || width == D3DX_DEFAULT) + width = (width == D3DX_DEFAULT) ? make_pow2(image_info.Width) : image_info.Width; + if (!height || height == D3DX_DEFAULT_NONPOW2 || height == D3DX_FROM_FILE || height == D3DX_DEFAULT) + height = (height == D3DX_DEFAULT) ? make_pow2(image_info.Height) : image_info.Height; + if (!depth || depth == D3DX_DEFAULT_NONPOW2 || depth == D3DX_FROM_FILE || depth == D3DX_DEFAULT) + depth = (depth == D3DX_DEFAULT) ? make_pow2(image_info.Depth) : image_info.Depth;
- if (mip_levels == D3DX_FROM_FILE) - { - file_mip_levels = TRUE; - mip_levels = image_info.MipLevels; - } + format_specified = (format != D3DFMT_UNKNOWN && format != D3DX_DEFAULT); + if (format == D3DFMT_FROM_FILE || format == D3DFMT_UNKNOWN || format == D3DX_DEFAULT) + format = image_info.Format; + mip_levels = (mip_levels == D3DX_FROM_FILE) ? image_info.MipLevels : mip_levels;
hr = D3DXCheckVolumeTextureRequirements(device, &width, &height, &depth, &mip_levels, usage, &format, pool); if (FAILED(hr)) @@ -1177,12 +1137,8 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic goto err; }
- if ((file_width && width != image_info.Width) - || (file_height && height != image_info.Height) - || (file_depth && depth != image_info.Depth) - || (file_format && format != image_info.Format) - || (file_mip_levels && mip_levels != image_info.MipLevels)) - return D3DERR_NOTAVAILABLE; + if (color_key && !format_specified) + format = get_alpha_replacement_format(format);
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps); if (FAILED(hr))
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/d3dx9_private.h | 2 - dlls/d3dx9_36/surface.c | 52 ------------------- dlls/d3dx9_36/tests/texture.c | 98 +++++++++++++++++------------------ dlls/d3dx9_36/texture.c | 47 +++++++++++++++-- 4 files changed, 90 insertions(+), 109 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 26e4a1560d6..34a9f6eec7f 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -174,8 +174,6 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info); -HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data, - const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info); HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock, IDirect3DSurface9 **temp_surface, BOOL write); HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index a97112a3562..5044feb0fb6 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -619,58 +619,6 @@ HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const vo return D3D_OK; }
-HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data, - const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) -{ - HRESULT hr; - UINT mip_level; - UINT mip_levels; - UINT src_slice_pitch; - UINT src_row_pitch; - D3DBOX src_box; - UINT width, height, depth; - IDirect3DVolume9 *volume; - const struct dds_header *header = src_data; - const BYTE *pixels = (BYTE *)(header + 1); - - if (src_info->ResourceType != D3DRTYPE_VOLUMETEXTURE) - return D3DXERR_INVALIDDATA; - - width = src_info->Width; - height = src_info->Height; - depth = src_info->Depth; - mip_levels = min(src_info->MipLevels, IDirect3DVolumeTexture9_GetLevelCount(volume_texture)); - - for (mip_level = 0; mip_level < mip_levels; mip_level++) - { - hr = d3dx_calculate_pixels_size(src_info->Format, width, height, &src_row_pitch, &src_slice_pitch); - if (FAILED(hr)) return hr; - - hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, mip_level, &volume); - if (FAILED(hr)) return hr; - - src_box.Left = 0; - src_box.Top = 0; - src_box.Right = width; - src_box.Bottom = height; - src_box.Front = 0; - src_box.Back = depth; - - hr = D3DXLoadVolumeFromMemory(volume, palette, NULL, pixels, src_info->Format, - src_row_pitch, src_slice_pitch, NULL, &src_box, filter, color_key); - - IDirect3DVolume9_Release(volume); - if (FAILED(hr)) return hr; - - pixels += depth * src_slice_pitch; - width = max(1, width / 2); - height = max(1, height / 2); - depth = max(1, depth / 2); - } - - return D3D_OK; -} - 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) { diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index 4787bb6ada4..da7521ab134 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -2475,37 +2475,35 @@ static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *dev hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, dds_24bit_8_8, sizeof(dds_24bit_8_8), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + + check_texture_mip_levels(texture, 4, FALSE); + check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE); + check_volume_texture_level_desc(texture, 0, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 8, 8, 1, FALSE); + check_volume_texture_level_desc(texture, 1, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 4, 4, 1, FALSE); + check_volume_texture_level_desc(texture, 2, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 1, FALSE); + check_volume_texture_level_desc(texture, 3, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, FALSE); + + for (mip_level = 0; mip_level < 4; ++mip_level) { - check_texture_mip_levels(texture, 4, FALSE); - check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE); - check_volume_texture_level_desc(texture, 0, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 8, 8, 1, FALSE); - check_volume_texture_level_desc(texture, 1, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 4, 4, 1, FALSE); - check_volume_texture_level_desc(texture, 2, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 1, FALSE); - check_volume_texture_level_desc(texture, 3, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, FALSE); + const uint32_t expected_color = dds_24bit_8_8_expected[mip_level]; + uint32_t x, y, z;
- for (mip_level = 0; mip_level < 4; ++mip_level) + IDirect3DVolumeTexture9_GetLevelDesc(texture, mip_level, &desc); + get_texture_volume_readback(device, texture, mip_level, &volume_rb); + for (z = 0; z < desc.Depth; ++z) { - const uint32_t expected_color = dds_24bit_8_8_expected[mip_level]; - uint32_t x, y, z; - - IDirect3DVolumeTexture9_GetLevelDesc(texture, mip_level, &desc); - get_texture_volume_readback(device, texture, mip_level, &volume_rb); - for (z = 0; z < desc.Depth; ++z) + for (y = 0; y < desc.Height; ++y) { - for (y = 0; y < desc.Height; ++y) + for (x = 0; x < desc.Width; ++x) { - for (x = 0; x < desc.Width; ++x) - { - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color, FALSE); - } + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color, FALSE); } } - release_volume_readback(&volume_rb); } - IDirect3DVolumeTexture9_Release(texture); + release_volume_readback(&volume_rb); } + IDirect3DVolumeTexture9_Release(texture);
/* Multi-mip compressed volume texture file. */ if (has_3d_dxt3) @@ -2550,42 +2548,42 @@ static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *dev hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, bmp_32bpp_4_4_argb, sizeof(bmp_32bpp_4_4_argb), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_FILTER_POINT, 0, &img_info, NULL, &texture); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + + check_texture_mip_levels(texture, 3, TRUE); + check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE); + check_volume_texture_level_desc(texture, 0, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 4, 4, 1, FALSE); + check_volume_texture_level_desc(texture, 1, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 1, TRUE); + check_volume_texture_level_desc(texture, 2, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, TRUE); + + /* + * Check that the values actually get set. Only checking 4x4 and 2x2, 1x1 + * will vary based on filter implementation. + */ + for (mip_level = 0; mip_level < 2; ++mip_level) { - check_texture_mip_levels(texture, 3, FALSE); - check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE); - check_volume_texture_level_desc(texture, 0, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 4, 4, 1, FALSE); - check_volume_texture_level_desc(texture, 1, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 1, FALSE); - check_volume_texture_level_desc(texture, 2, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, FALSE); - - /* - * Check that the values actually get set. Only checking 4x4 and 2x2, 1x1 - * will vary based on filter implementation. - */ - for (mip_level = 0; mip_level < 2; ++mip_level) + BOOL todo = !!mip_level; + + IDirect3DVolumeTexture9_GetLevelDesc(texture, mip_level, &desc); + get_texture_volume_readback(device, texture, mip_level, &volume_rb); + for (z = 0; z < desc.Depth; ++z) { - IDirect3DVolumeTexture9_GetLevelDesc(texture, mip_level, &desc); - get_texture_volume_readback(device, texture, mip_level, &volume_rb); - for (z = 0; z < desc.Depth; ++z) + for (y = 0; y < desc.Height; ++y) { - for (y = 0; y < desc.Height; ++y) - { - const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2]; + const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2];
- for (x = 0; x < desc.Width; ++x) - { - if (x < (desc.Width / 2)) - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE); - else - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE); - } + for (x = 0; x < desc.Width; ++x) + { + if (x < (desc.Width / 2)) + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], todo); + else + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], todo); } } - release_volume_readback(&volume_rb); } - IDirect3DVolumeTexture9_Release(texture); + release_volume_readback(&volume_rb); } + IDirect3DVolumeTexture9_Release(texture); }
/* fills positive x face with red color */ diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 4050115c6df..8f39cade7f8 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -1097,9 +1097,12 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic { HRESULT hr; D3DCAPS9 caps; + struct d3dx_image image; D3DXIMAGE_INFO image_info; + uint32_t loaded_miplevels, skip_levels, i; IDirect3DVolumeTexture9 *tex, *staging_tex; BOOL dynamic_texture, format_specified = FALSE; + const struct pixel_format_desc *src_fmt_desc, *dst_fmt_desc;
TRACE("device %p, data %p, data_size %u, width %u, height %u, depth %u, mip_levels %u, " "usage %#lx, format %#x, pool %#x, filter %#lx, mip_filter %#lx, color_key 0x%08lx, " @@ -1111,11 +1114,15 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic return D3DERR_INVALIDCALL;
staging_tex = tex = *volume_texture = NULL; - hr = D3DXGetImageInfoFromFileInMemory(data, data_size, &image_info); - if (FAILED(hr)) return hr; + skip_levels = mip_filter != D3DX_DEFAULT ? mip_filter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0; + hr = d3dx_image_init(data, data_size, &image, skip_levels, 0); + if (FAILED(hr)) + { + FIXME("Unrecognized file format, returning failure.\n"); + return hr; + }
- if (image_info.ImageFileFormat != D3DXIFF_DDS) - return D3DXERR_INVALIDDATA; + d3dximage_info_from_d3dx_image(&image_info, &image);
/* Handle default values. */ if (!width || width == D3DX_DEFAULT_NONPOW2 || width == D3DX_FROM_FILE || width == D3DX_DEFAULT) @@ -1172,7 +1179,35 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic }
TRACE("Texture created correctly. Now loading the texture data into it.\n"); - hr = load_volume_texture_from_dds(tex, data, palette, filter, color_key, &image_info); + dst_fmt_desc = get_format_info(format); + src_fmt_desc = get_format_info(image_info.Format); + loaded_miplevels = min(image_info.MipLevels, IDirect3DVolumeTexture9_GetLevelCount(tex)); + for (i = 0; i < loaded_miplevels; i++) + { + struct d3dx_pixels src_pixels, dst_pixels; + D3DVOLUME_DESC dst_volume_desc; + D3DLOCKED_BOX dst_locked_box; + RECT dst_rect; + + hr = d3dx_image_get_pixels(&image, i, &src_pixels); + if (FAILED(hr)) + break; + + hr = IDirect3DVolumeTexture9_LockBox(tex, i, &dst_locked_box, NULL, 0); + if (FAILED(hr)) + break; + + IDirect3DVolumeTexture9_GetLevelDesc(tex, i, &dst_volume_desc); + SetRect(&dst_rect, 0, 0, dst_volume_desc.Width, dst_volume_desc.Height); + set_d3dx_pixels(&dst_pixels, dst_locked_box.pBits, dst_locked_box.RowPitch, dst_locked_box.SlicePitch, palette, + dst_volume_desc.Width, dst_volume_desc.Height, dst_volume_desc.Depth, &dst_rect); + + hr = d3dx_load_pixels_from_pixels(&dst_pixels, dst_fmt_desc, &src_pixels, src_fmt_desc, filter, color_key); + IDirect3DVolumeTexture9_UnlockBox(tex, i); + if (FAILED(hr)) + break; + } + if (FAILED(hr)) { FIXME("Texture loading failed.\n"); @@ -1194,12 +1229,14 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic *volume_texture = tex; }
+ d3dx_image_cleanup(&image); if (info) *info = image_info;
return hr;
err: + d3dx_image_cleanup(&image); if (tex) IDirect3DVolumeTexture9_Release(tex);
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/texture.c | 12 +++++------- dlls/d3dx9_36/texture.c | 13 +++++++------ 2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index da7521ab134..14a1bbf199b 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -2550,11 +2550,11 @@ static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *dev D3DX_DEFAULT, D3DX_FILTER_POINT, 0, &img_info, NULL, &texture); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- check_texture_mip_levels(texture, 3, TRUE); + check_texture_mip_levels(texture, 3, FALSE); check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE); check_volume_texture_level_desc(texture, 0, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 4, 4, 1, FALSE); - check_volume_texture_level_desc(texture, 1, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 1, TRUE); - check_volume_texture_level_desc(texture, 2, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, TRUE); + check_volume_texture_level_desc(texture, 1, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 1, FALSE); + check_volume_texture_level_desc(texture, 2, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, FALSE);
/* * Check that the values actually get set. Only checking 4x4 and 2x2, 1x1 @@ -2562,8 +2562,6 @@ static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *dev */ for (mip_level = 0; mip_level < 2; ++mip_level) { - BOOL todo = !!mip_level; - IDirect3DVolumeTexture9_GetLevelDesc(texture, mip_level, &desc); get_texture_volume_readback(device, texture, mip_level, &volume_rb); for (z = 0; z < desc.Depth; ++z) @@ -2575,9 +2573,9 @@ static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *dev for (x = 0; x < desc.Width; ++x) { if (x < (desc.Width / 2)) - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], todo); + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE); else - check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], todo); + check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE); } } } diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 8f39cade7f8..89909f71707 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -1154,12 +1154,6 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic goto err; }
- if (mip_levels > image_info.MipLevels) - { - FIXME("Generation of mipmaps for volume textures is not implemented yet.\n"); - mip_levels = image_info.MipLevels; - } - dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC); if (pool == D3DPOOL_DEFAULT && !dynamic_texture) { @@ -1214,6 +1208,13 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic goto err; }
+ hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)tex, palette, loaded_miplevels - 1, mip_filter); + if (FAILED(hr)) + { + FIXME("Texture filtering failed.\n"); + goto err; + } + /* Move the data to the actual texture if necessary. */ if (staging_tex) {
Matteo Bruni (@Mystral) commented about dlls/d3dx9_36/tests/volume.c:
{ HRESULT hr; D3DBOX src_box;
- uint32_t x, y, z;
- D3DVOLUME_DESC desc;
- D3DXIMAGE_INFO img_info; IDirect3DVolume9 *volume;
- struct volume_readback volume_rb; IDirect3DVolumeTexture9 *volume_texture;
- static const uint32_t bmp_32bpp_4_4_argb_expected[] =
- {
0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000,
- };
Just for future endeavors: I think it's better to consistently order declarations the other way around, from the longest line to the shortest. That's what we generally do for new "d3d" code.
Matteo Bruni (@Mystral) commented about dlls/d3dx9_36/volume.c:
- if (!dst_volume || !src_data || !src_data_size) return D3DERR_INVALIDCALL;
- if (FAILED(hr = D3DXGetImageInfoFromFileInMemory(src_data, src_data_size, &image_info)))
return hr;
hr = d3dx_image_init(src_data, src_data_size, &image, 0, 0);
if (FAILED(hr))
return D3DXERR_INVALIDDATA;
d3dximage_info_from_d3dx_image(&image_info, &image); if (src_box) { if (src_box->Right > image_info.Width || src_box->Bottom > image_info.Height || src_box->Back > image_info.Depth) return D3DERR_INVALIDCALL;
```suggestion:-3+0 if (src_box->Right > image_info.Width || src_box->Bottom > image_info.Height || src_box->Back > image_info.Depth) { hr = D3DERR_INVALIDCALL; goto exit; } ```
Matteo Bruni (@Mystral) commented about dlls/d3dx9_36/tests/texture.c:
- hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, bmp_32bpp_4_4_argb, sizeof(bmp_32bpp_4_4_argb),
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
D3DX_DEFAULT, D3DX_FILTER_POINT, 0, &img_info, NULL, &texture);
- todo_wine ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- if (SUCCEEDED(hr))
- {
check_texture_mip_levels(texture, 3, FALSE);
check_image_info(&img_info, 4, 4, 1, 1, D3DFMT_A8R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_BMP, FALSE);
check_volume_texture_level_desc(texture, 0, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 4, 4, 1, FALSE);
check_volume_texture_level_desc(texture, 1, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 2, 2, 1, FALSE);
check_volume_texture_level_desc(texture, 2, D3DFMT_A8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 1, 1, 1, FALSE);
/*
* Check that the values actually get set. Only checking 4x4 and 2x2, 1x1
* will vary based on filter implementation.
*/
Is this something that should be tested and marked `todo` instead?
Matteo Bruni (@Mystral) commented about dlls/d3dx9_36/tests/texture.c:
const uint32_t *expected_color = &bmp_32bpp_4_4_argb_expected[(y < (desc.Height / 2)) ? 0 : 2];
for (x = 0; x < desc.Width; ++x)
{
if (x < (desc.Width / 2))
check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], FALSE);
else
check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], FALSE);
}
for (x = 0; x < desc.Width; ++x)
{
if (x < (desc.Width / 2))
check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[0], todo);
else
check_volume_readback_pixel_4bpp(&volume_rb, x, y, z, expected_color[1], todo); }
We might want to use `winetest_push_context()` / `winetest_pop_context()` to trace the mip level here.
No need to go around adding context to all the old tests but worth considering for tests to come.
Matteo Bruni (@Mystral) commented about dlls/d3dx9_36/texture.c:
return D3DERR_INVALIDCALL; staging_tex = tex = *volume_texture = NULL;
- hr = D3DXGetImageInfoFromFileInMemory(data, data_size, &image_info);
- if (FAILED(hr)) return hr;
- skip_levels = mip_filter != D3DX_DEFAULT ? mip_filter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0;
Obviously this is not new, but I noticed it only now: we're not applying `D3DX_SKIP_DDS_MIP_LEVELS_MASK` to the value and, as it turns out, that's potentially significant since that means we're taking into account an extra bit compared to the other option. Quickly hacking a test seems to show that native does indeed ignore it:
``` diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index da7521ab134..b46a07ffdf0 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -2192,7 +2192,7 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device) /* Test values returned in the D3DXIMAGE_INFO structure. */ hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_24bit, sizeof(dds_24bit), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, - D3DX_DEFAULT, D3DX_SKIP_DDS_MIP_LEVELS(0, D3DX_FILTER_POINT), 0, &img_info, NULL, &texture); + D3DX_DEFAULT, D3DX_FILTER_POINT | (0x20u << D3DX_SKIP_DDS_MIP_LEVELS_SHIFT), 0, &img_info, NULL, &texture); ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
check_texture_mip_levels(texture, 2, FALSE);
```
This certainly isn't a big deal and can be fixed in a follow up or whenever it feels right.
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=146660
Your paranoid android.
=== debian11 (32 bit report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
=== debian11 (32 bit ar:MA report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
=== debian11 (32 bit de report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
=== debian11 (32 bit fr report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
=== debian11 (32 bit he:IL report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
=== debian11 (32 bit hi:IN report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
=== debian11 (32 bit ja:JP report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
=== debian11 (32 bit zh:CN report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
=== debian11b (32 bit WoW report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
=== debian11b (64 bit WoW report) ===
d3dx9_36: texture.c:2377: Test failed: Got miplevels 1, expected 2. texture.c:2378: Test failed: Got unexpected image info values. texture.c:2378: Test failed: Expected width 2, got 1. texture.c:2378: Test failed: Expected height 2, got 1. texture.c:2378: Test failed: Expected mip_levels 2, got 1. texture.c:2379: Test failed: Got unexpected surface desc values. texture.c:2379: Test failed: Expected width 2, got 1. texture.c:2379: Test failed: Expected height 2, got 1. texture.c:2380: Test failed: Failed to get texture level desc with hr 0x8876086c.
Sorry for the delay in reviewing this MR. I have a few comments, only one is "important", related some missing cleanup on an error path. The comment happens to be in a context area that needed to be expanded with the arrow, hopefully gitlab does the right thing...