Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
September 2018
- 70 participants
- 1549 messages
Re: [PATCH 2/2] mscms: update spec (win7)
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Sept. 27, 2018
Re: [PATCH 1/2] mscms: add stub for WcsGetUsePerUserProfiles
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Sept. 27, 2018
[PATCH vkd3d 8/8] tests: Add test for initial pipeline state.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)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
Sept. 27, 2018
[PATCH vkd3d 7/8] tests: Add test for gather4_c shader instructions.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
tests/d3d12.c | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 286 insertions(+), 13 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 9424ca182059..ad5200d55d48 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -937,27 +937,35 @@ static ID3D12RootSignature *create_32bit_constants_root_signature_(unsigned int
return root_signature;
}
-#define create_texture_root_signature(a, b, c, d) create_texture_root_signature_(__LINE__, a, b, c, d)
+#define create_texture_root_signature(a, b, c, d) create_texture_root_signature_(__LINE__, a, b, c, d, NULL)
static ID3D12RootSignature *create_texture_root_signature_(unsigned int line,
ID3D12Device *device, D3D12_SHADER_VISIBILITY shader_visibility,
- unsigned int constant_count, D3D12_ROOT_SIGNATURE_FLAGS flags)
+ unsigned int constant_count, D3D12_ROOT_SIGNATURE_FLAGS flags,
+ const D3D12_STATIC_SAMPLER_DESC *sampler_desc)
{
D3D12_ROOT_SIGNATURE_DESC root_signature_desc;
ID3D12RootSignature *root_signature = NULL;
+ D3D12_STATIC_SAMPLER_DESC static_sampler;
D3D12_DESCRIPTOR_RANGE descriptor_range;
D3D12_ROOT_PARAMETER root_parameters[2];
- D3D12_STATIC_SAMPLER_DESC sampler_desc;
HRESULT hr;
- memset(&sampler_desc, 0, sizeof(sampler_desc));
- sampler_desc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT;
- sampler_desc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
- sampler_desc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
- sampler_desc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
- sampler_desc.MaxLOD = D3D12_FLOAT32_MAX;
- sampler_desc.ShaderRegister = 0;
- sampler_desc.RegisterSpace = 0;
- sampler_desc.ShaderVisibility = shader_visibility;
+ if (sampler_desc)
+ {
+ static_sampler = *sampler_desc;
+ }
+ else
+ {
+ memset(&static_sampler, 0, sizeof(static_sampler));
+ static_sampler.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT;
+ static_sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
+ static_sampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
+ static_sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
+ static_sampler.MaxLOD = D3D12_FLOAT32_MAX;
+ static_sampler.ShaderRegister = 0;
+ static_sampler.RegisterSpace = 0;
+ static_sampler.ShaderVisibility = shader_visibility;
+ }
descriptor_range.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
descriptor_range.NumDescriptors = 1;
@@ -979,7 +987,7 @@ static ID3D12RootSignature *create_texture_root_signature_(unsigned int line,
root_signature_desc.NumParameters = constant_count ? 2 : 1;
root_signature_desc.pParameters = root_parameters;
root_signature_desc.NumStaticSamplers = 1;
- root_signature_desc.pStaticSamplers = &sampler_desc;
+ root_signature_desc.pStaticSamplers = &static_sampler;
root_signature_desc.Flags = flags;
hr = create_root_signature(device, &root_signature_desc, &root_signature);
@@ -9963,6 +9971,270 @@ static void test_gather(void)
destroy_test_context(&context);
}
+static void test_gather_c(void)
+{
+ struct
+ {
+ int width, height;
+ int offset_x, offset_y;
+ float d_ref;
+ } constants;
+
+ D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc;
+ ID3D12GraphicsCommandList *command_list;
+ D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle;
+ D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle;
+ struct test_context_desc desc;
+ struct resource_readback rb;
+ struct test_context context;
+ ID3D12DescriptorHeap *heap;
+ ID3D12CommandQueue *queue;
+ ID3D12Resource *texture;
+ unsigned int x, y;
+
+ static const DWORD gather4_c_code[] =
+ {
+#if 0
+ SamplerComparisonState s;
+ Texture2D<float4> t;
+
+ int2 size;
+ int2 offset;
+ float d_ref;
+
+ float4 main(float4 position : SV_Position) : SV_Target
+ {
+ return t.GatherCmp(s, position.xy / size, d_ref);
+ }
+#endif
+ 0x43425844, 0xd3d04479, 0x901e9208, 0x7074fd0c, 0xbcadb2da, 0x00000001, 0x00000168, 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, 0x000000cc, 0x00000050,
+ 0x00000033, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300085a, 0x00106000,
+ 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
+ 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
+ 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
+ 0x00000000, 0x00100046, 0x00000000, 0x8e00007e, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
+ 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x0010600a, 0x00000000, 0x0020800a, 0x00000000,
+ 0x00000001, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps_gather4_c = {gather4_c_code, sizeof(gather4_c_code)};
+ static const DWORD gather4_po_c_code[] =
+ {
+#if 0
+ SamplerComparisonState s;
+ Texture2D<float4> t;
+
+ int2 size;
+ int2 offset;
+ float d_ref;
+
+ float4 main(float4 position : SV_Position) : SV_Target
+ {
+ return t.GatherCmp(s, position.xy / size, d_ref, offset);
+ }
+#endif
+ 0x43425844, 0x501de13e, 0x472d2d20, 0x6df0fee4, 0xef27d9e6, 0x00000001, 0x00000174, 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, 0x000000d8, 0x00000050,
+ 0x00000036, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300085a, 0x00106000,
+ 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000,
+ 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600002b, 0x00100032,
+ 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x0700000e, 0x00100032, 0x00000000, 0x00101046,
+ 0x00000000, 0x00100046, 0x00000000, 0x91000080, 0x800000c2, 0x00155543, 0x001020f2, 0x00000000,
+ 0x00100046, 0x00000000, 0x00208ae6, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x0010600a,
+ 0x00000000, 0x0020800a, 0x00000000, 0x00000001, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps_gather4_po_c = {gather4_po_c_code, sizeof(gather4_po_c_code)};
+ static const float texture_data[] =
+ {
+ 0.0f, 1.0f, 0.20f, 0.30f,
+ 0.4f, 0.5f, 0.60f, 0.70f,
+ 0.8f, 0.9f, 0.50f, 0.15f,
+ 0.2f, 0.3f, 0.45f, 0.55f,
+ };
+ static const struct vec4 expected_gather4_c[] =
+ {
+ {0.0f, 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 0.0f, 0.0f},
+ {1.0f, 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 0.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 1.0f, 1.0f},
+ {0.0f, 0.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 1.0f, 1.0f}, {0.0f, 1.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f},
+ };
+ static const struct vec4 expected_gather4_po_c[] =
+ {
+ {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 0.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 1.0f, 1.0f},
+ {0.0f, 0.0f, 1.0f, 1.0f}, {0.0f, 1.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f},
+ {0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f},
+ };
+ static const struct vec4 white = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const D3D12_SUBRESOURCE_DATA resource_data = {&texture_data, sizeof(texture_data) / 4};
+ static const D3D12_STATIC_SAMPLER_DESC sampler_desc =
+ {
+ .Filter = D3D12_FILTER_COMPARISON_MIN_MAG_MIP_POINT,
+ .AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP,
+ .AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP,
+ .AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP,
+ .ComparisonFunc = D3D12_COMPARISON_FUNC_LESS,
+ .MaxLOD = D3D12_FLOAT32_MAX,
+ .ShaderRegister = 0,
+ .RegisterSpace = 0,
+ .ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL,
+ };
+
+ memset(&desc, 0, sizeof(desc));
+ desc.rt_width = 4;
+ desc.rt_height = 4;
+ desc.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT;
+ desc.no_root_signature = true;
+ if (!init_test_context(&context, &desc))
+ return;
+ command_list = context.list;
+ queue = context.queue;
+
+ context.root_signature = create_texture_root_signature_(__LINE__, context.device,
+ D3D12_SHADER_VISIBILITY_PIXEL, 5, 0, &sampler_desc);
+
+ heap = create_gpu_descriptor_heap(context.device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 1);
+ cpu_handle = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap);
+ gpu_handle = ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(heap);
+
+ texture = create_default_texture(context.device, 4, 4, DXGI_FORMAT_R32_TYPELESS,
+ 0, D3D12_RESOURCE_STATE_COPY_DEST);
+ upload_texture_data(texture, &resource_data, 1, queue, command_list);
+ reset_command_list(command_list, context.allocator);
+ transition_resource_state(command_list, texture,
+ D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
+
+ memset(&srv_desc, 0, sizeof(srv_desc));
+ srv_desc.Format = DXGI_FORMAT_R32_FLOAT;
+ srv_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
+ srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
+ srv_desc.Texture2D.MipLevels = 1;
+ ID3D12Device_CreateShaderResourceView(context.device, texture, &srv_desc, cpu_handle);
+
+ constants.width = 4;
+ constants.height = 4;
+ constants.offset_x = 1;
+ constants.offset_y = 1;
+ constants.d_ref = 0.46f;
+
+ /* ps_gather4_c */
+ context.pipeline_state = create_pipeline_state(context.device,
+ context.root_signature, desc.rt_format, NULL, &ps_gather4_c, NULL);
+
+ ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 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, gpu_handle);
+ ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 1, 5, &constants.width, 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_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list);
+ for (y = 0; y < rb.height; ++y)
+ {
+ for (x = 0; x < rb.width; ++x)
+ {
+ const struct vec4 *expected = &expected_gather4_c[y * rb.width + x];
+ const struct vec4 *got = get_readback_vec4(&rb, x, y);
+ ok(compare_vec4(got, expected, 0),
+ "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
+ got->x, got->y, got->z, got->w, expected->x, expected->y, expected->z, expected->w);
+ }
+ }
+ release_resource_readback(&rb);
+
+ ID3D12PipelineState_Release(context.pipeline_state);
+ reset_command_list(command_list, context.allocator);
+ transition_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
+
+ /* ps_gather4_po_c */
+ context.pipeline_state = create_pipeline_state(context.device,
+ context.root_signature, desc.rt_format, NULL, &ps_gather4_po_c, NULL);
+
+ ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 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, gpu_handle);
+ ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 1, 5, &constants.width, 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_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list);
+ for (y = 0; y < rb.height; ++y)
+ {
+ for (x = 0; x < rb.width; ++x)
+ {
+ const struct vec4 *expected = &expected_gather4_po_c[y * rb.width + x];
+ const struct vec4 *got = get_readback_vec4(&rb, x, y);
+ ok(compare_vec4(got, expected, 0),
+ "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
+ got->x, got->y, got->z, got->w, expected->x, expected->y, expected->z, expected->w);
+ }
+ }
+ release_resource_readback(&rb);
+
+ reset_command_list(command_list, context.allocator);
+ transition_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
+
+ constants.offset_x = 0;
+ constants.offset_y = 0;
+
+ ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 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, gpu_handle);
+ ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 1, 5, &constants.width, 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_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list);
+ for (y = 0; y < rb.height; ++y)
+ {
+ for (x = 0; x < rb.width; ++x)
+ {
+ const struct vec4 *expected = &expected_gather4_c[y * rb.width + x];
+ const struct vec4 *got = get_readback_vec4(&rb, x, y);
+ ok(compare_vec4(got, expected, 0),
+ "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
+ got->x, got->y, got->z, got->w, expected->x, expected->y, expected->z, expected->w);
+ }
+ }
+ release_resource_readback(&rb);
+
+ ID3D12Resource_Release(texture);
+ ID3D12DescriptorHeap_Release(heap);
+ destroy_test_context(&context);
+}
+
static void test_cube_maps(void)
{
unsigned int i, j, sub_resource_idx, sub_resource_count;
@@ -19823,6 +20095,7 @@ START_TEST(d3d12)
run_test(test_texture);
run_test(test_texture_ld);
run_test(test_gather);
+ run_test(test_gather_c);
run_test(test_cube_maps);
run_test(test_descriptor_tables);
run_test(test_descriptor_tables_overlapping_bindings);
--
2.16.4
Sept. 27, 2018
[PATCH vkd3d 6/8] vkd3d-shader: Translate gather4_po_c instructions.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 07ac808c2e67..7fe35289c534 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -5332,10 +5332,10 @@ static void vkd3d_dxbc_compiler_prepare_dummy_sampled_image(struct vkd3d_dxbc_co
static void vkd3d_dxbc_compiler_prepare_sampled_image(struct vkd3d_dxbc_compiler *compiler,
struct vkd3d_shader_image *image, const struct vkd3d_shader_register *resource_reg,
- const struct vkd3d_shader_register *sampler_reg, bool depth_comparison)
+ const struct vkd3d_shader_register *sampler_reg, unsigned int flags)
{
vkd3d_dxbc_compiler_prepare_sampled_image_for_sampler(compiler, image, resource_reg,
- vkd3d_dxbc_compiler_get_register_id(compiler, sampler_reg), depth_comparison);
+ vkd3d_dxbc_compiler_get_register_id(compiler, sampler_reg), flags);
}
static uint32_t vkd3d_dxbc_compiler_emit_texel_offset(struct vkd3d_dxbc_compiler *compiler,
@@ -5489,6 +5489,7 @@ static void vkd3d_dxbc_compiler_emit_gather4(struct vkd3d_dxbc_compiler *compile
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
const struct vkd3d_shader_dst_param *dst = instruction->dst;
const struct vkd3d_shader_src_param *src = instruction->src;
+ unsigned int image_flags = VKD3D_IMAGE_FLAG_NONE;
SpvImageOperandsMask operands_mask = 0;
unsigned int image_operand_count = 0;
struct vkd3d_shader_image image;
@@ -5497,6 +5498,10 @@ static void vkd3d_dxbc_compiler_emit_gather4(struct vkd3d_dxbc_compiler *compile
DWORD coordinate_mask;
bool extended_offset;
+ if (instruction->handler_idx == VKD3DSIH_GATHER4_C
+ || instruction->handler_idx == VKD3DSIH_GATHER4_PO_C)
+ image_flags |= VKD3D_IMAGE_FLAG_DEPTH;
+
extended_offset = instruction->handler_idx == VKD3DSIH_GATHER4_PO
|| instruction->handler_idx == VKD3DSIH_GATHER4_PO_C;
@@ -5506,7 +5511,7 @@ static void vkd3d_dxbc_compiler_emit_gather4(struct vkd3d_dxbc_compiler *compile
sampler = &src[2 + extended_offset];
vkd3d_dxbc_compiler_prepare_sampled_image(compiler, &image,
- &resource->reg, &sampler->reg, VKD3D_IMAGE_FLAG_NONE);
+ &resource->reg, &sampler->reg, image_flags);
if (offset)
{
@@ -5525,7 +5530,7 @@ static void vkd3d_dxbc_compiler_emit_gather4(struct vkd3d_dxbc_compiler *compile
sampled_type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, VKD3D_VEC4_SIZE);
coordinate_mask = (1u << image.resource_type_info->coordinate_component_count) - 1;
coordinate_id = vkd3d_dxbc_compiler_emit_load_src(compiler, addr, coordinate_mask);
- if (instruction->handler_idx == VKD3DSIH_GATHER4_C)
+ if (image_flags & VKD3D_IMAGE_FLAG_DEPTH)
{
dref_id = vkd3d_dxbc_compiler_emit_load_src(compiler,
&src[3 + extended_offset], VKD3DSP_WRITEMASK_0);
@@ -6414,6 +6419,7 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler
case VKD3DSIH_GATHER4:
case VKD3DSIH_GATHER4_C:
case VKD3DSIH_GATHER4_PO:
+ case VKD3DSIH_GATHER4_PO_C:
vkd3d_dxbc_compiler_emit_gather4(compiler, instruction);
break;
case VKD3DSIH_LD_RAW:
--
2.16.4
Sept. 27, 2018
[PATCH vkd3d 5/8] vkd3d-shader: Translate retc instructions.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 19 +++++++++++++++++++
tests/d3d12.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 62e1f3f9d5ec..07ac808c2e67 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -4817,6 +4817,20 @@ static void vkd3d_dxbc_compiler_emit_return(struct vkd3d_dxbc_compiler *compiler
vkd3d_spirv_build_op_return(builder);
}
+static void vkd3d_dxbc_compiler_emit_retc(struct vkd3d_dxbc_compiler *compiler,
+ const struct vkd3d_shader_instruction *instruction)
+{
+ struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
+ uint32_t target_id, merge_block_id;
+
+ target_id = vkd3d_spirv_alloc_id(builder);
+ merge_block_id = vkd3d_dxbc_compiler_emit_conditional_branch(compiler, instruction, target_id);
+
+ vkd3d_spirv_build_op_label(builder, target_id);
+ vkd3d_dxbc_compiler_emit_return(compiler, instruction);
+ vkd3d_spirv_build_op_label(builder, merge_block_id);
+}
+
static void vkd3d_dxbc_compiler_emit_kill(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction)
{
@@ -5166,6 +5180,10 @@ static void vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_
cf_info->inside_block = false;
break;
+ case VKD3DSIH_RETP:
+ vkd3d_dxbc_compiler_emit_retc(compiler, instruction);
+ break;
+
case VKD3DSIH_TEXKILL:
vkd3d_dxbc_compiler_emit_kill(compiler, instruction);
break;
@@ -6369,6 +6387,7 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler
case VKD3DSIH_IF:
case VKD3DSIH_LOOP:
case VKD3DSIH_RET:
+ case VKD3DSIH_RETP:
case VKD3DSIH_SWITCH:
case VKD3DSIH_TEXKILL:
vkd3d_dxbc_compiler_emit_control_flow_instruction(compiler, instruction);
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 69b9fe7f0284..9424ca182059 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -5718,6 +5718,38 @@ static void test_shader_instructions(void)
0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e,
};
static const D3D12_SHADER_BYTECODE ps_continuec_nz = {ps_continuec_nz_code, sizeof(ps_continuec_nz_code)};
+ static const DWORD ps_retc_nz_code[] =
+ {
+#if 0
+ float src;
+
+ float4 main() : SV_TARGET
+ {
+ for (int i = 0; i < 255; ++i)
+ {
+ if (i == src)
+ return float4(1, 0, 0, 0);
+ }
+
+ return 0;
+ }
+#endif
+ /* compiled with /Gfa */
+ 0x43425844, 0xf829c302, 0xf21361cb, 0x963b87e9, 0x92f9470e, 0x00000001, 0x00000188, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040, 0x00000044,
+ 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
+ 0x00000001, 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000021,
+ 0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010001a,
+ 0x00000000, 0x0500002b, 0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x08000018, 0x00100022,
+ 0x00000000, 0x0010001a, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2,
+ 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x00000000, 0x0304003f, 0x0010001a,
+ 0x00000000, 0x0700001e, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000001,
+ 0x01000016, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps_retc_nz = {ps_retc_nz_code, sizeof(ps_retc_nz_code)};
static const DWORD ps_src_modifiers_code[] =
{
#if 0
@@ -6823,6 +6855,11 @@ static void test_shader_instructions(void)
{&ps_continue, {}, {{254.0f}}, TRUE},
{&ps_continuec_nz, {}, {{509.0f}}},
+ {&ps_retc_nz, {{ 0.0f}}, {{1.0f}}},
+ {&ps_retc_nz, {{ 10.0f}}, {{1.0f}}},
+ {&ps_retc_nz, {{ 99.0f}}, {{1.0f}}},
+ {&ps_retc_nz, {{300.0f}}, {{0.0f}}},
+
{&ps_src_modifiers, {{ 1.0f, 1.0f, 1.0f, 2.0f}}, {{-1.0f, 1.0f, -1.0f, -2.0f}}},
{&ps_src_modifiers, {{-1.0f, -1.0f, -1.0f, -2.0f}}, {{ 1.0f, 1.0f, -1.0f, -2.0f}}},
--
2.16.4
Sept. 27, 2018
[PATCH vkd3d 4/8] vkd3d-shader: Use vkd3d_dxbc_compiler_emit_conditional_branch() in more places.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index a3e8c3977b38..62e1f3f9d5ec 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -4770,7 +4770,7 @@ static void vkd3d_dxbc_compiler_emit_comparison_instruction(struct vkd3d_dxbc_co
vkd3d_dxbc_compiler_emit_store_reg(compiler, &dst->reg, dst->write_mask, result_id);
}
-static void vkd3d_dxbc_compiler_emit_conditional_branch(struct vkd3d_dxbc_compiler *compiler,
+static uint32_t vkd3d_dxbc_compiler_emit_conditional_branch(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction, uint32_t target_block_id)
{
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
@@ -4784,7 +4784,8 @@ static void vkd3d_dxbc_compiler_emit_conditional_branch(struct vkd3d_dxbc_compil
vkd3d_spirv_build_op_selection_merge(builder, merge_block_id, SpvSelectionControlMaskNone);
vkd3d_spirv_build_op_branch_conditional(builder, condition_id, target_block_id, merge_block_id);
- vkd3d_spirv_build_op_label(builder, merge_block_id);
+
+ return merge_block_id;
}
static void vkd3d_dxbc_compiler_emit_output_setup_invocation(struct vkd3d_dxbc_compiler *compiler)
@@ -4820,18 +4821,12 @@ static void vkd3d_dxbc_compiler_emit_kill(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction)
{
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
- const struct vkd3d_shader_src_param *src = instruction->src;
- uint32_t condition_id, target_block_id, merge_block_id;
+ uint32_t target_id, merge_block_id;
- condition_id = vkd3d_dxbc_compiler_emit_load_src(compiler, src, VKD3DSP_WRITEMASK_0);
- condition_id = vkd3d_dxbc_compiler_emit_int_to_bool(compiler, instruction->flags, 1, condition_id);
+ target_id = vkd3d_spirv_alloc_id(builder);
+ merge_block_id = vkd3d_dxbc_compiler_emit_conditional_branch(compiler, instruction, target_id);
- merge_block_id = vkd3d_spirv_alloc_id(builder);
- target_block_id = vkd3d_spirv_alloc_id(builder);
-
- vkd3d_spirv_build_op_selection_merge(builder, merge_block_id, SpvSelectionControlMaskNone);
- vkd3d_spirv_build_op_branch_conditional(builder, condition_id, target_block_id, merge_block_id);
- vkd3d_spirv_build_op_label(builder, target_block_id);
+ vkd3d_spirv_build_op_label(builder, target_id);
vkd3d_spirv_build_op_kill(builder);
vkd3d_spirv_build_op_label(builder, merge_block_id);
}
@@ -5126,8 +5121,9 @@ static void vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_
return;
}
- vkd3d_dxbc_compiler_emit_conditional_branch(compiler,
+ merge_block_id = vkd3d_dxbc_compiler_emit_conditional_branch(compiler,
instruction, loop_cf_info->u.loop.merge_block_id);
+ vkd3d_spirv_build_op_label(builder, merge_block_id);
break;
}
@@ -5157,8 +5153,9 @@ static void vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_
return;
}
- vkd3d_dxbc_compiler_emit_conditional_branch(compiler,
+ merge_block_id = vkd3d_dxbc_compiler_emit_conditional_branch(compiler,
instruction, loop_cf_info->u.loop.continue_block_id);
+ vkd3d_spirv_build_op_label(builder, merge_block_id);
break;
}
--
2.16.4
Sept. 27, 2018
[PATCH vkd3d 3/8] vkd3d: Fix shader stage bits for pipeline barriers.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
The Vulkan spec says:
"Any pipeline stage included in srcStageMask or dstStageMask must be
supported by the capabilities of the queue family..."
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/command.c | 49 ++++++++++++++++++++++++----------------------
libs/vkd3d/vkd3d_private.h | 5 ++++-
2 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index 031f61e34e51..5fd093617e3b 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -37,6 +37,7 @@ HRESULT vkd3d_queue_create(struct d3d12_device *device,
}
object->vk_family_index = family_index;
+ object->vk_queue_flags = properties->queueFlags;
object->timestamp_bits = properties->timestampValidBits;
VK_CALL(vkGetDeviceQueue(device->vk_device, family_index, 0, &object->vk_queue));
@@ -667,6 +668,8 @@ static HRESULT d3d12_command_allocator_allocate_command_buffer(struct d3d12_comm
return hresult_from_vk_result(vr);
}
+ list->vk_queue_flags = allocator->vk_queue_flags;
+
if (FAILED(hr = d3d12_command_list_begin_command_buffer(list)))
{
VK_CALL(vkFreeCommandBuffers(device->vk_device, allocator->vk_command_pool,
@@ -1169,6 +1172,7 @@ static HRESULT d3d12_command_allocator_init(struct d3d12_command_allocator *allo
allocator->refcount = 1;
allocator->type = type;
+ allocator->vk_queue_flags = queue->vk_queue_flags;
command_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
command_pool_info.pNext = NULL;
@@ -1297,9 +1301,22 @@ static void d3d12_command_list_invalidate_bindings(struct d3d12_command_list *li
}
static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state,
- bool is_swapchain_image, D3D12_RESOURCE_STATES present_state,
+ bool is_swapchain_image, D3D12_RESOURCE_STATES present_state, VkQueueFlags vk_queue_flags,
VkAccessFlags *access_mask, VkPipelineStageFlags *stage_flags, VkImageLayout *image_layout)
{
+ VkPipelineStageFlags queue_shader_stages = 0;
+
+ if (vk_queue_flags & VK_QUEUE_GRAPHICS_BIT)
+ {
+ queue_shader_stages |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
+ | VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
+ | VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
+ | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
+ | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
+ }
+ if (vk_queue_flags & VK_QUEUE_COMPUTE_BIT)
+ queue_shader_stages |= VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
+
switch (state)
{
case D3D12_RESOURCE_STATE_COMMON: /* D3D12_RESOURCE_STATE_PRESENT */
@@ -1321,7 +1338,7 @@ static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state,
else
{
vk_barrier_parameters_from_d3d12_resource_state(present_state,
- false, 0, access_mask, stage_flags, image_layout);
+ false, 0, vk_queue_flags, access_mask, stage_flags, image_layout);
}
}
else
@@ -1344,12 +1361,7 @@ static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state,
case D3D12_RESOURCE_STATE_UNORDERED_ACCESS:
*access_mask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
- *stage_flags = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
- | VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
- | VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
- | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
- | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
- | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
+ *stage_flags = queue_shader_stages;
if (image_layout)
*image_layout = VK_IMAGE_LAYOUT_GENERAL;
return true;
@@ -1419,12 +1431,7 @@ static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state,
*access_mask |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
| VK_ACCESS_UNIFORM_READ_BIT;
*stage_flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
- | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
- | VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
- | VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
- | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
- | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
- | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
+ | queue_shader_stages;
state &= ~D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER;
}
@@ -1446,11 +1453,7 @@ static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state,
if (state & D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE)
{
*access_mask |= VK_ACCESS_SHADER_READ_BIT;
- *stage_flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
- | VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
- | VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
- | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
- | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
+ *stage_flags |= (queue_shader_stages & ~VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
state &= ~D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
}
if (state & D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
@@ -1509,7 +1512,7 @@ static void d3d12_command_list_transition_resource_to_initial_state(struct d3d12
if (!vk_barrier_parameters_from_d3d12_resource_state(resource->initial_state,
resource->flags & VKD3D_RESOURCE_PRESENT_STATE_TRANSITION, resource->present_state,
- &barrier.dstAccessMask, &dst_stage_mask, &barrier.newLayout))
+ list->vk_queue_flags, &barrier.dstAccessMask, &dst_stage_mask, &barrier.newLayout))
{
FIXME("Unhandled state %#x.\n", resource->initial_state);
return;
@@ -3069,14 +3072,14 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsC
if (!vk_barrier_parameters_from_d3d12_resource_state(transition->StateBefore,
resource->flags & VKD3D_RESOURCE_PRESENT_STATE_TRANSITION, resource->present_state,
- &src_access_mask, &src_stage_mask, &layout_before))
+ list->vk_queue_flags, &src_access_mask, &src_stage_mask, &layout_before))
{
FIXME("Unhandled state %#x.\n", transition->StateBefore);
continue;
}
if (!vk_barrier_parameters_from_d3d12_resource_state(transition->StateAfter,
resource->flags & VKD3D_RESOURCE_PRESENT_STATE_TRANSITION, resource->present_state,
- &dst_access_mask, &dst_stage_mask, &layout_after))
+ list->vk_queue_flags, &dst_access_mask, &dst_stage_mask, &layout_after))
{
FIXME("Unhandled state %#x.\n", transition->StateAfter);
continue;
@@ -3097,7 +3100,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsC
resource = unsafe_impl_from_ID3D12Resource(uav->pResource);
vk_barrier_parameters_from_d3d12_resource_state(D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
resource && (resource->flags & VKD3D_RESOURCE_PRESENT_STATE_TRANSITION),
- resource ? resource->present_state : 0,
+ resource ? resource->present_state : 0, list->vk_queue_flags,
&access_mask, &stage_mask, &image_layout);
src_access_mask = dst_access_mask = access_mask;
src_stage_mask = dst_stage_mask = stage_mask;
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index e47e53899dc2..bffae35fb830 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -593,6 +593,7 @@ struct d3d12_command_allocator
LONG refcount;
D3D12_COMMAND_LIST_TYPE type;
+ VkQueueFlags vk_queue_flags;
VkCommandPool vk_command_pool;
@@ -658,10 +659,11 @@ struct d3d12_command_list
LONG refcount;
D3D12_COMMAND_LIST_TYPE type;
+ VkQueueFlags vk_queue_flags;
- VkCommandBuffer vk_command_buffer;
bool is_recording;
bool is_valid;
+ VkCommandBuffer vk_command_buffer;
uint32_t strides[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
VkPrimitiveTopology primitive_topology;
@@ -692,6 +694,7 @@ struct vkd3d_queue
pthread_mutex_t mutex;
VkQueue vk_queue;
uint32_t vk_family_index;
+ VkQueueFlags vk_queue_flags;
uint32_t timestamp_bits;
};
--
2.16.4
Sept. 27, 2018
[PATCH vkd3d 2/8] vkd3d: Pass VkQueueFamilyProperties to vkd3d_queue_create().
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/command.c | 4 ++--
libs/vkd3d/device.c | 44 ++++++++++++++------------------------------
libs/vkd3d/vkd3d_private.h | 3 ++-
3 files changed, 18 insertions(+), 33 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index a7cac8f72653..031f61e34e51 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -20,7 +20,7 @@
#include "vkd3d_private.h"
HRESULT vkd3d_queue_create(struct d3d12_device *device,
- uint32_t family_index, uint32_t timestamp_bits, struct vkd3d_queue **queue)
+ uint32_t family_index, const VkQueueFamilyProperties *properties, struct vkd3d_queue **queue)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
struct vkd3d_queue *object;
@@ -37,7 +37,7 @@ HRESULT vkd3d_queue_create(struct d3d12_device *device,
}
object->vk_family_index = family_index;
- object->timestamp_bits = timestamp_bits;
+ object->timestamp_bits = properties->timestampValidBits;
VK_CALL(vkGetDeviceQueue(device->vk_device, family_index, 0, &object->vk_queue));
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 1a8f9a0f1444..3a9dad03ef91 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -952,9 +952,8 @@ static void d3d12_device_destroy_vkd3d_queues(struct d3d12_device *device)
}
static HRESULT d3d12_device_create_vkd3d_queues(struct d3d12_device *device,
- uint32_t direct_queue_family_index, uint32_t direct_queue_timestamp_bits,
- uint32_t compute_queue_family_index, uint32_t compute_queue_timestamp_bits,
- uint32_t copy_queue_family_index, uint32_t copy_queue_timestamp_bits)
+ const VkQueueFamilyProperties *queue_properties, uint32_t direct_queue_family_index,
+ uint32_t compute_queue_family_index, uint32_t copy_queue_family_index)
{
HRESULT hr;
@@ -963,39 +962,33 @@ static HRESULT d3d12_device_create_vkd3d_queues(struct d3d12_device *device,
device->copy_queue = NULL;
if (FAILED((hr = vkd3d_queue_create(device, direct_queue_family_index,
- direct_queue_timestamp_bits, &device->direct_queue))))
- {
- d3d12_device_destroy_vkd3d_queues(device);
- return hr;
- }
+ &queue_properties[direct_queue_family_index], &device->direct_queue))))
+ goto out_destroy_queues;
if (compute_queue_family_index == direct_queue_family_index)
device->compute_queue = device->direct_queue;
else if (FAILED(hr = vkd3d_queue_create(device, compute_queue_family_index,
- compute_queue_timestamp_bits, &device->compute_queue)))
- {
- d3d12_device_destroy_vkd3d_queues(device);
- return hr;
- }
+ &queue_properties[compute_queue_family_index], &device->compute_queue)))
+ goto out_destroy_queues;
if (copy_queue_family_index == direct_queue_family_index)
device->copy_queue = device->direct_queue;
else if (copy_queue_family_index == compute_queue_family_index)
device->copy_queue = device->compute_queue;
else if (FAILED(hr = vkd3d_queue_create(device, copy_queue_family_index,
- copy_queue_timestamp_bits, &device->copy_queue)))
- {
- d3d12_device_destroy_vkd3d_queues(device);
- return hr;
- }
+ &queue_properties[copy_queue_family_index], &device->copy_queue)))
+ goto out_destroy_queues;
return S_OK;
+
+out_destroy_queues:
+ d3d12_device_destroy_vkd3d_queues(device);
+ return hr;
}
static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
const struct vkd3d_device_create_info *create_info)
{
- uint32_t direct_queue_timestamp_bits, copy_queue_timestamp_bits, compute_queue_timestamp_bits;
unsigned int direct_queue_family_index, copy_queue_family_index, compute_queue_family_index;
const struct vkd3d_vk_instance_procs *vk_procs = &device->vkd3d_instance->vk_procs;
VkQueueFamilyProperties *queue_properties = NULL;
@@ -1032,11 +1025,8 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
}
direct_queue_family_index = ~0u;
- direct_queue_timestamp_bits = 0;
copy_queue_family_index = ~0u;
- copy_queue_timestamp_bits = 0;
compute_queue_family_index = ~0u;
- compute_queue_timestamp_bits = 0;
for (i = 0; i < queue_family_count; ++i)
{
static float priorities[] = {1.0f};
@@ -1052,18 +1042,15 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
== (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT))
{
direct_queue_family_index = i;
- direct_queue_timestamp_bits = queue_properties[i].timestampValidBits;
}
if (queue_properties[i].queueFlags & VK_QUEUE_TRANSFER_BIT)
{
copy_queue_family_index = i;
- copy_queue_timestamp_bits = queue_properties[i].timestampValidBits;
}
if ((queue_properties[i].queueFlags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT))
== VK_QUEUE_COMPUTE_BIT)
{
compute_queue_family_index = i;
- compute_queue_timestamp_bits = queue_properties[i].timestampValidBits;
}
}
@@ -1083,7 +1070,6 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
{
/* No compute-only queue family, reuse the direct queue family with graphics and compute. */
compute_queue_family_index = direct_queue_family_index;
- compute_queue_timestamp_bits = direct_queue_timestamp_bits;
}
TRACE("Using queue family %u for direct command queues.\n", direct_queue_family_index);
@@ -1137,10 +1123,8 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
device->vk_device = vk_device;
- if (FAILED(hr = d3d12_device_create_vkd3d_queues(device,
- direct_queue_family_index, direct_queue_timestamp_bits,
- compute_queue_family_index, compute_queue_timestamp_bits,
- copy_queue_family_index, copy_queue_timestamp_bits)))
+ if (FAILED(hr = d3d12_device_create_vkd3d_queues(device, queue_properties,
+ direct_queue_family_index, compute_queue_family_index, copy_queue_family_index)))
{
ERR("Failed to create queues, hr %#x.\n", hr);
device->vk_procs.vkDestroyDevice(vk_device, NULL);
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index aca0e5098b79..e47e53899dc2 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -696,7 +696,8 @@ struct vkd3d_queue
};
HRESULT vkd3d_queue_create(struct d3d12_device *device,
- uint32_t family_index, uint32_t timestamp_bits, struct vkd3d_queue **queue) DECLSPEC_HIDDEN;
+ uint32_t family_index, const VkQueueFamilyProperties *properties,
+ struct vkd3d_queue **queue) DECLSPEC_HIDDEN;
void vkd3d_queue_destroy(struct vkd3d_queue *queue) DECLSPEC_HIDDEN;
/* ID3D12CommandQueue */
--
2.16.4
Sept. 27, 2018
[PATCH vkd3d 1/8] vkd3d: Simplify error handling in vkd3d_create_vk_device().
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/device.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 8cc61420bab9..1a8f9a0f1444 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -998,9 +998,9 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
uint32_t direct_queue_timestamp_bits, copy_queue_timestamp_bits, compute_queue_timestamp_bits;
unsigned int direct_queue_family_index, copy_queue_family_index, compute_queue_family_index;
const struct vkd3d_vk_instance_procs *vk_procs = &device->vkd3d_instance->vk_procs;
- VkQueueFamilyProperties *queue_properties;
+ VkQueueFamilyProperties *queue_properties = NULL;
+ VkDeviceQueueCreateInfo *queue_info = NULL;
VkPhysicalDeviceFeatures device_features;
- VkDeviceQueueCreateInfo *queue_info;
VkPhysicalDevice physical_device;
VkDeviceCreateInfo device_info;
uint32_t queue_family_count;
@@ -1027,8 +1027,8 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
if (!(queue_info = vkd3d_calloc(queue_family_count, sizeof(*queue_info))))
{
- vkd3d_free(queue_properties);
- return E_OUTOFMEMORY;
+ hr = E_OUTOFMEMORY;
+ goto fail;
}
direct_queue_family_index = ~0u;
@@ -1066,19 +1066,18 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
compute_queue_timestamp_bits = queue_properties[i].timestampValidBits;
}
}
- vkd3d_free(queue_properties);
if (direct_queue_family_index == ~0u)
{
FIXME("Could not find a suitable queue family for a direct command queue.\n");
- vkd3d_free(queue_info);
- return E_FAIL;
+ hr = E_FAIL;
+ goto fail;
}
if (copy_queue_family_index == ~0u)
{
FIXME("Could not find a suitable queue family for a copy command queue.\n");
- vkd3d_free(queue_info);
- return E_FAIL;
+ hr = E_FAIL;
+ goto fail;
}
if (compute_queue_family_index == ~0u)
{
@@ -1096,15 +1095,12 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
VK_CALL(vkGetPhysicalDeviceFeatures(physical_device, &device_features));
device->vk_physical_device = physical_device;
if (FAILED(hr = vkd3d_init_device_caps(device, create_info, &device_features, &extension_count)))
- {
- vkd3d_free(queue_info);
- return E_FAIL;
- }
+ goto fail;
if (!(extensions = vkd3d_calloc(extension_count, sizeof(*extensions))))
{
- vkd3d_free(queue_info);
- return E_OUTOFMEMORY;
+ hr = E_OUTOFMEMORY;
+ goto fail;
}
/* Create device */
@@ -1125,7 +1121,6 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
vr = VK_CALL(vkCreateDevice(physical_device, &device_info, NULL, &vk_device));
vkd3d_free(extensions);
- vkd3d_free(queue_info);
if (vr < 0)
{
ERR("Failed to create Vulkan device, vr %d.\n", vr);
@@ -1137,7 +1132,7 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
ERR("Failed to load device procs, hr %#x.\n", hr);
if (device->vk_procs.vkDestroyDevice)
device->vk_procs.vkDestroyDevice(vk_device, NULL);
- return hr;
+ goto fail;
}
device->vk_device = vk_device;
@@ -1149,12 +1144,17 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device,
{
ERR("Failed to create queues, hr %#x.\n", hr);
device->vk_procs.vkDestroyDevice(vk_device, NULL);
- return hr;
+ goto fail;
}
TRACE("Created Vulkan device %p.\n", vk_device);
- return S_OK;
+fail:
+ if (queue_properties)
+ vkd3d_free(queue_properties);
+ if (queue_info)
+ vkd3d_free(queue_info);
+ return hr;
}
static HRESULT d3d12_device_create_dummy_sampler(struct d3d12_device *device)
--
2.16.4
Sept. 27, 2018