diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-03-18 19:05:43 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-09-14 13:52:31 +0300 |
commit | 363556470b91cdd14d1b8df277dc61e56262e893 (patch) | |
tree | 2a18e6e3dd3506b2d9664e2e2156211c14f5acf0 | |
parent | 07446261ec94db14f2dc89d528f2e3d294d08e10 (diff) |
vkd3d: Sink shader interface struct build to where we need it.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
-rw-r--r-- | libs/vkd3d/state.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 0f5a8c06..54ac3c57 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -2239,14 +2239,23 @@ static HRESULT vkd3d_load_spirv_from_cached_state(struct d3d12_device *device, return hr; } -static HRESULT vkd3d_create_shader_stage(struct d3d12_device *device, +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); + +static void d3d12_pipeline_state_init_compile_arguments(struct d3d12_pipeline_state *state, + struct d3d12_device *device, VkShaderStageFlagBits stage, + struct vkd3d_shader_compile_arguments *compile_arguments); + +static HRESULT vkd3d_create_shader_stage(struct d3d12_pipeline_state *state, struct d3d12_device *device, VkPipelineShaderStageCreateInfo *stage_desc, VkShaderStageFlagBits stage, VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT *required_subgroup_size_info, - const D3D12_SHADER_BYTECODE *code, - const struct vkd3d_shader_interface_info *shader_interface, - const struct vkd3d_shader_compile_arguments *compile_args, struct vkd3d_shader_code *spirv_code) + const D3D12_SHADER_BYTECODE *code, struct vkd3d_shader_code *spirv_code) { struct vkd3d_shader_code dxbc = {code->pShaderBytecode, code->BytecodeLength}; + struct vkd3d_shader_interface_info shader_interface; + struct vkd3d_shader_compile_arguments compile_args; vkd3d_shader_hash_t recovered_hash = 0; vkd3d_shader_hash_t compiled_hash = 0; int ret; @@ -2268,7 +2277,11 @@ static HRESULT vkd3d_create_shader_stage(struct d3d12_device *device, if (!spirv_code->code) { TRACE("Calling vkd3d_shader_compile_dxbc.\n"); - if ((ret = vkd3d_shader_compile_dxbc(&dxbc, spirv_code, 0, shader_interface, compile_args)) < 0) + + d3d12_pipeline_state_init_shader_interface(state, device, stage, &shader_interface); + d3d12_pipeline_state_init_compile_arguments(state, device, stage, &compile_args); + + if ((ret = vkd3d_shader_compile_dxbc(&dxbc, spirv_code, 0, &shader_interface, &compile_args)) < 0) { WARN("Failed to compile shader, vkd3d result %d.\n", ret); return hresult_from_vkd3d_result(ret); @@ -2401,7 +2414,6 @@ static void d3d12_pipeline_state_init_compile_arguments(struct d3d12_pipeline_st static HRESULT vkd3d_create_compute_pipeline(struct d3d12_pipeline_state *state, struct d3d12_device *device, const D3D12_SHADER_BYTECODE *code, - const struct vkd3d_shader_interface_info *shader_interface, VkPipelineLayout vk_pipeline_layout, VkPipelineCache vk_cache, VkPipeline *vk_pipeline, struct vkd3d_shader_code *spirv_code) { @@ -2409,22 +2421,19 @@ static HRESULT vkd3d_create_compute_pipeline(struct d3d12_pipeline_state *state, const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; VkPipelineCreationFeedbackCreateInfoEXT feedback_info; struct vkd3d_shader_debug_ring_spec_info spec_info; - struct vkd3d_shader_compile_arguments compile_args; VkPipelineCreationFeedbackEXT feedbacks[1]; VkComputePipelineCreateInfo pipeline_info; VkPipelineCreationFeedbackEXT feedback; VkResult vr; HRESULT hr; - d3d12_pipeline_state_init_compile_arguments(state, device, VK_SHADER_STAGE_COMPUTE_BIT, &compile_args); - pipeline_info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO; pipeline_info.pNext = NULL; pipeline_info.flags = 0; - if (FAILED(hr = vkd3d_create_shader_stage(device, + if (FAILED(hr = vkd3d_create_shader_stage(state, device, &pipeline_info.stage, VK_SHADER_STAGE_COMPUTE_BIT, &required_subgroup_size_info, - code, shader_interface, &compile_args, spirv_code))) + code, spirv_code))) return hr; pipeline_info.layout = vk_pipeline_layout; pipeline_info.basePipelineHandle = VK_NULL_HANDLE; @@ -2486,6 +2495,9 @@ static void d3d12_pipeline_state_init_shader_interface(struct d3d12_pipeline_sta 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; + shader_interface->xfb_info = state->pipeline_type == VKD3D_PIPELINE_TYPE_GRAPHICS && + stage == state->graphics.cached_desc.xfb_stage ? + state->graphics.cached_desc.xfb_info : NULL; if (stage == VK_SHADER_STAGE_MESH_BIT_EXT) { @@ -2528,7 +2540,7 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st VK_SHADER_STAGE_COMPUTE_BIT, &state->compute.code); hr = vkd3d_create_compute_pipeline(state, device, - &desc->cs, &shader_interface, + &desc->cs, state->root_signature->compute.vk_pipeline_layout, state->vk_pso_cache, &state->compute.vk_pipeline, @@ -3532,23 +3544,13 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s for (i = 0; i < ARRAY_SIZE(shader_stages); i++) { const D3D12_SHADER_BYTECODE *b = (const void *)((uintptr_t)desc + shader_stages[i].offset); - struct vkd3d_shader_interface_info shader_interface; - struct vkd3d_shader_compile_arguments compile_args; if (!(graphics->stage_flags & shader_stages[i].stage)) continue; - /* TODO: Move this to vkd3d_create_shader_stage itself. */ - d3d12_pipeline_state_init_shader_interface(state, device, shader_stages[i].stage, - &shader_interface); - shader_interface.xfb_info = shader_stages[i].stage == graphics->cached_desc.xfb_stage ? - graphics->cached_desc.xfb_info : NULL; - d3d12_pipeline_state_init_compile_arguments(state, device, shader_interface.stage, &compile_args); - - if (FAILED(hr = vkd3d_create_shader_stage(device, + if (FAILED(hr = vkd3d_create_shader_stage(state, device, &graphics->stages[stage_count], - shader_stages[i].stage, NULL, b, &shader_interface, - &compile_args, + shader_stages[i].stage, NULL, b, &graphics->code[stage_count]))) goto fail; |