Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/HansKristian-Work/vkd3d-proton.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2022-03-18 18:01:28 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2022-09-13 17:04:58 +0300
commit9bc981dd4a3e0514435d8623330b8d29d80558a7 (patch)
treeef79bca1830e5731e1a037f97e875a7e81dc2534
parentcbad3d27b5520086e18ab8bcc6dcd7b7c36714e5 (diff)
vkd3d: Refactor out shader interface struct plumbing.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
-rw-r--r--libs/vkd3d/state.c75
1 files changed, 33 insertions, 42 deletions
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index d1f6c66e..c4348d99 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2389,34 +2389,41 @@ static HRESULT vkd3d_create_compute_pipeline(struct d3d12_device *device,
return S_OK;
}
+static void d3d12_pipeline_state_init_shader_interface(struct d3d12_pipeline_state *state,
+ struct d3d12_device *device,
+ VkShaderStageFlagBits stage,
+ struct vkd3d_shader_interface_info *shader_interface)
+{
+ const struct d3d12_root_signature *root_signature = state->root_signature;
+ memset(shader_interface, 0, sizeof(*shader_interface));
+ shader_interface->flags = d3d12_root_signature_get_shader_interface_flags(root_signature);
+ shader_interface->min_ssbo_alignment = d3d12_device_get_ssbo_alignment(device);
+ shader_interface->descriptor_tables.offset = root_signature->descriptor_table_offset;
+ shader_interface->descriptor_tables.count = root_signature->descriptor_table_count;
+ shader_interface->bindings = root_signature->bindings;
+ shader_interface->binding_count = root_signature->binding_count;
+ shader_interface->push_constant_buffers = root_signature->root_constants;
+ shader_interface->push_constant_buffer_count = root_signature->root_constant_count;
+ shader_interface->push_constant_ubo_binding = &root_signature->push_constant_ubo_binding;
+ shader_interface->offset_buffer_binding = &root_signature->offset_buffer_binding;
+ shader_interface->stage = stage;
+#ifdef VKD3D_ENABLE_DESCRIPTOR_QA
+ shader_interface->descriptor_qa_global_binding = &root_signature->descriptor_qa_global_info;
+ shader_interface->descriptor_qa_heap_binding = &root_signature->descriptor_qa_heap_binding;
+#endif
+}
+
static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *state,
struct d3d12_device *device, const struct d3d12_pipeline_state_desc *desc,
const struct d3d12_cached_pipeline_state *cached_pso)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
struct vkd3d_shader_interface_info shader_interface;
- const struct d3d12_root_signature *root_signature;
HRESULT hr;
state->pipeline_type = VKD3D_PIPELINE_TYPE_COMPUTE;
- root_signature = state->root_signature;
-
- memset(&shader_interface, 0, sizeof(shader_interface));
- shader_interface.flags = d3d12_root_signature_get_shader_interface_flags(root_signature);
- shader_interface.min_ssbo_alignment = d3d12_device_get_ssbo_alignment(device);
- shader_interface.descriptor_tables.offset = root_signature->descriptor_table_offset;
- shader_interface.descriptor_tables.count = root_signature->descriptor_table_count;
- shader_interface.bindings = root_signature->bindings;
- shader_interface.binding_count = root_signature->binding_count;
- shader_interface.push_constant_buffers = root_signature->root_constants;
- shader_interface.push_constant_buffer_count = root_signature->root_constant_count;
- shader_interface.push_constant_ubo_binding = &root_signature->push_constant_ubo_binding;
- shader_interface.offset_buffer_binding = &root_signature->offset_buffer_binding;
- shader_interface.stage = VK_SHADER_STAGE_COMPUTE_BIT;
-#ifdef VKD3D_ENABLE_DESCRIPTOR_QA
- shader_interface.descriptor_qa_global_binding = &root_signature->descriptor_qa_global_info;
- shader_interface.descriptor_qa_heap_binding = &root_signature->descriptor_qa_heap_binding;
-#endif
+ d3d12_pipeline_state_init_shader_interface(state, device,
+ VK_SHADER_STAGE_COMPUTE_BIT, &shader_interface);
if (!(vkd3d_config_flags & VKD3D_CONFIG_FLAG_GLOBAL_PIPELINE_CACHE))
{
@@ -2432,7 +2439,7 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st
hr = vkd3d_create_compute_pipeline(device,
&desc->cs, &shader_interface,
- root_signature->compute.vk_pipeline_layout,
+ state->root_signature->compute.vk_pipeline_layout,
state->vk_pso_cache,
&state->compute.vk_pipeline,
&state->compute.code);
@@ -3115,7 +3122,6 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
struct vkd3d_shader_parameter ps_shader_parameters[1];
struct vkd3d_shader_transform_feedback_info xfb_info;
struct vkd3d_shader_interface_info shader_interface;
- const struct d3d12_root_signature *root_signature;
bool have_attachment, can_compile_pipeline_early;
struct vkd3d_shader_stage_io_map ms_ps_interface;
struct vkd3d_shader_signature output_signature;
@@ -3168,8 +3174,6 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
}
}
- root_signature = state->root_signature;
-
sample_count = vk_samples_from_dxgi_sample_desc(&desc->sample_desc);
if (desc->sample_desc.Count != 1 && desc->sample_desc.Quality)
WARN("Ignoring sample quality %u.\n", desc->sample_desc.Quality);
@@ -3341,7 +3345,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
graphics->xfb_enabled = false;
if (so_desc->NumEntries)
{
- if (!(root_signature->d3d12_flags & D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT))
+ if (!(state->root_signature->d3d12_flags & D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT))
{
WARN("Stream output is used without D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT.\n");
hr = E_INVALIDARG;
@@ -3370,21 +3374,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
xfb_stage = VK_SHADER_STAGE_VERTEX_BIT;
}
- memset(&shader_interface, 0, sizeof(shader_interface));
- shader_interface.flags = d3d12_root_signature_get_shader_interface_flags(root_signature);
- shader_interface.min_ssbo_alignment = d3d12_device_get_ssbo_alignment(device);
- shader_interface.descriptor_tables.offset = root_signature->descriptor_table_offset;
- shader_interface.descriptor_tables.count = root_signature->descriptor_table_count;
- shader_interface.bindings = root_signature->bindings;
- shader_interface.binding_count = root_signature->binding_count;
- shader_interface.push_constant_buffers = root_signature->root_constants;
- shader_interface.push_constant_buffer_count = root_signature->root_constant_count;
- shader_interface.push_constant_ubo_binding = &root_signature->push_constant_ubo_binding;
- shader_interface.offset_buffer_binding = &root_signature->offset_buffer_binding;
-#ifdef VKD3D_ENABLE_DESCRIPTOR_QA
- shader_interface.descriptor_qa_global_binding = &root_signature->descriptor_qa_global_info;
- shader_interface.descriptor_qa_heap_binding = &root_signature->descriptor_qa_heap_binding;
-#endif
+ /* Stage / XFB info are overridden later. */
+ d3d12_pipeline_state_init_shader_interface(state, device, VK_SHADER_STAGE_ALL, &shader_interface);
graphics->patch_vertex_count = 0;
@@ -3528,7 +3519,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
}
if (graphics->attribute_count
- && !(root_signature->d3d12_flags & D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT))
+ && !(state->root_signature->d3d12_flags & D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT))
{
WARN("Input layout is used without D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT.\n");
hr = E_INVALIDARG;
@@ -3719,7 +3710,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
if (graphics->stage_flags & VK_SHADER_STAGE_MESH_BIT_EXT)
{
can_compile_pipeline_early = true;
- graphics->pipeline_layout = root_signature->mesh.vk_pipeline_layout;
+ graphics->pipeline_layout = state->root_signature->mesh.vk_pipeline_layout;
}
else
{
@@ -3728,7 +3719,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
can_compile_pipeline_early =
(desc->primitive_topology_type != D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH || graphics->patch_vertex_count != 0) &&
desc->primitive_topology_type != D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED;
- graphics->pipeline_layout = root_signature->graphics.vk_pipeline_layout;
+ graphics->pipeline_layout = state->root_signature->graphics.vk_pipeline_layout;
}
graphics->pipeline = VK_NULL_HANDLE;