diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-03-21 14:26:53 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-09-14 16:48:23 +0300 |
commit | e0b566ce995cb14717fad5d3370368a96c5d4823 (patch) | |
tree | 2008359e5d25d836af4d3573d8978a283063c4a7 | |
parent | a5d7951ab9cd7b9a91af44d9b29eca640e6800a5 (diff) |
vkd3d: Separate out the different stages of graphics PSO creation.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
-rw-r--r-- | libs/vkd3d/state.c | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 667e20b1..913eb1cd 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -3276,9 +3276,8 @@ static void d3d12_pipeline_state_graphics_handle_meta(struct d3d12_pipeline_stat } } -static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *state, - struct d3d12_device *device, const struct d3d12_pipeline_state_desc *desc, - const struct d3d12_cached_pipeline_state *cached_pso) +static HRESULT d3d12_pipeline_state_init_graphics_create_info(struct d3d12_pipeline_state *state, + struct d3d12_device *device, const struct d3d12_pipeline_state_desc *desc) { const VkPhysicalDeviceFeatures *features = &device->device_info.features2.features; struct d3d12_graphics_pipeline_state *graphics = &state->graphics; @@ -3287,13 +3286,13 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s const struct vkd3d_vulkan_info *vk_info = &device->vk_info; uint32_t instance_divisors[D3D12_VS_INPUT_REGISTER_COUNT]; uint32_t aligned_offsets[D3D12_VS_INPUT_REGISTER_COUNT]; - bool have_attachment, can_compile_pipeline_early; struct vkd3d_shader_signature output_signature; struct vkd3d_shader_signature input_signature; VkSampleCountFlagBits sample_count; const struct vkd3d_format *format; unsigned int instance_divisor; VkVertexInputRate input_rate; + bool have_attachment; unsigned int i, j; size_t rt_count; uint32_t mask; @@ -3317,6 +3316,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s }; graphics->stage_flags = vkd3d_pipeline_state_desc_get_shader_stages(desc); + /* Defer taking ref-count until completion. */ + state->device = device; graphics->stage_count = 0; graphics->primitive_topology_type = desc->primitive_topology_type; @@ -3784,13 +3785,36 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s goto fail; } + return S_OK; + +fail: + vkd3d_shader_free_shader_signature(&input_signature); + vkd3d_shader_free_shader_signature(&output_signature); + return hr; +} + +static HRESULT d3d12_pipeline_state_init_graphics_spirv(struct d3d12_pipeline_state *state, + const struct d3d12_pipeline_state_desc *desc, + const struct d3d12_cached_pipeline_state *cached_pso) +{ + struct d3d12_device *device = state->device; + HRESULT hr; + d3d12_pipeline_state_graphics_load_spirv_from_cached_state(state, device, desc, cached_pso); if (FAILED(hr = d3d12_pipeline_state_graphics_create_shader_stages(state, device, desc))) - goto fail; + return hr; /* At this point, we will have valid meta structures set up. * Deduce further PSO information from these structs. */ d3d12_pipeline_state_graphics_handle_meta(state, device); + return S_OK; +} + +static HRESULT d3d12_pipeline_state_init_static_pipeline(struct d3d12_pipeline_state *state, + const struct d3d12_pipeline_state_desc *desc) +{ + struct d3d12_graphics_pipeline_state *graphics = &state->graphics; + bool can_compile_pipeline_early; if (graphics->stage_flags & VK_SHADER_STAGE_MESH_BIT_EXT) { @@ -3808,31 +3832,31 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s } graphics->pipeline = VK_NULL_HANDLE; - state->device = device; if (can_compile_pipeline_early) { if (!(graphics->pipeline = d3d12_pipeline_state_create_pipeline_variant(state, NULL, graphics->dsv_format, state->vk_pso_cache, &graphics->dynamic_state_flags))) - goto fail; + return E_OUTOFMEMORY; } else { graphics->dsv_plane_optimal_mask = d3d12_graphics_pipeline_state_get_plane_optimal_mask(graphics, NULL); } - list_init(&graphics->compiled_fallback_pipelines); + return S_OK; +} - if (FAILED(hr = vkd3d_private_store_init(&state->private_store))) - goto fail; +static HRESULT d3d12_pipeline_state_finish_graphics(struct d3d12_pipeline_state *state) +{ + struct d3d12_graphics_pipeline_state *graphics = &state->graphics; + HRESULT hr; + list_init(&graphics->compiled_fallback_pipelines); + if (FAILED(hr = vkd3d_private_store_init(&state->private_store))) + return hr; d3d12_device_add_ref(state->device); return S_OK; - -fail: - vkd3d_shader_free_shader_signature(&input_signature); - vkd3d_shader_free_shader_signature(&output_signature); - return hr; } bool d3d12_pipeline_state_has_replaced_shaders(struct d3d12_pipeline_state *state) @@ -3968,7 +3992,14 @@ HRESULT d3d12_pipeline_state_create(struct d3d12_device *device, VkPipelineBindP break; case VK_PIPELINE_BIND_POINT_GRAPHICS: - hr = d3d12_pipeline_state_init_graphics(object, device, desc, desc_cached_pso); + /* Creating a graphics PSO is more involved ... */ + hr = d3d12_pipeline_state_init_graphics_create_info(object, device, desc); + if (SUCCEEDED(hr)) + hr = d3d12_pipeline_state_init_graphics_spirv(object, desc, desc_cached_pso); + if (SUCCEEDED(hr)) + hr = d3d12_pipeline_state_init_static_pipeline(object, desc); + if (SUCCEEDED(hr)) + hr = d3d12_pipeline_state_finish_graphics(object); break; default: |