shader_checker: Do not hold lock across API call.
authorCourtney Goeltzenleuchter <courtney@LunarG.com>
Wed, 16 Sep 2015 18:57:55 +0000 (12:57 -0600)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 17 Sep 2015 21:32:11 +0000 (15:32 -0600)
layers/shader_checker.cpp

index 678b5671f2943bc7150833563a7c143c1d37f474..e0f3693804f2f9e5930496ec3af204c6d51ae4c9 100644 (file)
@@ -521,11 +521,13 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateShaderModule(
         const VkShaderModuleCreateInfo *pCreateInfo,
         VkShaderModule *pShaderModule)
 {
-    loader_platform_thread_lock_mutex(&globalLock);
     VkResult res = get_dispatch_table(shader_checker_device_table_map, device)->CreateShaderModule(device, pCreateInfo, pShaderModule);
 
-    shader_module_map[pShaderModule->handle] = new shader_module(device, pCreateInfo);
-    loader_platform_thread_unlock_mutex(&globalLock);
+    if (res == VK_SUCCESS) {
+        loader_platform_thread_lock_mutex(&globalLock);
+        shader_module_map[pShaderModule->handle] = new shader_module(device, pCreateInfo);
+        loader_platform_thread_unlock_mutex(&globalLock);
+    }
     return res;
 }
 
@@ -534,9 +536,9 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateShader(
         const VkShaderCreateInfo *pCreateInfo,
         VkShader *pShader)
 {
-    loader_platform_thread_lock_mutex(&globalLock);
     VkResult res = get_dispatch_table(shader_checker_device_table_map, device)->CreateShader(device, pCreateInfo, pShader);
 
+    loader_platform_thread_lock_mutex(&globalLock);
     shader_object_map[pShader->handle] = new shader_object(pCreateInfo);
     loader_platform_thread_unlock_mutex(&globalLock);
     return res;
@@ -547,9 +549,9 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(
         const VkRenderPassCreateInfo *pCreateInfo,
         VkRenderPass *pRenderPass)
 {
-    loader_platform_thread_lock_mutex(&globalLock);
     VkResult res = get_dispatch_table(shader_checker_device_table_map, device)->CreateRenderPass(device, pCreateInfo, pRenderPass);
 
+    loader_platform_thread_lock_mutex(&globalLock);
     render_pass_map[pRenderPass->handle] = new render_pass(pCreateInfo);
     loader_platform_thread_unlock_mutex(&globalLock);
     return res;