diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 763abcd2fa..e289329063 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -617,19 +617,25 @@ static DWORD get_texture_color(ID3D10Texture2D *texture, unsigned int x, unsigne return color; } -#define check_texture_sub_resource_color(t, s, c, d) check_texture_sub_resource_color_(__LINE__, t, s, c, d) +#define check_texture_sub_resource_color(a, b, c, d, e) check_texture_sub_resource_color_(__LINE__, a, b, c, d, e) static void check_texture_sub_resource_color_(unsigned int line, ID3D10Texture2D *texture, - unsigned int sub_resource_idx, DWORD expected_color, BYTE max_diff) + unsigned int sub_resource_idx, const RECT *rect, DWORD expected_color, BYTE max_diff) { struct resource_readback rb; unsigned int x = 0, y = 0; BOOL all_match = TRUE; + RECT default_rect; DWORD color = 0; get_texture_readback(texture, sub_resource_idx, &rb); - for (y = 0; y < rb.height; ++y) + if (!rect) { - for (x = 0; x < rb.width; ++x) + SetRect(&default_rect, 0, 0, rb.width, rb.height); + rect = &default_rect; + } + for (y = rect->top; y < rect->bottom; ++y) + { + for (x = rect->left; x < rect->right; ++x) { color = get_readback_color(&rb, x, y); if (!compare_color(color, expected_color, max_diff)) @@ -657,22 +663,28 @@ static void check_texture_color_(unsigned int line, ID3D10Texture2D *texture, ID3D10Texture2D_GetDesc(texture, &texture_desc); sub_resource_count = texture_desc.ArraySize * texture_desc.MipLevels; for (sub_resource_idx = 0; sub_resource_idx < sub_resource_count; ++sub_resource_idx) - check_texture_sub_resource_color_(line, texture, sub_resource_idx, expected_color, max_diff); + check_texture_sub_resource_color_(line, texture, sub_resource_idx, NULL, expected_color, max_diff); } -#define check_texture_sub_resource_float(r, s, f, d) check_texture_sub_resource_float_(__LINE__, r, s, f, d) +#define check_texture_sub_resource_float(a, b, c, d, e) check_texture_sub_resource_float_(__LINE__, a, b, c, d, e) static void check_texture_sub_resource_float_(unsigned int line, ID3D10Texture2D *texture, - unsigned int sub_resource_idx, float expected_value, BYTE max_diff) + unsigned int sub_resource_idx, const RECT *rect, float expected_value, BYTE max_diff) { struct resource_readback rb; unsigned int x = 0, y = 0; BOOL all_match = TRUE; float value = 0.0f; + RECT default_rect; get_texture_readback(texture, sub_resource_idx, &rb); - for (y = 0; y < rb.height; ++y) + if (!rect) { - for (x = 0; x < rb.width; ++x) + SetRect(&default_rect, 0, 0, rb.width, rb.height); + rect = &default_rect; + } + for (y = rect->top; y < rect->bottom; ++y) + { + for (x = rect->left; x < rect->right; ++x) { value = get_readback_float(&rb, x, y); if (!compare_float(value, expected_value, max_diff)) @@ -700,22 +712,28 @@ static void check_texture_float_(unsigned int line, ID3D10Texture2D *texture, ID3D10Texture2D_GetDesc(texture, &texture_desc); sub_resource_count = texture_desc.ArraySize * texture_desc.MipLevels; for (sub_resource_idx = 0; sub_resource_idx < sub_resource_count; ++sub_resource_idx) - check_texture_sub_resource_float_(line, texture, sub_resource_idx, expected_value, max_diff); + check_texture_sub_resource_float_(line, texture, sub_resource_idx, NULL, expected_value, max_diff); } -#define check_texture_sub_resource_vec4(a, b, c, d) check_texture_sub_resource_vec4_(__LINE__, a, b, c, d) +#define check_texture_sub_resource_vec4(a, b, c, d, e) check_texture_sub_resource_vec4_(__LINE__, a, b, c, d, e) static void check_texture_sub_resource_vec4_(unsigned int line, ID3D10Texture2D *texture, - unsigned int sub_resource_idx, const struct vec4 *expected_value, BYTE max_diff) + unsigned int sub_resource_idx, const RECT *rect, const struct vec4 *expected_value, BYTE max_diff) { struct resource_readback rb; unsigned int x = 0, y = 0; struct vec4 value = {0}; BOOL all_match = TRUE; + RECT default_rect; get_texture_readback(texture, sub_resource_idx, &rb); - for (y = 0; y < rb.height; ++y) + if (!rect) { - for (x = 0; x < rb.width; ++x) + SetRect(&default_rect, 0, 0, rb.width, rb.height); + rect = &default_rect; + } + for (y = rect->top; y < rect->bottom; ++y) + { + for (x = rect->left; x < rect->right; ++x) { value = *get_readback_vec4(&rb, x, y); if (!compare_vec4(&value, expected_value, max_diff)) @@ -745,22 +763,28 @@ static void check_texture_vec4_(unsigned int line, ID3D10Texture2D *texture, ID3D10Texture2D_GetDesc(texture, &texture_desc); sub_resource_count = texture_desc.ArraySize * texture_desc.MipLevels; for (sub_resource_idx = 0; sub_resource_idx < sub_resource_count; ++sub_resource_idx) - check_texture_sub_resource_vec4_(line, texture, sub_resource_idx, expected_value, max_diff); + check_texture_sub_resource_vec4_(line, texture, sub_resource_idx, NULL, expected_value, max_diff); } -#define check_texture_sub_resource_uvec4(a, b, c) check_texture_sub_resource_uvec4_(__LINE__, a, b, c) +#define check_texture_sub_resource_uvec4(a, b, c, d) check_texture_sub_resource_uvec4_(__LINE__, a, b, c, d) static void check_texture_sub_resource_uvec4_(unsigned int line, ID3D10Texture2D *texture, - unsigned int sub_resource_idx, const struct uvec4 *expected_value) + unsigned int sub_resource_idx, const RECT *rect, const struct uvec4 *expected_value) { struct resource_readback rb; unsigned int x = 0, y = 0; struct uvec4 value = {0}; BOOL all_match = TRUE; + RECT default_rect; get_texture_readback(texture, sub_resource_idx, &rb); - for (y = 0; y < rb.height; ++y) + if (!rect) { - for (x = 0; x < rb.width; ++x) + SetRect(&default_rect, 0, 0, rb.width, rb.height); + rect = &default_rect; + } + for (y = rect->top; y < rect->bottom; ++y) + { + for (x = rect->left; x < rect->right; ++x) { value = *get_readback_uvec4(&rb, x, y); if (!compare_uvec4(&value, expected_value)) @@ -791,7 +815,7 @@ static void check_texture_uvec4_(unsigned int line, ID3D10Texture2D *texture, ID3D10Texture2D_GetDesc(texture, &texture_desc); sub_resource_count = texture_desc.ArraySize * texture_desc.MipLevels; for (sub_resource_idx = 0; sub_resource_idx < sub_resource_count; ++sub_resource_idx) - check_texture_sub_resource_uvec4_(line, texture, sub_resource_idx, expected_value); + check_texture_sub_resource_uvec4_(line, texture, sub_resource_idx, NULL, expected_value); } static ID3D10Device *create_device(void) @@ -2509,7 +2533,7 @@ static void test_render_target_views(void) sub_resource_count = texture_desc.MipLevels * texture_desc.ArraySize; assert(sub_resource_count <= sizeof(test->expected_colors) / sizeof(*test->expected_colors)); for (j = 0; j < sub_resource_count; ++j) - check_texture_sub_resource_color(texture, j, test->expected_colors[j], 1); + check_texture_sub_resource_color(texture, j, NULL, test->expected_colors[j], 1); ID3D10RenderTargetView_Release(rtv); ID3D10Texture2D_Release(texture); @@ -10525,15 +10549,15 @@ static void test_sm4_ret_instruction(void) static void test_primitive_restart(void) { struct d3d10core_test_context test_context; - unsigned int stride, offset, x, y; ID3D10Buffer *ib32, *ib16, *vb; - struct resource_readback rb; + unsigned int stride, offset; ID3D10InputLayout *layout; ID3D10VertexShader *vs; ID3D10PixelShader *ps; ID3D10Device *device; unsigned int i; HRESULT hr; + RECT rect; static const DWORD ps_code[] = { @@ -10650,25 +10674,12 @@ static void test_primitive_restart(void) ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, black); ID3D10Device_DrawIndexed(device, 9, 0, 0); - get_texture_readback(test_context.backbuffer, 0, &rb); - for (y = 0; y < 480; ++y) - { - for (x = 0; x < 640; ++x) - { - DWORD color = get_readback_color(&rb, x, y); - DWORD expected_color; - if (x < 240) - expected_color = 0xffffff00; - else if (x >= 640 - 240) - expected_color = 0xff0000ff; - else - expected_color = 0x00000000; - ok(compare_color(color, expected_color, 1), - "Test %u: Got 0x%08x, expected 0x%08x at (%u, %u).\n", - i, color, expected_color, x, y); - } - } - release_resource_readback(&rb); + SetRect(&rect, 0, 0, 240, 480); + check_texture_sub_resource_color(test_context.backbuffer, 0, &rect, 0xffffff00, 1); + SetRect(&rect, 240, 0, 400, 480); + check_texture_sub_resource_color(test_context.backbuffer, 0, &rect, 0x00000000, 1); + SetRect(&rect, 400, 0, 640, 480); + check_texture_sub_resource_color(test_context.backbuffer, 0, &rect, 0xff0000ff, 1); } ID3D10Buffer_Release(ib16);