=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: tests: Add basic test for NULL CBV descriptors.
Alexandre Julliard
julliard at winehq.org
Mon Mar 4 14:44:26 CST 2019
Module: vkd3d
Branch: master
Commit: e20ddc48a63ccc4f7340909f55652906ebbfb128
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=e20ddc48a63ccc4f7340909f55652906ebbfb128
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Mon Mar 4 13:15:15 2019 +0100
tests: Add basic test for NULL CBV descriptors.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
include/vkd3d_d3d12.idl | 2 +
tests/d3d12.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 116 insertions(+), 2 deletions(-)
diff --git a/include/vkd3d_d3d12.idl b/include/vkd3d_d3d12.idl
index 231123b..a1f87b2 100644
--- a/include/vkd3d_d3d12.idl
+++ b/include/vkd3d_d3d12.idl
@@ -45,6 +45,8 @@ const UINT D3D12_DEFAULT_STENCIL_WRITE_MASK = 0xff;
const UINT D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND = 0xffffffff;
cpp_quote("#define D3D12_FLOAT32_MAX (3.402823466e+38f)")
const UINT D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT = 32;
+const UINT D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT = 4096;
+const UINT D3D12_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT = 4096;
const UINT D3D12_REQ_MIP_LEVELS = 15;
const UINT D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION = 2048;
const UINT D3D12_REQ_TEXTURE1D_U_DIMENSION = 16384;
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 5ae8511..44e128a 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -15387,7 +15387,7 @@ static void test_descriptors_visibility(void)
destroy_test_context(&context);
}
-static void test_null_descriptors(void)
+static void test_create_null_descriptors(void)
{
D3D12_UNORDERED_ACCESS_VIEW_DESC uav_desc;
D3D12_CONSTANT_BUFFER_VIEW_DESC cbv_desc;
@@ -15456,6 +15456,117 @@ static void test_null_descriptors(void)
destroy_test_context(&context);
}
+static void test_null_cbv(void)
+{
+ D3D12_ROOT_SIGNATURE_DESC root_signature_desc;
+ D3D12_CONSTANT_BUFFER_VIEW_DESC cbv_desc;
+ ID3D12GraphicsCommandList *command_list;
+ D3D12_ROOT_PARAMETER root_parameters[2];
+ D3D12_DESCRIPTOR_RANGE descriptor_range;
+ struct test_context_desc desc;
+ struct test_context context;
+ ID3D12DescriptorHeap *heap;
+ ID3D12CommandQueue *queue;
+ ID3D12Device *device;
+ unsigned int index;
+ HRESULT hr;
+
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const DWORD ps_code[] =
+ {
+#if 0
+ uint index;
+
+ cbuffer null_cb
+ {
+ float4 data[1024];
+ };
+
+ float4 main() : SV_Target
+ {
+ return data[index];
+ }
+#endif
+ 0x43425844, 0xa69026e2, 0xccf934be, 0x11f0a922, 0x95e9ab51, 0x00000001, 0x000000f0, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000078, 0x00000050, 0x0000001e,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000859, 0x00208e46, 0x00000001,
+ 0x00000400, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x06000036, 0x00100012,
+ 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x07000036, 0x001020f2, 0x00000000, 0x04208e46,
+ 0x00000001, 0x0010000a, 0x00000000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)};
+
+ memset(&desc, 0, sizeof(desc));
+ desc.no_root_signature = true;
+ if (!init_test_context(&context, &desc))
+ return;
+ command_list = context.list;
+ queue = context.queue;
+ device = context.device;
+
+ descriptor_range.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_CBV;
+ descriptor_range.NumDescriptors = 1;
+ descriptor_range.BaseShaderRegister = 1;
+ descriptor_range.RegisterSpace = 0;
+ descriptor_range.OffsetInDescriptorsFromTableStart = 0;
+ root_parameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
+ root_parameters[0].DescriptorTable.NumDescriptorRanges = 1;
+ root_parameters[0].DescriptorTable.pDescriptorRanges = &descriptor_range;
+ root_parameters[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
+
+ root_parameters[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
+ root_parameters[1].Constants.ShaderRegister = 0;
+ root_parameters[1].Constants.RegisterSpace = 0;
+ root_parameters[1].Constants.Num32BitValues = 1;
+ root_parameters[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
+
+ memset(&root_signature_desc, 0, sizeof(root_signature_desc));
+ root_signature_desc.NumParameters = ARRAY_SIZE(root_parameters);
+ root_signature_desc.pParameters = root_parameters;
+ hr = create_root_signature(device, &root_signature_desc, &context.root_signature);
+ ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
+
+ context.pipeline_state = create_pipeline_state(context.device,
+ context.root_signature, context.render_target_desc.Format, NULL, &ps, NULL);
+
+ heap = create_gpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 16);
+
+ cbv_desc.BufferLocation = 0;
+ cbv_desc.SizeInBytes = 0; /* Size doesn't appear to matter for NULL CBV. */
+ ID3D12Device_CreateConstantBufferView(device, &cbv_desc,
+ ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap));
+
+ for (index = 0; index < 1200; index += 100)
+ {
+ ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
+
+ ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, FALSE, NULL);
+ ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
+ ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state);
+ ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &heap);
+ ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 0,
+ ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(heap));
+ ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 1, 1, &index, 0);
+ ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
+ ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
+ ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
+
+ transition_sub_resource_state(command_list, context.render_target, 0,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ check_sub_resource_float(context.render_target, 0, queue, command_list, 0x00000000, 0);
+
+ reset_command_list(command_list, context.allocator);
+ transition_sub_resource_state(command_list, context.render_target, 0,
+ D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
+ }
+
+ ID3D12DescriptorHeap_Release(heap);
+ destroy_test_context(&context);
+}
+
#define check_copyable_footprints(a, b, c, d, e, f, g, h) \
check_copyable_footprints_(__LINE__, a, b, c, d, e, f, g, h)
static void check_copyable_footprints_(unsigned int line, const D3D12_RESOURCE_DESC *desc,
@@ -25371,7 +25482,8 @@ START_TEST(d3d12)
run_test(test_copy_descriptors);
run_test(test_copy_descriptors_range_sizes);
run_test(test_descriptors_visibility);
- run_test(test_null_descriptors);
+ run_test(test_create_null_descriptors);
+ run_test(test_null_cbv);
run_test(test_get_copyable_footprints);
run_test(test_depth_stencil_sampling);
run_test(test_depth_load);
More information about the wine-cvs
mailing list