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 <post@arntzen-software.no>
This commit is contained in:
Hans-Kristian Arntzen 2022-03-21 11:29:22 +01:00
parent d45b3a0dc7
commit fdf5ec705c
1 changed files with 19 additions and 28 deletions

View File

@ -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; 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, vkd3d_load_spirv_from_cached_state(device, &desc->cached_pso,
VK_SHADER_STAGE_COMPUTE_BIT, &state->compute.code); 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 (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, 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))) state->vk_pso_cache ? state->vk_pso_cache : device->global_pipeline_cache, &graphics->dynamic_state_flags)))
goto fail; goto fail;
@ -3714,19 +3696,28 @@ HRESULT d3d12_pipeline_state_create(struct d3d12_device *device, VkPipelineBindP
object->refcount = 1; object->refcount = 1;
object->internal_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: switch (bind_point)
hr = d3d12_pipeline_state_init_compute(object, device, desc); {
break; case VK_PIPELINE_BIND_POINT_COMPUTE:
hr = d3d12_pipeline_state_init_compute(object, device, desc);
break;
case VK_PIPELINE_BIND_POINT_GRAPHICS: case VK_PIPELINE_BIND_POINT_GRAPHICS:
hr = d3d12_pipeline_state_init_graphics(object, device, desc); hr = d3d12_pipeline_state_init_graphics(object, device, desc);
break; break;
default: default:
ERR("Invalid pipeline type %u.", bind_point); ERR("Invalid pipeline type %u.", bind_point);
hr = E_INVALIDARG; hr = E_INVALIDARG;
}
} }
if (FAILED(hr)) if (FAILED(hr))