From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Józef Kucia jkucia@codeweavers.com --- tests/d3d12.c | 95 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 22 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index bd055fb5d444..970e2ea32369 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -4283,6 +4283,22 @@ static void test_clear_depth_stencil_view(void) destroy_test_context(&context); }
+#define test_clear_rtv_r8g8b8a8_2d(a, b, c, d, e, f, g) test_clear_rtv_r8g8b8a8_2d_(__LINE__, a, b, c, d, e, f, g) +static void test_clear_rtv_r8g8b8a8_2d_(unsigned int line, const struct test_context *context, + ID3D12Resource *resource, D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle, + const float *color, unsigned int expected, unsigned int max_diff, bool is_todo) +{ + ID3D12GraphicsCommandList_ClearRenderTargetView(context->list, rtv_handle, color, 0, NULL); + transition_resource_state(context->list, resource, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + todo_if(is_todo) + check_sub_resource_uint_(line, resource, 0, context->queue, context->list, expected, max_diff); + + reset_command_list(context->list, context->allocator); + transition_resource_state(context->list, resource, + D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); +} + static void test_clear_render_target_view(void) { static const unsigned int array_expected_colors[] = {0xff00ff00, 0xff0000ff, 0xffff0000}; @@ -4292,6 +4308,7 @@ static void test_clear_render_target_view(void) {1.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f, 1.0f}, }; + static const float negative_value[] = {1.0f, -1.0f, -0.5f, -2.0f}; static const float color[] = {0.1f, 0.5f, 0.3f, 0.75f}; static const float green[] = {0.0f, 1.0f, 0.0f, 1.0f}; ID3D12GraphicsCommandList *command_list; @@ -4311,6 +4328,30 @@ static void test_clear_render_target_view(void) unsigned int i; D3D12_BOX box; HRESULT hr; + static const struct + { + const float *color; + unsigned int expected; + unsigned int max_diff; + bool is_todo; + } + test_r8g8b8a8_unorm[] = + { + {green, 0xff00ff00, 0}, + {color, 0xbf4c7f19, 2}, + }, + test_r8g8b8a8_uint[] = + { + {green, 0x01000100, 0, true}, + {color, 0x00000000, 0, true}, + {negative_value, 0x00000001, 0, true}, + }, + test_r8g8b8a8_sint[] = + { + {green, 0x01000100, 0, true}, + {color, 0x00000000, 0, true}, + {negative_value, 0xfe00ff01, 0, true}, + };
STATIC_ASSERT(ARRAY_SIZE(array_colors) == ARRAY_SIZE(array_expected_colors));
@@ -4358,34 +4399,45 @@ static void test_clear_render_target_view(void) rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; rtv_desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle); - - ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, green, 0, NULL); - transition_resource_state(command_list, resource, - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - check_sub_resource_uint(resource, 0, queue, command_list, 0xff00ff00, 0); - - reset_command_list(command_list, context.allocator); - transition_resource_state(command_list, resource, - D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); - - ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, color, 0, NULL); - transition_resource_state(command_list, resource, - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - check_sub_resource_uint(resource, 0, queue, command_list, 0xbf4c7f19, 2); + for (i = 0; i < ARRAY_SIZE(test_r8g8b8a8_unorm); i++) + { + vkd3d_test_set_context("Test %u", i); + test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, test_r8g8b8a8_unorm[i].color, + test_r8g8b8a8_unorm[i].expected, test_r8g8b8a8_unorm[i].max_diff, test_r8g8b8a8_unorm[i].is_todo); + } + vkd3d_test_set_context(NULL);
/* sRGB view */ - reset_command_list(command_list, context.allocator); - transition_resource_state(command_list, resource, - D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle); + test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, color, 0xbf95bc59, 2, false);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, color, 0, NULL); - transition_resource_state(command_list, resource, - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - check_sub_resource_uint(resource, 0, queue, command_list, 0xbf95bc59, 2); + /* DXGI_FORMAT_R8G8B8A8_UINT view */ + rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UINT; + ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle); + for (i = 0; i < ARRAY_SIZE(test_r8g8b8a8_uint); i++) + { + vkd3d_test_set_context("Test %u", i); + test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, test_r8g8b8a8_uint[i].color, + test_r8g8b8a8_uint[i].expected, test_r8g8b8a8_uint[i].max_diff, test_r8g8b8a8_uint[i].is_todo); + } + vkd3d_test_set_context(NULL); + + /* DXGI_FORMAT_R8G8B8A8_SINT view */ + rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_SINT; + ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle); + for (i = 0; i < ARRAY_SIZE(test_r8g8b8a8_sint); i++) + { + vkd3d_test_set_context("Test %u", i); + test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, test_r8g8b8a8_sint[i].color, + test_r8g8b8a8_sint[i].expected, test_r8g8b8a8_sint[i].max_diff, test_r8g8b8a8_sint[i].is_todo); + } + vkd3d_test_set_context(NULL);
/* 2D array texture */ + hr = ID3D12GraphicsCommandList_Close(command_list); + ok(hr == S_OK, "Failed to close command list, hr %#x.\n", hr); + reset_command_list(command_list, context.allocator); ID3D12Resource_Release(resource); resource_desc.DepthOrArraySize = ARRAY_SIZE(array_colors); hr = ID3D12Device_CreateCommittedResource(device, @@ -4394,7 +4446,6 @@ static void test_clear_render_target_view(void) &IID_ID3D12Resource, (void **)&resource); ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
- reset_command_list(command_list, context.allocator); for (i = 0; i < ARRAY_SIZE(array_colors); ++i) { memset(&rtv_desc, 0, sizeof(rtv_desc));