Commit 23d1f9b4 by Mohan Maiya Committed by Commit Bot

Vulkan: Add support for VK_KHR_image_format_list extension

GLES sRGB extensions allows for a texture to be respecified, with say the sRGB_override extension, which will require us to reinterpret the data in the texture in sRGB colorspace (or linear depending on the format of the texture). If the underlying ICD supports VK_KHR_image_format_list extension we create a texture's backing VkImage with the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT enabled since we already know the format we might need to reinterpret the texture as. Bug: angleproject:3609 Bug: angleproject:4561 Bug: angleproject:5281 Change-Id: Ia4bed596ed3000f8af1a8fd73fb8e6c2cb9b5d6e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2513110 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 8a275449
......@@ -390,6 +390,14 @@ struct FeaturesVk : FeatureSetBase
"Force max uniform buffer size to 16K on some device due to bug", &members,
"https://issuetracker.google.com/161903006"};
// Enable mutable bit by default for ICD's that support VK_KHR_image_format_list.
// http://anglebug.com/5281
Feature supportsImageFormatList = {
"supportsImageFormatList", FeatureCategory::VulkanFeatures,
"Enable VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT by default for ICDs "
"that support VK_KHR_image_format_list",
&members, "http://anglebug.com/5281"};
// Swiftshader on mac fails to initialize WebGL context when EXT_multisampled_render_to_texture
// is used by Chromium.
// http://anglebug.com/4937
......
......@@ -1334,6 +1334,11 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
enabledDeviceExtensions.push_back(VK_QCOM_render_pass_store_ops_EXTENSION_NAME);
}
if (getFeatures().supportsImageFormatList.enabled)
{
enabledDeviceExtensions.push_back(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
}
std::sort(enabledDeviceExtensions.begin(), enabledDeviceExtensions.end(), StrLess);
ANGLE_VK_TRY(displayVk, VerifyExtensionsPresent(deviceExtensionNames, enabledDeviceExtensions));
......@@ -1973,6 +1978,10 @@ void RendererVk::initFeatures(DisplayVk *displayVk, const ExtensionNameList &dev
bool isAdreno540 = mPhysicalDeviceProperties.deviceID == angle::kDeviceID_Adreno540;
ANGLE_FEATURE_CONDITION(&mFeatures, forceMaxUniformBufferSize16KB, isQualcomm && isAdreno540);
ANGLE_FEATURE_CONDITION(
&mFeatures, supportsImageFormatList,
(ExtensionFound(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, deviceExtensionNames)) && isAMD);
// Feature disabled due to driver bugs:
//
// - Swiftshader on mac: http://anglebug.com/4937
......
......@@ -1234,6 +1234,7 @@ void TextureVk::releaseAndDeleteImage(ContextVk *contextVk)
releaseImage(contextVk);
releaseStagingBuffer(contextVk);
mImageObserverBinding.bind(nullptr);
mRequiresMutableStorage = false;
SafeDelete(mImage);
}
mRedefinedLevels.reset();
......@@ -2386,9 +2387,34 @@ angle::Result TextureVk::initImage(ContextVk *contextVk,
gl_vk::GetExtentsAndLayerCount(mState.getType(), extents, &vkExtent, &layerCount);
GLint samples = mState.getBaseLevelDesc().samples ? mState.getBaseLevelDesc().samples : 1;
// With the introduction of sRGB related GLES extensions any texture could be respecified
// causing it to be interpreted in a different colorspace. Create the VkImage accordingly.
VkImageFormatListCreateInfoKHR *additionalCreateInfo = nullptr;
VkFormat imageFormat = format.vkImageFormat;
VkFormat imageListFormat = format.actualImageFormat().isSRGB ? vk::ConvertToLinear(imageFormat)
: vk::ConvertToSRGB(imageFormat);
VkImageFormatListCreateInfoKHR formatListInfo = {};
if (renderer->getFeatures().supportsImageFormatList.enabled &&
(imageListFormat != VK_FORMAT_UNDEFINED))
{
mRequiresMutableStorage = true;
// Add VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT to VkImage create flag
mImageCreateFlags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
// There is just 1 additional format we might use to create a VkImageView for this VkImage
formatListInfo.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR;
formatListInfo.pNext = nullptr;
formatListInfo.viewFormatCount = 1;
formatListInfo.pViewFormats = &imageListFormat;
additionalCreateInfo = &formatListInfo;
}
ANGLE_TRY(mImage->initExternal(contextVk, mState.getType(), vkExtent, format, samples,
mImageUsageFlags, mImageCreateFlags, vk::ImageLayout::Undefined,
nullptr, gl::LevelIndex(mState.getEffectiveBaseLevel()),
additionalCreateInfo,
gl::LevelIndex(mState.getEffectiveBaseLevel()),
gl::LevelIndex(mState.getEffectiveMaxLevel()), levelCount,
layerCount, contextVk->isRobustResourceInitEnabled()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment