Support Multi-Aspect Copy in Texture::CopyIntoStagingBuffer

Only copying a single aspect was supported by `CopyIntoStagingBuffer` earlier due to not supplying a `VkBufferImageCopy` for each aspect separately, this has now been done with Color/Depth/Stencil aspects having their own `VkBufferImageCopy` for the `VkCmdCopyImageToBuffer` command.
This commit is contained in:
PixelyIon 2021-12-08 14:28:45 +05:30
parent daff17c776
commit bd6cd0056c

View File

@ -172,13 +172,26 @@ namespace skyline::gpu {
},
});
commandBuffer.copyImageToBuffer(image, layout, stagingBuffer->vkBuffer, vk::BufferImageCopy{
.imageExtent = dimensions,
.imageSubresource = {
.aspectMask = format->vkAspect,
.layerCount = layerCount,
},
});
boost::container::static_vector<const vk::BufferImageCopy, 3> bufferImageCopies;
auto pushBufferImageCopyWithAspect{[&](vk::ImageAspectFlagBits aspect) {
bufferImageCopies.emplace_back(
vk::BufferImageCopy{
.imageExtent = dimensions,
.imageSubresource = {
.aspectMask = aspect,
.layerCount = layerCount,
},
});
}};
if (format->vkAspect & vk::ImageAspectFlagBits::eColor)
pushBufferImageCopyWithAspect(vk::ImageAspectFlagBits::eColor);
if (format->vkAspect & vk::ImageAspectFlagBits::eDepth)
pushBufferImageCopyWithAspect(vk::ImageAspectFlagBits::eDepth);
if (format->vkAspect & vk::ImageAspectFlagBits::eStencil)
pushBufferImageCopyWithAspect(vk::ImageAspectFlagBits::eStencil);
commandBuffer.copyImageToBuffer(image, layout, stagingBuffer->vkBuffer, vk::ArrayProxy(static_cast<u32>(bufferImageCopies.size()), bufferImageCopies.data()));
commandBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eHost, {}, {}, vk::BufferMemoryBarrier{
.srcAccessMask = vk::AccessFlagBits::eTransferWrite,