From fdf5ec705c7fc52dbca85daef22c3a551a9d991a Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Mon, 21 Mar 2022 11:29:22 +0100 Subject: [PATCH] vkd3d: Hoist out pipeline cache creation. Not super useful to create a local pipeline cache if we're not going to compile early, but it's super rare, and cleans up the code either way. Signed-off-by: Hans-Kristian Arntzen --- libs/vkd3d/state.c | 47 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index d212eb1d..bc69ac59 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -2380,15 +2380,6 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st state->vk_bind_point = VK_PIPELINE_BIND_POINT_COMPUTE; - if (!device->global_pipeline_cache) - { - if ((hr = vkd3d_create_pipeline_cache_from_d3d12_desc(device, &desc->cached_pso, &state->vk_pso_cache)) < 0) - { - ERR("Failed to create pipeline cache, hr %d.\n", hr); - return hr; - } - } - vkd3d_load_spirv_from_cached_state(device, &desc->cached_pso, VK_SHADER_STAGE_COMPUTE_BIT, &state->compute.code); @@ -3592,15 +3583,6 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s if (can_compile_pipeline_early) { - if (!device->global_pipeline_cache) - { - if ((hr = vkd3d_create_pipeline_cache_from_d3d12_desc(device, &desc->cached_pso, &state->vk_pso_cache)) < 0) - { - ERR("Failed to create pipeline cache, hr %d.\n", hr); - goto fail; - } - } - if (!(graphics->pipeline = d3d12_pipeline_state_create_pipeline_variant(state, NULL, graphics->dsv_format, state->vk_pso_cache ? state->vk_pso_cache : device->global_pipeline_cache, &graphics->dynamic_state_flags))) goto fail; @@ -3714,19 +3696,28 @@ HRESULT d3d12_pipeline_state_create(struct d3d12_device *device, VkPipelineBindP object->refcount = 1; object->internal_refcount = 1; - switch (bind_point) + hr = S_OK; + + if (!device->global_pipeline_cache) + if ((hr = vkd3d_create_pipeline_cache_from_d3d12_desc(device, &desc->cached_pso, &object->vk_pso_cache)) < 0) + ERR("Failed to create pipeline cache, hr %d.\n", hr); + + if (SUCCEEDED(hr)) { - case VK_PIPELINE_BIND_POINT_COMPUTE: - hr = d3d12_pipeline_state_init_compute(object, device, desc); - break; + switch (bind_point) + { + case VK_PIPELINE_BIND_POINT_COMPUTE: + hr = d3d12_pipeline_state_init_compute(object, device, desc); + break; - case VK_PIPELINE_BIND_POINT_GRAPHICS: - hr = d3d12_pipeline_state_init_graphics(object, device, desc); - break; + case VK_PIPELINE_BIND_POINT_GRAPHICS: + hr = d3d12_pipeline_state_init_graphics(object, device, desc); + break; - default: - ERR("Invalid pipeline type %u.", bind_point); - hr = E_INVALIDARG; + default: + ERR("Invalid pipeline type %u.", bind_point); + hr = E_INVALIDARG; + } } if (FAILED(hr))