forked from MoonsideGames/Refresh
				
			fix barrier issue when sampling depth texture
							parent
							
								
									83a59d7685
								
							
						
					
					
						commit
						06ad0e1901
					
				|  | @ -1509,6 +1509,7 @@ typedef struct VulkanCommandBuffer | |||
| 
 | ||||
| 	VulkanTexture *renderPassColorTargetTextures[MAX_COLOR_TARGET_BINDINGS]; | ||||
| 	uint32_t renderPassColorTargetCount; | ||||
| 	VulkanTexture *renderPassDepthTexture; /* can be NULL */ | ||||
| 
 | ||||
| 	VulkanUniformBuffer *vertexUniformBuffer; | ||||
| 	VulkanUniformBuffer *fragmentUniformBuffer; | ||||
|  | @ -8389,6 +8390,8 @@ static void VULKAN_BeginRenderPass( | |||
| 		); | ||||
| 
 | ||||
| 		clearCount += 1; | ||||
| 
 | ||||
| 		VULKAN_INTERNAL_TrackTexture(renderer, vulkanCommandBuffer, texture); | ||||
| 	} | ||||
| 
 | ||||
| 	/* Set clear values */ | ||||
|  | @ -8451,6 +8454,11 @@ static void VULKAN_BeginRenderPass( | |||
| 	} | ||||
| 	vulkanCommandBuffer->renderPassColorTargetCount = colorAttachmentCount; | ||||
| 
 | ||||
| 	if (depthStencilAttachmentInfo != NULL) | ||||
| 	{ | ||||
| 		vulkanCommandBuffer->renderPassDepthTexture = (VulkanTexture*) depthStencilAttachmentInfo->texture; | ||||
| 	} | ||||
| 
 | ||||
| 	/* Set sensible default viewport state */ | ||||
| 
 | ||||
| 	defaultViewport.x = 0; | ||||
|  | @ -8549,6 +8557,29 @@ static void VULKAN_EndRenderPass( | |||
| 	} | ||||
| 	vulkanCommandBuffer->renderPassColorTargetCount = 0; | ||||
| 
 | ||||
| 	if (vulkanCommandBuffer->renderPassDepthTexture != NULL) | ||||
| 	{ | ||||
| 		currentTexture = vulkanCommandBuffer->renderPassDepthTexture; | ||||
| 
 | ||||
| 		if (currentTexture->usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) | ||||
| 		{ | ||||
| 			VULKAN_INTERNAL_ImageMemoryBarrier( | ||||
| 				renderer, | ||||
| 				vulkanCommandBuffer->commandBuffer, | ||||
| 				RESOURCE_ACCESS_ANY_SHADER_READ_SAMPLED_IMAGE, | ||||
| 				currentTexture->aspectFlags, | ||||
| 				0, | ||||
| 				currentTexture->layerCount, | ||||
| 				0, | ||||
| 				currentTexture->levelCount, | ||||
| 				0, | ||||
| 				currentTexture->image, | ||||
| 				¤tTexture->resourceAccessType | ||||
| 			); | ||||
| 		} | ||||
| 	} | ||||
| 	vulkanCommandBuffer->renderPassDepthTexture = NULL; | ||||
| 
 | ||||
| 	vulkanCommandBuffer->currentGraphicsPipeline = NULL; | ||||
| 	vulkanCommandBuffer->renderPassInProgress = 0; | ||||
| } | ||||
|  | @ -8937,6 +8968,8 @@ static void VULKAN_INTERNAL_AllocateCommandBuffers( | |||
| 			LogVulkanResultAsError("vkCreateFence", vulkanResult); | ||||
| 		} | ||||
| 
 | ||||
| 		commandBuffer->renderPassDepthTexture = NULL; | ||||
| 
 | ||||
| 		/* Presentation tracking */ | ||||
| 
 | ||||
| 		commandBuffer->presentDataCapacity = 1; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue