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]; VulkanTexture *renderPassColorTargetTextures[MAX_COLOR_TARGET_BINDINGS];
uint32_t renderPassColorTargetCount; uint32_t renderPassColorTargetCount;
VulkanTexture *renderPassDepthTexture; /* can be NULL */
VulkanUniformBuffer *vertexUniformBuffer; VulkanUniformBuffer *vertexUniformBuffer;
VulkanUniformBuffer *fragmentUniformBuffer; VulkanUniformBuffer *fragmentUniformBuffer;
@ -8389,6 +8390,8 @@ static void VULKAN_BeginRenderPass(
); );
clearCount += 1; clearCount += 1;
VULKAN_INTERNAL_TrackTexture(renderer, vulkanCommandBuffer, texture);
} }
/* Set clear values */ /* Set clear values */
@ -8451,6 +8454,11 @@ static void VULKAN_BeginRenderPass(
} }
vulkanCommandBuffer->renderPassColorTargetCount = colorAttachmentCount; vulkanCommandBuffer->renderPassColorTargetCount = colorAttachmentCount;
if (depthStencilAttachmentInfo != NULL)
{
vulkanCommandBuffer->renderPassDepthTexture = (VulkanTexture*) depthStencilAttachmentInfo->texture;
}
/* Set sensible default viewport state */ /* Set sensible default viewport state */
defaultViewport.x = 0; defaultViewport.x = 0;
@ -8549,6 +8557,29 @@ static void VULKAN_EndRenderPass(
} }
vulkanCommandBuffer->renderPassColorTargetCount = 0; 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->currentGraphicsPipeline = NULL;
vulkanCommandBuffer->renderPassInProgress = 0; vulkanCommandBuffer->renderPassInProgress = 0;
} }
@ -8937,6 +8968,8 @@ static void VULKAN_INTERNAL_AllocateCommandBuffers(
LogVulkanResultAsError("vkCreateFence", vulkanResult); LogVulkanResultAsError("vkCreateFence", vulkanResult);
} }
commandBuffer->renderPassDepthTexture = NULL;
/* Presentation tracking */ /* Presentation tracking */
commandBuffer->presentDataCapacity = 1; commandBuffer->presentDataCapacity = 1;