mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-27 03:04:16 +01:00
Add Depth/Stencil Format Support to Texture
Sets `VkImageUsageFlags` correctly rather than hardcoding it for color attachments and adds multiple `VkBufferImageCopy` to `VkCmdCopyBufferToImage` for Color/Depth/Stencil aspects of an image.
This commit is contained in:
parent
68c990c041
commit
aa32f6b017
@ -103,13 +103,26 @@ namespace skyline::gpu {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
commandBuffer.copyBufferToImage(stagingBuffer->vkBuffer, image, layout, vk::BufferImageCopy{
|
boost::container::static_vector<const vk::BufferImageCopy, 3> bufferImageCopies;
|
||||||
.imageExtent = dimensions,
|
auto pushBufferImageCopyWithAspect{[&](vk::ImageAspectFlagBits aspect) {
|
||||||
.imageSubresource = {
|
bufferImageCopies.emplace_back(
|
||||||
.aspectMask = format->vkAspect,
|
vk::BufferImageCopy{
|
||||||
.layerCount = layerCount,
|
.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.copyBufferToImage(stagingBuffer->vkBuffer, image, layout, vk::ArrayProxy(static_cast<u32>(bufferImageCopies.size()), bufferImageCopies.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::CopyIntoStagingBuffer(const vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr<memory::StagingBuffer> &stagingBuffer) {
|
void Texture::CopyIntoStagingBuffer(const vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr<memory::StagingBuffer> &stagingBuffer) {
|
||||||
@ -203,6 +216,12 @@ namespace skyline::gpu {
|
|||||||
mipLevels(1),
|
mipLevels(1),
|
||||||
layerCount(guest->layerCount),
|
layerCount(guest->layerCount),
|
||||||
sampleCount(vk::SampleCountFlagBits::e1) {
|
sampleCount(vk::SampleCountFlagBits::e1) {
|
||||||
|
vk::ImageUsageFlags usage{vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst};
|
||||||
|
if (format->vkAspect & vk::ImageAspectFlagBits::eColor)
|
||||||
|
usage |= vk::ImageUsageFlagBits::eColorAttachment;
|
||||||
|
if (format->vkAspect & (vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil))
|
||||||
|
usage |= vk::ImageUsageFlagBits::eDepthStencilAttachment;
|
||||||
|
|
||||||
vk::ImageCreateInfo imageCreateInfo{
|
vk::ImageCreateInfo imageCreateInfo{
|
||||||
.imageType = guest->dimensions.GetType(),
|
.imageType = guest->dimensions.GetType(),
|
||||||
.format = *guest->format,
|
.format = *guest->format,
|
||||||
@ -211,7 +230,7 @@ namespace skyline::gpu {
|
|||||||
.arrayLayers = guest->layerCount,
|
.arrayLayers = guest->layerCount,
|
||||||
.samples = vk::SampleCountFlagBits::e1,
|
.samples = vk::SampleCountFlagBits::e1,
|
||||||
.tiling = tiling,
|
.tiling = tiling,
|
||||||
.usage = vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst,
|
.usage = usage,
|
||||||
.sharingMode = vk::SharingMode::eExclusive,
|
.sharingMode = vk::SharingMode::eExclusive,
|
||||||
.queueFamilyIndexCount = 1,
|
.queueFamilyIndexCount = 1,
|
||||||
.pQueueFamilyIndices = &gpu.vkQueueFamilyIndex,
|
.pQueueFamilyIndices = &gpu.vkQueueFamilyIndex,
|
||||||
|
Loading…
Reference in New Issue
Block a user