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-21 15:54:09 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2022-03-21 16:35:41 +0300
commit3a1e6de93d4837b9673d979c203e0f6afe3fe9ac (patch)
tree3807e9526909aeca35c94c16bb14d1e3e246912e
parent191214899dff2062deac97a1aed81bd629de78b2 (diff)
vkd3d: Use rwlock instead of spinlock in PSO fallback cache.pso-creation-refactor
If we defer SPIR-V compilation we risk holding the lock for quite a long time. Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
-rw-r--r--libs/vkd3d/state.c17
-rw-r--r--libs/vkd3d/vkd3d_private.h2
2 files changed, 14 insertions, 5 deletions
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 5516b894..884d22ff 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -1971,6 +1971,7 @@ void d3d12_pipeline_state_dec_ref(struct d3d12_pipeline_state *state)
if (state->vk_bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS)
d3d12_pipeline_state_free_cached_desc(&state->graphics.cached_desc);
+ rwlock_destroy(&state->lock);
vkd3d_free(state);
}
}
@@ -3759,6 +3760,12 @@ HRESULT d3d12_pipeline_state_create(struct d3d12_device *device, VkPipelineBindP
memset(object, 0, sizeof(*object));
+ if (rwlock_init(&object->lock))
+ {
+ vkd3d_free(object);
+ return E_FAIL;
+ }
+
if (!desc->root_signature)
{
if (FAILED(hr = d3d12_pipeline_create_private_root_signature(device,
@@ -3788,6 +3795,7 @@ HRESULT d3d12_pipeline_state_create(struct d3d12_device *device, VkPipelineBindP
{
if (object->root_signature)
d3d12_root_signature_dec_ref(object->root_signature);
+ rwlock_destroy(&object->lock);
vkd3d_free(object);
return hr;
}
@@ -3837,6 +3845,7 @@ HRESULT d3d12_pipeline_state_create(struct d3d12_device *device, VkPipelineBindP
if (object->vk_bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS)
d3d12_pipeline_state_free_cached_desc(&object->graphics.cached_desc);
VK_CALL(vkDestroyPipelineCache(device->vk_device, object->vk_pso_cache, NULL));
+ rwlock_destroy(&object->lock);
vkd3d_free(object);
return hr;
@@ -3978,7 +3987,7 @@ static VkPipeline d3d12_pipeline_state_find_compiled_pipeline(struct d3d12_pipel
struct vkd3d_compiled_pipeline *current;
VkPipeline vk_pipeline = VK_NULL_HANDLE;
- rw_spinlock_acquire_read(&state->lock);
+ rwlock_lock_read(&state->lock);
LIST_FOR_EACH_ENTRY(current, &graphics->compiled_fallback_pipelines, struct vkd3d_compiled_pipeline, entry)
{
if (!memcmp(&current->key, key, sizeof(*key)))
@@ -3988,7 +3997,7 @@ static VkPipeline d3d12_pipeline_state_find_compiled_pipeline(struct d3d12_pipel
break;
}
}
- rw_spinlock_release_read(&state->lock);
+ rwlock_unlock_read(&state->lock);
return vk_pipeline;
}
@@ -4006,7 +4015,7 @@ static bool d3d12_pipeline_state_put_pipeline_to_cache(struct d3d12_pipeline_sta
compiled_pipeline->vk_pipeline = vk_pipeline;
compiled_pipeline->dynamic_state_flags = dynamic_state_flags;
- rw_spinlock_acquire_write(&state->lock);
+ rwlock_lock_write(&state->lock);
LIST_FOR_EACH_ENTRY(current, &graphics->compiled_fallback_pipelines, struct vkd3d_compiled_pipeline, entry)
{
@@ -4021,7 +4030,7 @@ static bool d3d12_pipeline_state_put_pipeline_to_cache(struct d3d12_pipeline_sta
if (compiled_pipeline)
list_add_tail(&graphics->compiled_fallback_pipelines, &compiled_pipeline->entry);
- rw_spinlock_release_write(&state->lock);
+ rwlock_unlock_write(&state->lock);
return compiled_pipeline;
}
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 78668205..1959fcf0 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1554,7 +1554,7 @@ struct d3d12_pipeline_state
};
VkPipelineBindPoint vk_bind_point;
VkPipelineCache vk_pso_cache;
- spinlock_t lock;
+ rwlock_t lock;
struct vkd3d_pipeline_cache_compatibility pipeline_cache_compat;
struct d3d12_root_signature *root_signature;