diff --git a/src/dxvk/dxvk_image.cpp b/src/dxvk/dxvk_image.cpp index b25d9d977..da4fba07c 100644 --- a/src/dxvk/dxvk_image.cpp +++ b/src/dxvk/dxvk_image.cpp @@ -8,10 +8,24 @@ namespace dxvk { DxvkMemoryAllocator& memAlloc, VkMemoryPropertyFlags memFlags) : m_vkd(vkd), m_info(createInfo), m_memFlags(memFlags) { + + // Copy the compatible view formats to a persistent array + m_viewFormats.resize(createInfo.viewFormatCount); + for (uint32_t i = 0; i < createInfo.viewFormatCount; i++) + m_viewFormats[i] = createInfo.viewFormats[i]; + m_info.viewFormats = m_viewFormats.data(); + + // If defined, we should provide a format list, which + // allows some drivers to enable image compression + VkImageFormatListCreateInfoKHR formatList; + formatList.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR; + formatList.pNext = nullptr; + formatList.viewFormatCount = createInfo.viewFormatCount; + formatList.pViewFormats = createInfo.viewFormats; VkImageCreateInfo info; info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - info.pNext = nullptr; + info.pNext = &formatList; info.flags = createInfo.flags; info.imageType = createInfo.type; info.format = createInfo.format; diff --git a/src/dxvk/dxvk_image.h b/src/dxvk/dxvk_image.h index e8cc66b10..71f963005 100644 --- a/src/dxvk/dxvk_image.h +++ b/src/dxvk/dxvk_image.h @@ -50,6 +50,11 @@ namespace dxvk { /// Common image layout VkImageLayout layout; + + // Image view formats that can + // be used with this image + uint32_t viewFormatCount = 0; + const VkFormat* viewFormats = nullptr; }; @@ -240,6 +245,8 @@ namespace dxvk { VkMemoryPropertyFlags m_memFlags; DxvkMemory m_memory; VkImage m_image = VK_NULL_HANDLE; + + std::vector m_viewFormats; };