rework nested mutex lock on FetchFramebuffer
							parent
							
								
									0ef91c7f42
								
							
						
					
					
						commit
						313b4b81cc
					
				|  | @ -1811,7 +1811,6 @@ typedef struct VulkanRenderer | ||||||
| 
 | 
 | ||||||
| 	uint8_t needDefrag; | 	uint8_t needDefrag; | ||||||
| 	uint32_t defragTimer; | 	uint32_t defragTimer; | ||||||
| 	uint8_t resourceFreed; |  | ||||||
| 
 | 
 | ||||||
| #define VULKAN_INSTANCE_FUNCTION(ext, ret, func, params) \ | #define VULKAN_INSTANCE_FUNCTION(ext, ret, func, params) \ | ||||||
| 		vkfntype_##func func; | 		vkfntype_##func func; | ||||||
|  | @ -2361,7 +2360,6 @@ static void VULKAN_INTERNAL_RemoveMemoryUsedRegion( | ||||||
| 
 | 
 | ||||||
| 	SDL_free(usedRegion); | 	SDL_free(usedRegion); | ||||||
| 
 | 
 | ||||||
| 	renderer->resourceFreed = 1; |  | ||||||
| 	SDL_UnlockMutex(renderer->allocatorLock); | 	SDL_UnlockMutex(renderer->allocatorLock); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -8489,8 +8487,6 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer( | ||||||
| 	uint32_t attachmentCount = 0; | 	uint32_t attachmentCount = 0; | ||||||
| 	uint32_t i; | 	uint32_t i; | ||||||
| 
 | 
 | ||||||
| 	SDL_LockMutex(renderer->framebufferFetchLock); |  | ||||||
| 
 |  | ||||||
| 	for (i = 0; i < MAX_COLOR_TARGET_BINDINGS; i += 1) | 	for (i = 0; i < MAX_COLOR_TARGET_BINDINGS; i += 1) | ||||||
| 	{ | 	{ | ||||||
| 		hash.colorAttachmentViews[i] = VK_NULL_HANDLE; | 		hash.colorAttachmentViews[i] = VK_NULL_HANDLE; | ||||||
|  | @ -8551,14 +8547,17 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer( | ||||||
| 	hash.width = width; | 	hash.width = width; | ||||||
| 	hash.height = height; | 	hash.height = height; | ||||||
| 
 | 
 | ||||||
|  | 	SDL_LockMutex(renderer->framebufferFetchLock); | ||||||
|  | 
 | ||||||
| 	vulkanFramebuffer = FramebufferHashArray_Fetch( | 	vulkanFramebuffer = FramebufferHashArray_Fetch( | ||||||
| 		&renderer->framebufferHashArray, | 		&renderer->framebufferHashArray, | ||||||
| 		&hash | 		&hash | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
|  | 	SDL_UnlockMutex(renderer->framebufferFetchLock); | ||||||
|  | 
 | ||||||
| 	if (vulkanFramebuffer != NULL) | 	if (vulkanFramebuffer != NULL) | ||||||
| 	{ | 	{ | ||||||
| 		SDL_UnlockMutex(renderer->framebufferFetchLock); |  | ||||||
| 		return vulkanFramebuffer; | 		return vulkanFramebuffer; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -8637,11 +8636,15 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer( | ||||||
| 
 | 
 | ||||||
| 	if (result == VK_SUCCESS) | 	if (result == VK_SUCCESS) | ||||||
| 	{ | 	{ | ||||||
|  | 		SDL_LockMutex(renderer->framebufferFetchLock); | ||||||
|  | 
 | ||||||
| 		FramebufferHashArray_Insert( | 		FramebufferHashArray_Insert( | ||||||
| 			&renderer->framebufferHashArray, | 			&renderer->framebufferHashArray, | ||||||
| 			hash, | 			hash, | ||||||
| 			vulkanFramebuffer | 			vulkanFramebuffer | ||||||
| 		); | 		); | ||||||
|  | 
 | ||||||
|  | 		SDL_UnlockMutex(renderer->framebufferFetchLock); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
|  | @ -8650,7 +8653,6 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer( | ||||||
| 		vulkanFramebuffer = NULL; | 		vulkanFramebuffer = NULL; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	SDL_UnlockMutex(renderer->framebufferFetchLock); |  | ||||||
| 	return vulkanFramebuffer; | 	return vulkanFramebuffer; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -10246,7 +10248,11 @@ static void VULKAN_Wait( | ||||||
| 		{ | 		{ | ||||||
| 			LogVulkanResultAsError("vkWaitForFences", result); | 			LogVulkanResultAsError("vkWaitForFences", result); | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
|  | 	for (i = renderer->submittedCommandBufferCount - 1; i >= 0; i -= 1) | ||||||
|  | 	{ | ||||||
|  | 		commandBuffer = renderer->submittedCommandBuffers[i]; | ||||||
| 		VULKAN_INTERNAL_CleanCommandBuffer(renderer, commandBuffer); | 		VULKAN_INTERNAL_CleanCommandBuffer(renderer, commandBuffer); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -11983,7 +11989,6 @@ static Refresh_Device* VULKAN_CreateDevice( | ||||||
| 
 | 
 | ||||||
| 	renderer->needDefrag = 0; | 	renderer->needDefrag = 0; | ||||||
| 	renderer->defragTimer = 0; | 	renderer->defragTimer = 0; | ||||||
| 	renderer->resourceFreed = 0; |  | ||||||
| 
 | 
 | ||||||
| 	return result; | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue