From: Ziqing Hui Subject: [PATCH 4/4] d3dx10/tests: Add code for generating test data. Message-Id: <1303ea81-cd50-af66-3f79-7df8732b6c4a@codeweavers.com> Date: Mon, 7 Jun 2021 14:58:11 +0800 Signed-off-by: Ziqing Hui --- The frame data in [PATCH 2/4] generated by the code here. dlls/d3dx10_43/tests/d3dx10.c | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 8952d0330ec..245a8fe9f1b 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -960,6 +960,57 @@ static ID3D10Texture2D *copy_texture(ID3D10Device *device, ID3D10Texture2D *text return texture_copy; } +#if 0 /* use this to generate test data for newly added test image */ + +static BOOL image_info_dumped[ARRAY_SIZE(test_image)]; +static BOOL frame_data_dumped[ARRAY_SIZE(test_image)]; + +static void dump_image_info(D3DX10_IMAGE_INFO *info, unsigned int i) +{ + if (!test_image[i].expected_info.Width && !image_info_dumped[i]) + { + printf("Test %u:\n", i); + printf("{%u, %u, %u, %u, %u, %#x, %#x, %u, %u}", info->Width, info->Height, info->Depth, info->ArraySize, + info->MipLevels, info->MiscFlags, info->Format, info->ResourceDimension, info->ImageFileFormat); + image_info_dumped[i] = TRUE; + } +} + +static void dump_frame_data(D3D10_MAPPED_TEXTURE2D *map, unsigned int stride, unsigned int height, unsigned int i) +{ + unsigned int j, k; + + if (!test_image[i].expected_frame && !frame_data_dumped[i]) + { + printf("Test %u:\n", i); + printf("static const BYTE test_*_frame_data[] =\n"); + printf("{\n"); + for (j = 0; j < height; ++j) + { + for (k = 0; k < stride; ++k) + { + if ((stride * j + k) % 16 == 0) + printf(" "); + printf("0x%02x", ((BYTE *)map->pData)[map->RowPitch * j + k]); + if (j == height - 1 && k == stride - 1) + printf("\n"); + else + printf(", "); + if ((stride * j + k) % 16 == 15) + printf("\n"); + } + frame_data_dumped[i] = TRUE; + } + printf("};\n"); + } +} + +#define check_image_info(info, i, line) dump_image_info(info, i) +#define check_resource_info(resource, i, line) +#define check_frame_data(map, stride, height, subresource, i, line) dump_frame_data(map, stride, height, i) + +#else + static void check_image_info(D3DX10_IMAGE_INFO *image_info, unsigned int i, unsigned int line) { ok_(__FILE__, line)(image_info->Width == test_image[i].expected_info.Width, @@ -1119,6 +1170,8 @@ static void check_frame_data(D3D10_MAPPED_TEXTURE2D *map, unsigned int stride, u } } +#endif + static void check_resource_data(ID3D10Device *device, ID3D10Resource *resource, unsigned int i, unsigned int line) { unsigned int width, height, stride;