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-09-16 23:25:44 +0300
commitf689188f2651d68eedff2ac2ce413e35f738e4ba (patch)
tree9bbe3b991b8ee0777895d5b066f91031c6ecba63
parenta9bb59f22197d4dcab8fa41a0e9cfbc52a04e018 (diff)
vkd3d: Use rwlock instead of spinlock in PSO fallback cache.
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 222b4d7b..8ba87770 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2090,6 +2090,7 @@ void d3d12_pipeline_state_dec_ref(struct d3d12_pipeline_state *state)
if (state->pipeline_type == VKD3D_PIPELINE_TYPE_GRAPHICS || state->pipeline_type == VKD3D_PIPELINE_TYPE_MESH_GRAPHICS)
d3d12_pipeline_state_free_cached_desc(&state->graphics.cached_desc);
+ rwlock_destroy(&state->lock);
vkd3d_free(state);
}
}
@@ -3945,6 +3946,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,
@@ -3976,6 +3983,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;
}
@@ -4050,6 +4058,7 @@ HRESULT d3d12_pipeline_state_create(struct d3d12_device *device, VkPipelineBindP
if (object->pipeline_type == VKD3D_PIPELINE_TYPE_GRAPHICS || object->pipeline_type == VKD3D_PIPELINE_TYPE_MESH_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;
@@ -4198,7 +4207,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)))
@@ -4208,7 +4217,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;
}
@@ -4226,7 +4235,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)
{
@@ -4241,7 +4250,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 9ed0f42c..3fa9c2c0 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1686,7 +1686,7 @@ struct d3d12_pipeline_state
enum vkd3d_pipeline_type pipeline_type;
VkPipelineCache vk_pso_cache;
- spinlock_t lock;
+ rwlock_t lock;
struct vkd3d_pipeline_cache_compatibility pipeline_cache_compat;
struct d3d12_root_signature *root_signature;