rhi: vulkan: Support to read depth textures

When reading back textures, VkImageAspect is
just used as VK_IMAGE_ASPECT_COLOR_BIT and
it doesn't work for depth/stencil formats.

Change-Id: Ib356a0821f9de8e27eb2b9333714fe75971744a2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Inho Lee 2025-03-10 13:03:23 +01:00
parent f9d9630e9e
commit c0a01ca6ad

View File

@ -4369,7 +4369,7 @@ void QRhiVulkan::enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdat
// Copy from the (optimal and not host visible) image into the buffer.
VkBufferImageCopy copyDesc = {};
copyDesc.bufferOffset = 0;
copyDesc.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
copyDesc.imageSubresource.aspectMask = aspectMaskForTextureFormat(readback.format);
copyDesc.imageSubresource.mipLevel = uint32_t(u.rb.level());
copyDesc.imageSubresource.baseArrayLayer = is3D ? 0 : uint32_t(u.rb.layer());
copyDesc.imageSubresource.layerCount = 1;