Commit abcabb47 by Mohan Maiya Committed by Commit Bot

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: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 6f6504c9
...@@ -157,8 +157,6 @@ constexpr const char *kSkippedMessages[] = { ...@@ -157,8 +157,6 @@ constexpr const char *kSkippedMessages[] = {
// http://anglebug.com/5304 // http://anglebug.com/5304
"VUID-vkCmdDraw-magFilter-04553", "VUID-vkCmdDraw-magFilter-04553",
"VUID-vkCmdDrawIndexed-magFilter-04553", "VUID-vkCmdDrawIndexed-magFilter-04553",
// http://anglebug.com/5309
"VUID-VkImageViewCreateInfo-usage-02652",
// http://anglebug.com/5336 // http://anglebug.com/5336
"UNASSIGNED-BestPractices-vkCreateDevice-specialuse-extension", "UNASSIGNED-BestPractices-vkCreateDevice-specialuse-extension",
// http://anglebug.com/5331 // http://anglebug.com/5331
...@@ -2182,6 +2180,13 @@ bool RendererVk::hasLinearImageFormatFeatureBits(VkFormat format, ...@@ -2182,6 +2180,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
...@@ -2282,6 +2287,26 @@ bool RendererVk::hasFormatFeatureBits(VkFormat format, const VkFormatFeatureFlag ...@@ -2282,6 +2287,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,
......
...@@ -2582,7 +2582,8 @@ angle::Result TextureVk::initImage(ContextVk *contextVk, ...@@ -2582,7 +2582,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;
......
...@@ -50,6 +50,9 @@ bool HasShaderImageAtomicsSupport(const RendererVk *rendererVk, ...@@ -50,6 +50,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)
...@@ -64,18 +67,14 @@ bool FormatReinterpretationSupported(const std::vector<GLenum> &optionalSizedFor ...@@ -64,18 +67,14 @@ bool FormatReinterpretationSupported(const std::vector<GLenum> &optionalSizedFor
VkFormat reinterpretedFormat = checkLinearColorspace VkFormat reinterpretedFormat = checkLinearColorspace
? vk::ConvertToLinear(vkFormat.vkImageFormat) ? vk::ConvertToLinear(vkFormat.vkImageFormat)
: vk::ConvertToSRGB(vkFormat.vkImageFormat); : vk::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