Change the 'viewformats' texture setting field to be a list of pixel formats.

Replace Texture:hasViewFormats with Texture:getViewFormats.
This commit is contained in:
Sasha Szpakowski
2024-02-24 23:42:28 -04:00
parent 42812ad521
commit e20f018272
7 changed files with 96 additions and 32 deletions
+21 -2
View File
@@ -100,9 +100,17 @@ bool Texture::loadVolatile()
if (root)
{
VkImageCreateFlags createFlags = 0;
std::vector<VkFormat> vkviewformats;
if (viewFormats)
createFlags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
for (PixelFormat viewformat : viewFormats)
{
if (viewformat != format)
{
createFlags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
TextureFormat f = Vulkan::getTextureFormat(viewformat);
vkviewformats.push_back(f.internalFormat);
}
}
if (texType == TEXTURE_CUBE || texType == TEXTURE_2D_ARRAY)
createFlags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
@@ -125,6 +133,17 @@ bool Texture::loadVolatile()
imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
imageInfo.samples = msaaSamples;
VkImageFormatListCreateInfo viewFormatsInfo{};
viewFormatsInfo.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO;
if (!vkviewformats.empty() && vgfx->getDeviceApiVersion() >= VK_API_VERSION_1_2)
{
viewFormatsInfo.viewFormatCount = (uint32)vkviewformats.size();
viewFormatsInfo.pViewFormats = vkviewformats.data();
imageInfo.pNext = &viewFormatsInfo;
}
VmaAllocationCreateInfo imageAllocationCreateInfo{};
if (vmaCreateImage(allocator, &imageInfo, &imageAllocationCreateInfo, &textureImage, &textureImageAllocation, nullptr) != VK_SUCCESS)