Skip to content

Commit

Permalink
[hdSt, hgiVulkan] Vulkan validation error fixes for AMD.
Browse files Browse the repository at this point in the history
Fixed bugs around HgiVulkan access masks for layout transition barriers and
provided correct read usage flags for depth buffers in Vulkan.

Contribution: Vipul Kapoor

(Internal change: 2330922)
  • Loading branch information
clach authored and pixar-oss committed Jun 13, 2024
1 parent 1c5de5d commit 71db927
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
12 changes: 7 additions & 5 deletions pxr/imaging/hdSt/renderBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ PXR_NAMESPACE_OPEN_SCOPE
static
HgiTextureUsage _GetTextureUsage(HdFormat format, TfToken const &name)
{
// We are assuming at some point in a render buffer's lifetime it could be
// used to read from, so provide that ability to the render buffer. This is
// especially useful for the HgiVulkan backend.

if (HdAovHasDepthSemantic(name)) {
return HgiTextureUsageBitsDepthTarget;
return HgiTextureUsageBitsDepthTarget | HgiTextureUsageBitsShaderRead;
} else if (HdAovHasDepthStencilSemantic(name)) {
return HgiTextureUsageBitsDepthTarget |
HgiTextureUsageBitsStencilTarget;
HgiTextureUsageBitsStencilTarget |
HgiTextureUsageBitsShaderRead;
}

// We are assuming at some point in a render buffer's lifetime it could be
// used to read from, so provide that ability to the render buffer. This is
// especially useful when for the HgiVulkan back-end.
return HgiTextureUsageBitsColorTarget | HgiTextureUsageBitsShaderRead;
}

Expand Down
17 changes: 7 additions & 10 deletions pxr/imaging/hgiVulkan/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,18 +619,15 @@ HgiVulkanTexture::GetDefaultImageLayout(HgiTextureUsage usage)
if (usage & HgiTextureUsageBitsShaderWrite) {
// Assume the ShaderWrite means its a storage image.
return VK_IMAGE_LAYOUT_GENERAL;
} else if (usage & HgiTextureUsageBitsShaderRead) {
// Also check if image is going to be used as a color attachment as
// well. If yes, then explicitly give it a color attachment layout.
if (usage & HgiTextureUsageBitsColorTarget) {
return VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
} else {
return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
} else if (usage & HgiTextureUsageBitsDepthTarget) {
return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
// Prioritize attachment layouts over shader read layout. Some textures
// might have both usages.
} else if (usage & HgiTextureUsageBitsColorTarget) {
return VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
} else if (usage & HgiTextureUsageBitsDepthTarget ||
usage & HgiTextureUsageBitsStencilTarget) {
return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
} else if (usage & HgiTextureUsageBitsShaderRead) {
return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}

return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
Expand Down

0 comments on commit 71db927

Please sign in to comment.