Commit e674625d by Mohan Maiya Committed by Commit Bot

Reland "Vulkan: Fix incorrect exposure of sRGB extensions"

This is a reland of abcabb47 only we continue to suppress the validation error Original change's description: > Vulkan: Fix incorrect exposure of sRGB extensions > > When we check to see what formats we can reinterpret for sRGB > extensions, we need to make sure we can match the image usage > flags as well. If the original format supports framebuffer > attachment usage, we need to make sure that the reinterpreted > format can support it as well. > > Bug: angleproject:5309 > Change-Id: I7e84d01004504f854a3e22227e99b1740ed1a2b2 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2549156 > Commit-Queue: Mohan Maiya <m.maiya@samsung.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> Bug: angleproject:5309 Change-Id: I0efb6180b7be4e14d24b4bb339de01a2b9177e7e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2556571 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent b1917fe1
...@@ -2201,6 +2201,13 @@ bool RendererVk::hasLinearImageFormatFeatureBits(VkFormat format, ...@@ -2201,6 +2201,13 @@ bool RendererVk::hasLinearImageFormatFeatureBits(VkFormat format,
return hasFormatFeatureBits<&VkFormatProperties::linearTilingFeatures>(format, featureBits); return hasFormatFeatureBits<&VkFormatProperties::linearTilingFeatures>(format, featureBits);
} }
VkFormatFeatureFlags RendererVk::getLinearImageFormatFeatureBits(
VkFormat format,
const VkFormatFeatureFlags featureBits) const
{
return getFormatFeatureBits<&VkFormatProperties::linearTilingFeatures>(format, featureBits);
}
VkFormatFeatureFlags RendererVk::getImageFormatFeatureBits( VkFormatFeatureFlags RendererVk::getImageFormatFeatureBits(
VkFormat format, VkFormat format,
const VkFormatFeatureFlags featureBits) const const VkFormatFeatureFlags featureBits) const
...@@ -2301,6 +2308,26 @@ bool RendererVk::hasFormatFeatureBits(VkFormat format, const VkFormatFeatureFlag ...@@ -2301,6 +2308,26 @@ bool RendererVk::hasFormatFeatureBits(VkFormat format, const VkFormatFeatureFlag
return IsMaskFlagSet(getFormatFeatureBits<features>(format, featureBits), featureBits); return IsMaskFlagSet(getFormatFeatureBits<features>(format, featureBits), featureBits);
} }
bool RendererVk::haveSameFormatFeatureBits(VkFormat fmt1, VkFormat fmt2) const
{
if (fmt1 == VK_FORMAT_UNDEFINED || fmt2 == VK_FORMAT_UNDEFINED)
{
return false;
}
constexpr VkFormatFeatureFlags kImageUsageFeatureBits =
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT |
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
VkFormatFeatureFlags fmt1LinearFeatureBits =
getLinearImageFormatFeatureBits(fmt1, kImageUsageFeatureBits);
VkFormatFeatureFlags fmt1OptimalFeatureBits =
getImageFormatFeatureBits(fmt1, kImageUsageFeatureBits);
return hasLinearImageFormatFeatureBits(fmt2, fmt1LinearFeatureBits) &&
hasImageFormatFeatureBits(fmt2, fmt1OptimalFeatureBits);
}
angle::Result RendererVk::cleanupGarbage(Serial lastCompletedQueueSerial) angle::Result RendererVk::cleanupGarbage(Serial lastCompletedQueueSerial)
{ {
std::lock_guard<std::mutex> lock(mGarbageMutex); std::lock_guard<std::mutex> lock(mGarbageMutex);
......
...@@ -161,6 +161,9 @@ class RendererVk : angle::NonCopyable ...@@ -161,6 +161,9 @@ class RendererVk : angle::NonCopyable
// device (first time only). // device (first time only).
bool hasLinearImageFormatFeatureBits(VkFormat format, bool hasLinearImageFormatFeatureBits(VkFormat format,
const VkFormatFeatureFlags featureBits) const; const VkFormatFeatureFlags featureBits) const;
VkFormatFeatureFlags getLinearImageFormatFeatureBits(
VkFormat format,
const VkFormatFeatureFlags featureBits) const;
VkFormatFeatureFlags getImageFormatFeatureBits(VkFormat format, VkFormatFeatureFlags getImageFormatFeatureBits(VkFormat format,
const VkFormatFeatureFlags featureBits) const; const VkFormatFeatureFlags featureBits) const;
bool hasImageFormatFeatureBits(VkFormat format, const VkFormatFeatureFlags featureBits) const; bool hasImageFormatFeatureBits(VkFormat format, const VkFormatFeatureFlags featureBits) const;
...@@ -294,6 +297,8 @@ class RendererVk : angle::NonCopyable ...@@ -294,6 +297,8 @@ class RendererVk : angle::NonCopyable
void outputVmaStatString(); void outputVmaStatString();
bool haveSameFormatFeatureBits(VkFormat fmt1, VkFormat fmt2) const;
angle::Result cleanupGarbage(Serial lastCompletedQueueSerial); angle::Result cleanupGarbage(Serial lastCompletedQueueSerial);
angle::Result submitFrame(vk::Context *context, angle::Result submitFrame(vk::Context *context,
......
...@@ -2630,7 +2630,8 @@ angle::Result TextureVk::initImage(ContextVk *contextVk, ...@@ -2630,7 +2630,8 @@ angle::Result TextureVk::initImage(ContextVk *contextVk,
: vk::ConvertToSRGB(imageFormat); : vk::ConvertToSRGB(imageFormat);
VkImageFormatListCreateInfoKHR formatListInfo = {}; VkImageFormatListCreateInfoKHR formatListInfo = {};
if (renderer->getFeatures().supportsImageFormatList.enabled) if (renderer->getFeatures().supportsImageFormatList.enabled &&
renderer->haveSameFormatFeatureBits(imageFormat, imageListFormat))
{ {
mRequiresMutableStorage = true; mRequiresMutableStorage = true;
......
...@@ -51,6 +51,9 @@ bool HasShaderImageAtomicsSupport(const RendererVk *rendererVk, ...@@ -51,6 +51,9 @@ bool HasShaderImageAtomicsSupport(const RendererVk *rendererVk,
return hasImageAtomicSupport && hasBufferAtomicSupport; return hasImageAtomicSupport && hasBufferAtomicSupport;
} }
// Checks to see if each format can be reinterpreted to an equivalent format in a different
// colorspace. If all supported formats can be reinterpreted, it returns true. Formats which are not
// supported at all are ignored and not counted as failures.
bool FormatReinterpretationSupported(const std::vector<GLenum> &optionalSizedFormats, bool FormatReinterpretationSupported(const std::vector<GLenum> &optionalSizedFormats,
const RendererVk *rendererVk, const RendererVk *rendererVk,
bool checkLinearColorspace) bool checkLinearColorspace)
...@@ -65,18 +68,14 @@ bool FormatReinterpretationSupported(const std::vector<GLenum> &optionalSizedFor ...@@ -65,18 +68,14 @@ bool FormatReinterpretationSupported(const std::vector<GLenum> &optionalSizedFor
VkFormat reinterpretedFormat = checkLinearColorspace VkFormat reinterpretedFormat = checkLinearColorspace
? ConvertToLinear(vkFormat.vkImageFormat) ? ConvertToLinear(vkFormat.vkImageFormat)
: ConvertToSRGB(vkFormat.vkImageFormat); : ConvertToSRGB(vkFormat.vkImageFormat);
ASSERT(reinterpretedFormat != VK_FORMAT_UNDEFINED);
constexpr uint32_t kBitsSampleFilter = if (!rendererVk->haveSameFormatFeatureBits(vkFormat.vkImageFormat, reinterpretedFormat))
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
if (!rendererVk->hasImageFormatFeatureBits(reinterpretedFormat, kBitsSampleFilter))
{ {
return false; return false;
} }
} }
} }
return true; return true;
} }
......
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