fix barrier issue when sampling depth texture

anisotropy
cosmonaut 2022-08-25 16:20:35 -07:00
parent 83a59d7685
commit 06ad0e1901
1 changed files with 33 additions and 0 deletions

View File

@ -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,
&currentTexture->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;