@@ -1178,6 +1178,9 @@ struct VulkanRenderer
11781178 SDL_Mutex * acquireUniformBufferLock ;
11791179 SDL_Mutex * renderPassFetchLock ;
11801180 SDL_Mutex * framebufferFetchLock ;
1181+ SDL_Mutex * graphicsPipelineLayoutFetchLock ;
1182+ SDL_Mutex * computePipelineLayoutFetchLock ;
1183+ SDL_Mutex * descriptorSetLayoutFetchLock ;
11811184 SDL_Mutex * windowLock ;
11821185
11831186 Uint8 defragInProgress ;
@@ -3698,10 +3701,13 @@ static DescriptorSetLayout *VULKAN_INTERNAL_FetchDescriptorSetLayout(
36983701 key .writeStorageBufferCount = writeStorageBufferCount ;
36993702 key .uniformBufferCount = uniformBufferCount ;
37003703
3704+ SDL_LockMutex (renderer -> descriptorSetLayoutFetchLock );
3705+
37013706 if (SDL_FindInHashTable (
37023707 renderer -> descriptorSetLayoutHashTable ,
37033708 (const void * )& key ,
37043709 (const void * * )& layout )) {
3710+ SDL_UnlockMutex (renderer -> descriptorSetLayoutFetchLock );
37053711 return layout ;
37063712 }
37073713
@@ -3784,7 +3790,10 @@ static DescriptorSetLayout *VULKAN_INTERNAL_FetchDescriptorSetLayout(
37843790 NULL ,
37853791 & descriptorSetLayout );
37863792
3787- CHECK_VULKAN_ERROR_AND_RETURN (vulkanResult , vkCreateDescriptorSetLayout , NULL );
3793+ if (vulkanResult != VK_SUCCESS ) {
3794+ SDL_UnlockMutex (renderer -> descriptorSetLayoutFetchLock );
3795+ CHECK_VULKAN_ERROR_AND_RETURN (vulkanResult , vkCreateDescriptorSetLayout , NULL );
3796+ }
37883797
37893798 layout = SDL_malloc (sizeof (DescriptorSetLayout ));
37903799 layout -> descriptorSetLayout = descriptorSetLayout ;
@@ -3806,6 +3815,7 @@ static DescriptorSetLayout *VULKAN_INTERNAL_FetchDescriptorSetLayout(
38063815 (const void * )allocedKey ,
38073816 (const void * )layout , true);
38083817
3818+ SDL_UnlockMutex (renderer -> descriptorSetLayoutFetchLock );
38093819 return layout ;
38103820}
38113821
@@ -3826,10 +3836,14 @@ static VulkanGraphicsPipelineResourceLayout *VULKAN_INTERNAL_FetchGraphicsPipeli
38263836 key .fragmentStorageTextureCount = fragmentShader -> numStorageTextures ;
38273837 key .fragmentStorageBufferCount = fragmentShader -> numStorageBuffers ;
38283838 key .fragmentUniformBufferCount = fragmentShader -> numUniformBuffers ;
3839+
3840+ SDL_LockMutex (renderer -> graphicsPipelineLayoutFetchLock );
3841+
38293842 if (SDL_FindInHashTable (
38303843 renderer -> graphicsPipelineResourceLayoutHashTable ,
38313844 (const void * )& key ,
38323845 (const void * * )& pipelineResourceLayout )) {
3846+ SDL_UnlockMutex (renderer -> graphicsPipelineLayoutFetchLock );
38333847 return pipelineResourceLayout ;
38343848 }
38353849
@@ -3912,6 +3926,7 @@ static VulkanGraphicsPipelineResourceLayout *VULKAN_INTERNAL_FetchGraphicsPipeli
39123926
39133927 if (vulkanResult != VK_SUCCESS ) {
39143928 VULKAN_INTERNAL_DestroyGraphicsPipelineResourceLayout (renderer , pipelineResourceLayout );
3929+ SDL_UnlockMutex (renderer -> graphicsPipelineLayoutFetchLock );
39153930 CHECK_VULKAN_ERROR_AND_RETURN (vulkanResult , vkCreatePipelineLayout , NULL );
39163931 }
39173932
@@ -3923,6 +3938,7 @@ static VulkanGraphicsPipelineResourceLayout *VULKAN_INTERNAL_FetchGraphicsPipeli
39233938 (const void * )allocedKey ,
39243939 (const void * )pipelineResourceLayout , true);
39253940
3941+ SDL_UnlockMutex (renderer -> graphicsPipelineLayoutFetchLock );
39263942 return pipelineResourceLayout ;
39273943}
39283944
@@ -3941,10 +3957,13 @@ static VulkanComputePipelineResourceLayout *VULKAN_INTERNAL_FetchComputePipeline
39413957 key .readWriteStorageBufferCount = createinfo -> num_readwrite_storage_buffers ;
39423958 key .uniformBufferCount = createinfo -> num_uniform_buffers ;
39433959
3960+ SDL_LockMutex (renderer -> computePipelineLayoutFetchLock );
3961+
39443962 if (SDL_FindInHashTable (
39453963 renderer -> computePipelineResourceLayoutHashTable ,
39463964 (const void * )& key ,
39473965 (const void * * )& pipelineResourceLayout )) {
3966+ SDL_UnlockMutex (renderer -> computePipelineLayoutFetchLock );
39483967 return pipelineResourceLayout ;
39493968 }
39503969
@@ -4013,6 +4032,7 @@ static VulkanComputePipelineResourceLayout *VULKAN_INTERNAL_FetchComputePipeline
40134032
40144033 if (vulkanResult != VK_SUCCESS ) {
40154034 VULKAN_INTERNAL_DestroyComputePipelineResourceLayout (renderer , pipelineResourceLayout );
4035+ SDL_UnlockMutex (renderer -> computePipelineLayoutFetchLock );
40164036 CHECK_VULKAN_ERROR_AND_RETURN (vulkanResult , vkCreatePipelineLayout , NULL );
40174037 }
40184038
@@ -4024,6 +4044,7 @@ static VulkanComputePipelineResourceLayout *VULKAN_INTERNAL_FetchComputePipeline
40244044 (const void * )allocedKey ,
40254045 (const void * )pipelineResourceLayout , true);
40264046
4047+ SDL_UnlockMutex (renderer -> computePipelineLayoutFetchLock );
40274048 return pipelineResourceLayout ;
40284049}
40294050
@@ -4914,6 +4935,9 @@ static void VULKAN_DestroyDevice(
49144935 SDL_DestroyMutex (renderer -> acquireUniformBufferLock );
49154936 SDL_DestroyMutex (renderer -> renderPassFetchLock );
49164937 SDL_DestroyMutex (renderer -> framebufferFetchLock );
4938+ SDL_DestroyMutex (renderer -> graphicsPipelineLayoutFetchLock );
4939+ SDL_DestroyMutex (renderer -> computePipelineLayoutFetchLock );
4940+ SDL_DestroyMutex (renderer -> descriptorSetLayoutFetchLock );
49174941 SDL_DestroyMutex (renderer -> windowLock );
49184942
49194943 renderer -> vkDestroyDevice (renderer -> logicalDevice , NULL );
@@ -11761,6 +11785,9 @@ static SDL_GPUDevice *VULKAN_CreateDevice(bool debugMode, bool preferLowPower, S
1176111785 renderer -> acquireUniformBufferLock = SDL_CreateMutex ();
1176211786 renderer -> renderPassFetchLock = SDL_CreateMutex ();
1176311787 renderer -> framebufferFetchLock = SDL_CreateMutex ();
11788+ renderer -> graphicsPipelineLayoutFetchLock = SDL_CreateMutex ();
11789+ renderer -> computePipelineLayoutFetchLock = SDL_CreateMutex ();
11790+ renderer -> descriptorSetLayoutFetchLock = SDL_CreateMutex ();
1176411791 renderer -> windowLock = SDL_CreateMutex ();
1176511792
1176611793 /*
@@ -11821,7 +11848,7 @@ static SDL_GPUDevice *VULKAN_CreateDevice(bool debugMode, bool preferLowPower, S
1182111848
1182211849 renderer -> renderPassHashTable = SDL_CreateHashTable (
1182311850 0 , // !!! FIXME: a real guess here, for a _minimum_ if not a maximum, could be useful.
11824- false, // manually synchronized due to timing
11851+ false, // manually synchronized due to lookup timing
1182511852 VULKAN_INTERNAL_RenderPassHashFunction ,
1182611853 VULKAN_INTERNAL_RenderPassHashKeyMatch ,
1182711854 VULKAN_INTERNAL_RenderPassHashDestroy ,
@@ -11837,23 +11864,23 @@ static SDL_GPUDevice *VULKAN_CreateDevice(bool debugMode, bool preferLowPower, S
1183711864
1183811865 renderer -> graphicsPipelineResourceLayoutHashTable = SDL_CreateHashTable (
1183911866 0 , // !!! FIXME: a real guess here, for a _minimum_ if not a maximum, could be useful.
11840- true , // thread-safe
11867+ false , // manually synchronized due to lookup timing
1184111868 VULKAN_INTERNAL_GraphicsPipelineResourceLayoutHashFunction ,
1184211869 VULKAN_INTERNAL_GraphicsPipelineResourceLayoutHashKeyMatch ,
1184311870 VULKAN_INTERNAL_GraphicsPipelineResourceLayoutHashDestroy ,
1184411871 (void * )renderer );
1184511872
1184611873 renderer -> computePipelineResourceLayoutHashTable = SDL_CreateHashTable (
1184711874 0 , // !!! FIXME: a real guess here, for a _minimum_ if not a maximum, could be useful.
11848- true , // thread-safe
11875+ false , // manually synchronized due to lookup timing
1184911876 VULKAN_INTERNAL_ComputePipelineResourceLayoutHashFunction ,
1185011877 VULKAN_INTERNAL_ComputePipelineResourceLayoutHashKeyMatch ,
1185111878 VULKAN_INTERNAL_ComputePipelineResourceLayoutHashDestroy ,
1185211879 (void * )renderer );
1185311880
1185411881 renderer -> descriptorSetLayoutHashTable = SDL_CreateHashTable (
1185511882 0 , // !!! FIXME: a real guess here, for a _minimum_ if not a maximum, could be useful.
11856- true , // thread-safe
11883+ false , // manually synchronized due to lookup timing
1185711884 VULKAN_INTERNAL_DescriptorSetLayoutHashFunction ,
1185811885 VULKAN_INTERNAL_DescriptorSetLayoutHashKeyMatch ,
1185911886 VULKAN_INTERNAL_DescriptorSetLayoutHashDestroy ,
0 commit comments