Commit cbdb76b0 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Create sRGB views only when needed

Creating sRGB views was conditioned to VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT being necessary, but that flag can be set for reasons other than sRGB override, such as when recreating the image to be used as a storage image. Bug: angleproject:4551 Change-Id: I6f94a1c898b599d4333d74608c7451b4ce4f71f0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2279134Reviewed-by: 's avatarMohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent a86c8547
......@@ -172,6 +172,7 @@ void Set3DBaseArrayLayerAndLayerCount(VkImageSubresourceLayers *Subresource)
TextureVk::TextureVk(const gl::TextureState &state, RendererVk *renderer)
: TextureImpl(state),
mOwnsImage(false),
mRequiresSRGBViews(false),
mImageNativeType(gl::TextureType::InvalidEnum),
mImageLayerOffset(0),
mImageLevelOffset(0),
......@@ -1750,6 +1751,7 @@ angle::Result TextureVk::syncState(const gl::Context *context,
if (mState.getSRGBOverride() != gl::SrgbOverride::Default)
{
mImageCreateFlags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
mRequiresSRGBViews = true;
}
}
......@@ -2046,8 +2048,9 @@ angle::Result TextureVk::initImageViews(ContextVk *contextVk,
ANGLE_TRY(mImageViews.initReadViews(contextVk, mState.getType(), *mImage, format, formatSwizzle,
readSwizzle, baseLevel, levelCount, baseLayer, layerCount));
if ((mImageCreateFlags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) != 0)
if (mRequiresSRGBViews)
{
ASSERT((mImageCreateFlags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) != 0);
ANGLE_TRY(mImageViews.initSRGBReadViews(
contextVk, mState.getType(), *mImage, format, formatSwizzle, readSwizzle, baseLevel,
levelCount, baseLayer, layerCount, mImageUsageFlags & ~VK_IMAGE_USAGE_STORAGE_BIT));
......
......@@ -391,6 +391,7 @@ class TextureVk : public TextureImpl, public angle::ObserverInterface
}
bool mOwnsImage;
bool mRequiresSRGBViews;
gl::TextureType mImageNativeType;
......
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