[PATCH vkd3d 8/8] tests: Add test for initial pipeline state.
Józef Kucia
joseph.kucia at gmail.com
Thu Sep 27 06:30:56 CDT 2018
From: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
tests/d3d12.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index ad5200d55d48..83010674d5cf 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -20023,6 +20023,82 @@ static void test_suballocate_small_textures(void)
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
}
+static void test_command_list_initial_pipeline_state(void)
+{
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ ID3D12GraphicsCommandList *command_list;
+ ID3D12PipelineState *pipeline_state;
+ ID3D12CommandAllocator *allocator;
+ struct test_context context;
+ ID3D12CommandQueue *queue;
+ HRESULT hr;
+
+ static const DWORD ps_code[] =
+ {
+#if 0
+ void main(out float4 target : SV_Target)
+ {
+ target = float4(0.0f, 0.25f, 0.5f, 1.0f);
+ }
+#endif
+ 0x43425844, 0x2f09e5ff, 0xaa135d5e, 0x7860f4b5, 0x5c7b8cbc, 0x00000001, 0x000000b4, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000003c, 0x00000050, 0x0000000f,
+ 0x0100086a, 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
+ 0x00000000, 0x3e800000, 0x3f000000, 0x3f800000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)};
+
+ if (!init_test_context(&context, NULL))
+ return;
+ queue = context.queue;
+
+ pipeline_state = create_pipeline_state(context.device,
+ context.root_signature, context.render_target_desc.Format, NULL, &ps, NULL);
+
+ hr = ID3D12Device_CreateCommandAllocator(context.device, D3D12_COMMAND_LIST_TYPE_DIRECT,
+ &IID_ID3D12CommandAllocator, (void **)&allocator);
+ ok(hr == S_OK, "Failed to create command allocator, hr %#x.\n", hr);
+ hr = ID3D12Device_CreateCommandList(context.device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
+ allocator, pipeline_state, &IID_ID3D12GraphicsCommandList, (void **)&command_list);
+ ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
+
+ 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_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_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ check_sub_resource_uint(context.render_target, 0, queue, command_list, 0xff804000, 1);
+
+ hr = ID3D12CommandAllocator_Reset(allocator);
+ ok(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
+ hr = ID3D12GraphicsCommandList_Reset(command_list, allocator, context.pipeline_state);
+ ok(hr == S_OK, "Failed to reset command list, hr %#x.\n", hr);
+ transition_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
+
+ 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_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_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ check_sub_resource_uint(context.render_target, 0, queue, command_list, 0xff00ff00, 0);
+
+ ID3D12CommandAllocator_Release(allocator);
+ ID3D12GraphicsCommandList_Release(command_list);
+ ID3D12PipelineState_Release(pipeline_state);
+ destroy_test_context(&context);
+}
+
START_TEST(d3d12)
{
bool enable_debug_layer = false;
@@ -20143,4 +20219,5 @@ START_TEST(d3d12)
run_test(test_combined_clip_and_cull_distances);
run_test(test_resource_allocation_info);
run_test(test_suballocate_small_textures);
+ run_test(test_command_list_initial_pipeline_state);
}
--
2.16.4
More information about the wine-devel
mailing list