Skip to content

Commit

Permalink
[hgiVulkan] Fix for HgiVulkanBlitCmds::CopyTextureGpuToCpu. Vulkan on…
Browse files Browse the repository at this point in the history
…ly expects

one aspect when copying an image to buffer, so if the image is a depth-stencil
image, assume we wish to copy the depth aspect.

See #2852

(Internal change: 2316631)
  • Loading branch information
clach authored and pixar-oss committed Mar 1, 2024
1 parent d596a92 commit 0410150
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pxr/imaging/hgiVulkan/blitCmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,23 @@ HgiVulkanBlitCmds::CopyTextureGpuToCpu(
size.depth = texDesc.dimensions[2] - depthOffset;

VkImageSubresourceLayers imageSub;
imageSub.aspectMask =
HgiVulkanConversions::GetImageAspectFlag(texDesc.usage);
imageSub.baseArrayLayer = isTexArray ? copyOp.sourceTexelOffset[2] : 0;
imageSub.layerCount = 1;
imageSub.mipLevel = copyOp.mipLevel;

// XXX: Vulkan validation demands that only one flag at a time be used
// during the copy operation. Both depth and stencil flags cannot be
// simultaneously passed as aspects to copy.
// So, we assume that the user wants to copy depth when the texture is a
// depthStencil texture. If need arises, this part of the implementation
// needs to be re-written such that an aspect flag is passed to this copy
// operation to resolve the discrepancy.
imageSub.aspectMask =
HgiVulkanConversions::GetImageAspectFlag(texDesc.usage);
if (imageSub.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) {
imageSub.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
}

// See vulkan docs: Copying Data Between Buffers and Images
VkBufferImageCopy region;
region.bufferImageHeight = 0; // Buffer is tightly packed, like image
Expand Down

0 comments on commit 0410150

Please sign in to comment.