Experimental shared memory texture handling

This commit is contained in:
Georg Hagen
2024-07-23 01:21:27 +02:00
parent d64bb7a530
commit 75aa36c024
9 changed files with 76 additions and 7 deletions

View File

@@ -35,14 +35,22 @@ namespace OpenVulkano::Vulkan
cmdBuffer.pipelineBarrier(/*VulkanUtils::GetPipelineStageForLayout(oldLayout)*/vk::PipelineStageFlagBits::eTopOfPipe, /*VulkanUtils::GetPipelineStageForLayout(newLayout)*/ vk::PipelineStageFlagBits::eTransfer, {}, nullptr, nullptr, imgMemBarrier);
}
void Image::Init(const Device* device, const DataFormat& format, const vk::Extent3D& resolution)
void Image::Init(const Device* device, const DataFormat& format, const vk::Extent3D& resolution, const vk::MemoryPropertyFlags& memoryPropertyFlags)
{
vk::ImageCreateInfo imgCreateInfo { {}, vk::ImageType::e2D, format, resolution, 1, 1 };
imgCreateInfo.usage = vk::ImageUsageFlagBits::eTransferDst | vk::ImageUsageFlagBits::eSampled;
imgCreateInfo.tiling = vk::ImageTiling::eOptimal;
if (memoryPropertyFlags & vk::MemoryPropertyFlagBits::eHostVisible)
{
imgCreateInfo.tiling = vk::ImageTiling::eLinear;
imgCreateInfo.initialLayout = vk::ImageLayout::ePreinitialized;
}
else
{
imgCreateInfo.tiling = vk::ImageTiling::eOptimal;
imgCreateInfo.initialLayout = vk::ImageLayout::eUndefined;
}
imgCreateInfo.sharingMode = vk::SharingMode::eExclusive;
imgCreateInfo.initialLayout = vk::ImageLayout::eUndefined;
vk::ImageViewCreateInfo imgViewCreateInfo { {}, image, vk::ImageViewType::e2D, imgCreateInfo.format };
imgViewCreateInfo.subresourceRange.aspectMask = vk::ImageAspectFlagBits::eColor;
@@ -51,7 +59,7 @@ namespace OpenVulkano::Vulkan
imgViewCreateInfo.subresourceRange.baseArrayLayer = 0;
imgViewCreateInfo.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
Init(device, imgCreateInfo, imgViewCreateInfo);
Init(device, imgCreateInfo, imgViewCreateInfo, true, memoryPropertyFlags);
}
void Image::Close()