[PATCH vkd3d v3 2/5] tests: Test ClearRenderTargetView() with R16G16B16A16 formats.
Józef Kucia
joseph.kucia at gmail.com
Fri Jul 19 11:28:05 CDT 2019
From: Jactry Zeng <jzeng at codeweavers.com>
Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
Version 3: Use llabs() and 1 table.
---
tests/d3d12.c | 124 +++++++++++++++++++++++++++++++++++++++
tests/d3d12_test_utils.h | 2 +
2 files changed, 126 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index c37821f03f2e..aa09295466b9 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -89,6 +89,11 @@ static bool compare_uint16(uint16_t a, uint16_t b, unsigned int max_diff)
return abs(a - b) <= max_diff;
}
+static bool compare_uint64(uint64_t a, uint64_t b, unsigned int max_diff)
+{
+ return llabs(a - b) <= max_diff;
+}
+
static ULONG get_refcount(void *iface)
{
IUnknown *unk = iface;
@@ -531,6 +536,47 @@ static void check_sub_resource_uint16_(unsigned int line, ID3D12Resource *textur
release_resource_readback(&rb);
}
+#define check_readback_data_uint64(a, b, c, d) check_readback_data_uint64_(__LINE__, a, b, c, d)
+static void check_readback_data_uint64_(unsigned int line, struct resource_readback *rb,
+ const RECT *rect, uint64_t expected, unsigned int max_diff)
+{
+ RECT r = {0, 0, rb->width, rb->height};
+ unsigned int x = 0, y;
+ bool all_match = true;
+ uint64_t got = 0;
+
+ if (rect)
+ r = *rect;
+
+ for (y = r.top; y < r.bottom; ++y)
+ {
+ for (x = r.left; x < r.right; ++x)
+ {
+ got = get_readback_uint64(rb, x, y);
+ if (!compare_uint64(got, expected, max_diff))
+ {
+ all_match = false;
+ break;
+ }
+ }
+ if (!all_match)
+ break;
+ }
+ ok_(line)(all_match, "Got %#"PRIx64", expected %#"PRIx64" at (%u, %u).\n", got, expected, x, y);
+}
+
+#define check_sub_resource_uint64(a, b, c, d, e, f) check_sub_resource_uint64_(__LINE__, a, b, c, d, e, f)
+static void check_sub_resource_uint64_(unsigned int line, ID3D12Resource *texture,
+ unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
+ uint64_t expected, unsigned int max_diff)
+{
+ struct resource_readback rb;
+
+ get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list);
+ check_readback_data_uint64_(line, &rb, NULL, expected, max_diff);
+ release_resource_readback(&rb);
+}
+
#define check_sub_resource_vec4(a, b, c, d, e, f) check_sub_resource_vec4_(__LINE__, a, b, c, d, e, f)
static void check_sub_resource_vec4_(unsigned int line, ID3D12Resource *texture,
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
@@ -4298,6 +4344,21 @@ static void test_clear_rtv_r8g8b8a8_2d_(unsigned int line, const struct test_con
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
}
+#define test_clear_rtv_r16g16b16a16_2d(a, b, c, d, e) test_clear_rtv_r16g16b16a16_2d_(__LINE__, a, b, c, d, e)
+static void test_clear_rtv_r16g16b16a16_2d_(unsigned int line, const struct test_context *context,
+ ID3D12Resource *resource, D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle,
+ const float *color, uint64_t expected)
+{
+ 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);
+ check_sub_resource_uint64_(line, resource, 0, context->queue, context->list, expected, 0);
+
+ 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};
@@ -4340,6 +4401,19 @@ static void test_clear_render_target_view(void)
{color, 0xbf4c7f19, 0x00000000, 0x00000000},
{negative_value, 0x00000000, 0x00000001, 0xfe00ff01},
};
+ static const struct
+ {
+ const float *color;
+ uint64_t unorm_result;
+ uint64_t uint_result;
+ uint64_t sint_result;
+ }
+ test_r16g16b16a16[] =
+ {
+ {green, 0xffff0000ffff0000, 0x0001000000010000, 0x0001000000010000},
+ {color, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000},
+ {negative_value, 0x0000000000000000, 0x0000000000000001, 0xfffe0000ffff0001},
+ };
STATIC_ASSERT(ARRAY_SIZE(array_colors) == ARRAY_SIZE(array_expected_colors));
@@ -4425,11 +4499,61 @@ static void test_clear_render_target_view(void)
}
vkd3d_test_set_context(NULL);
+ /* R16G16B16A16 views */
+ 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.Format = DXGI_FORMAT_R16G16B16A16_TYPELESS;
+ hr = ID3D12Device_CreateCommittedResource(device,
+ &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, NULL,
+ &IID_ID3D12Resource, (void **)&resource);
+ ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
+
+ memset(&rtv_desc, 0, sizeof(rtv_desc));
+ rtv_desc.Format = DXGI_FORMAT_R16G16B16A16_UNORM;
+ rtv_desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
+ ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+ for (i = 0; i < ARRAY_SIZE(test_r16g16b16a16); ++i)
+ {
+ if (!test_r16g16b16a16[i].unorm_result)
+ continue;
+
+ vkd3d_test_set_context("Test %u", i);
+ test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle,
+ test_r16g16b16a16[i].color, test_r16g16b16a16[i].unorm_result);
+ }
+ vkd3d_test_set_context(NULL);
+
+ /* DXGI_FORMAT_R16G16B16A16_UINT view */
+ rtv_desc.Format = DXGI_FORMAT_R16G16B16A16_UINT;
+ ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+ for (i = 0; i < ARRAY_SIZE(test_r16g16b16a16); ++i)
+ {
+ vkd3d_test_set_context("Test %u", i);
+ todo test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle,
+ test_r16g16b16a16[i].color, test_r16g16b16a16[i].uint_result);
+ }
+ vkd3d_test_set_context(NULL);
+
+ /* DXGI_FORMAT_R16G16B16A16_SINT view */
+ rtv_desc.Format = DXGI_FORMAT_R16G16B16A16_SINT;
+ ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+ for (i = 0; i < ARRAY_SIZE(test_r16g16b16a16); ++i)
+ {
+ vkd3d_test_set_context("Test %u", i);
+ todo test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle,
+ test_r16g16b16a16[i].color, test_r16g16b16a16[i].sint_result);
+ }
+ 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.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS;
resource_desc.DepthOrArraySize = ARRAY_SIZE(array_colors);
hr = ID3D12Device_CreateCommittedResource(device,
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc,
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index da272da98d6b..ec6f839d8e8d 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -270,6 +270,8 @@ static unsigned int format_size(DXGI_FORMAT format)
case DXGI_FORMAT_R32G32B32A32_UINT:
case DXGI_FORMAT_R8G8_UNORM:
return 16;
+ case DXGI_FORMAT_R16G16B16A16_TYPELESS:
+ return 8;
case DXGI_FORMAT_R32_TYPELESS:
case DXGI_FORMAT_D32_FLOAT:
case DXGI_FORMAT_R32_FLOAT:
--
2.21.0
More information about the wine-devel
mailing list