From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
tests/d3d12.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 168 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index edd1f5954688..1eca3b9c6063 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -15801,6 +15801,173 @@ static void test_null_cbv(void)
destroy_test_context(&context);
}
+static void test_null_srv(void)
+{
+ D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc;
+ ID3D12GraphicsCommandList *command_list;
+ struct test_context_desc desc;
+ struct test_context context;
+ ID3D12DescriptorHeap *heap;
+ ID3D12CommandQueue *queue;
+ struct uvec4 location;
+ ID3D12Device *device;
+ unsigned int i, j;
+
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const DWORD ps_sample_code[] =
+ {
+#if 0
+ Texture2D t;
+ SamplerState s;
+
+ float4 main(float4 position : SV_Position) : SV_Target
+ {
+ return t.Sample(s, float2(position.x / 32.0f, position.y / 32.0f));
+ }
+#endif
+ 0x43425844, 0xe096fa11, 0xeb01c081, 0x961588d4, 0x27c031af, 0x00000001, 0x00000140, 0x00000003,
+ 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
+ 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a4, 0x00000050,
+ 0x00000029, 0x0100086a, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000,
+ 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002,
+ 0x3d000000, 0x3d000000, 0x00000000, 0x00000000, 0x8b000045, 0x800000c2, 0x00155543, 0x001020f2,
+ 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps_sample = {ps_sample_code, sizeof(ps_sample_code)};
+ static const DWORD ps_ld_code[] =
+ {
+#if 0
+ Texture2D t;
+
+ uint4 location;
+
+ float4 main(float4 position : SV_Position) : SV_Target
+ {
+ return t.Load(location.xyz);
+ }
+#endif
+ 0x43425844, 0xfa13670e, 0x291af510, 0xc253cc12, 0x9474950b, 0x00000001, 0x00000100, 0x00000003,
+ 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69,
+ 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064, 0x00000050,
+ 0x00000019, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001858, 0x00107000,
+ 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x8a00002d, 0x800000c2, 0x00155543,
+ 0x001020f2, 0x00000000, 0x00208a46, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps_ld = {ps_ld_code, sizeof(ps_ld_code)};
+ static const DXGI_FORMAT formats[] =
+ {
+ DXGI_FORMAT_R32_FLOAT,
+ DXGI_FORMAT_R32_UINT,
+ DXGI_FORMAT_R8G8B8A8_UNORM,
+ };
+ /* component mapping is ignored for NULL SRVs */
+ static const unsigned int component_mappings[] =
+ {
+ D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING,
+ D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(
+ D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1,
+ D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1,
+ D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1,
+ D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1),
+ };
+
+ 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;
+
+ context.root_signature = create_texture_root_signature(context.device,
+ D3D12_SHADER_VISIBILITY_PIXEL, 4, 0);
+
+ context.pipeline_state = create_pipeline_state(context.device,
+ context.root_signature, context.render_target_desc.Format, NULL, &ps_sample, NULL);
+
+ heap = create_gpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 16);
+
+ for (i = 0; i < ARRAY_SIZE(formats); ++i)
+ {
+ for (j = 0; j < ARRAY_SIZE(component_mappings); ++j)
+ {
+ vkd3d_test_set_context("format %#x, component mapping %#x", formats[i], component_mappings[j]);
+
+ memset(&srv_desc, 0, sizeof(srv_desc));
+ srv_desc.Format = formats[i];
+ srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
+ srv_desc.Shader4ComponentMapping = component_mappings[j];
+ srv_desc.Texture2D.MipLevels = 1;
+ ID3D12Device_CreateShaderResourceView(device, NULL, &srv_desc,
+ ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap));
+
+ 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_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_uint(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);
+ }
+ }
+ vkd3d_test_set_context(NULL);
+
+ ID3D12PipelineState_Release(context.pipeline_state);
+ context.pipeline_state = create_pipeline_state(context.device,
+ context.root_signature, context.render_target_desc.Format, NULL, &ps_ld, NULL);
+
+ memset(&srv_desc, 0, sizeof(srv_desc));
+ srv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
+ srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
+ srv_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
+ srv_desc.Texture2D.MipLevels = 1;
+ ID3D12Device_CreateShaderResourceView(device, NULL, &srv_desc,
+ ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap));
+
+ 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_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
+ ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
+ location.x = 10;
+ location.y = 20;
+ location.z = 0;
+ location.w = 0;
+ ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 1, 4, &location, 0);
+ 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_uint(context.render_target, 0, queue, command_list, 0x00000000, 0);
+
+ 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,
@@ -26674,6 +26841,7 @@ START_TEST(d3d12)
run_test(test_descriptors_visibility);
run_test(test_create_null_descriptors);
run_test(test_null_cbv);
+ run_test(test_null_srv);
run_test(test_get_copyable_footprints);
run_test(test_depth_stencil_sampling);
run_test(test_depth_load);
--
2.19.2