Set the "mutable format" bit on sRGB images at creation time.
This allows us to later create an image view with a linear format, for
legacy-mode non-sRGB access.
No actual API change (just a comment change in public header).
TBR=bsalomon@google.com
BUG=skia:5308
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1981333004
Review-Url: https://codereview.chromium.org/1981333004
diff --git a/include/gpu/vk/GrVkTypes.h b/include/gpu/vk/GrVkTypes.h
index deee409..94b765f 100644
--- a/include/gpu/vk/GrVkTypes.h
+++ b/include/gpu/vk/GrVkTypes.h
@@ -30,6 +30,10 @@
* Vulkan textures are really const GrVkImageInfo*
*/
struct GrVkImageInfo {
+ /**
+ * If the image's format is sRGB (GrVkFormatIsSRGB returns true), then the image must have
+ * been created with VkImageCreateFlags containing VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT.
+ */
VkImage fImage;
VkDeviceMemory fAlloc; // can be VK_NULL_HANDLE iff Tex is an RT and uses borrow semantics
VkImageTiling fImageTiling;
diff --git a/src/gpu/vk/GrVkImage.cpp b/src/gpu/vk/GrVkImage.cpp
index 9e7faf4..d3195e7 100644
--- a/src/gpu/vk/GrVkImage.cpp
+++ b/src/gpu/vk/GrVkImage.cpp
@@ -77,10 +77,14 @@
SkASSERT(VK_IMAGE_TILING_OPTIMAL == imageDesc.fImageTiling ||
VK_SAMPLE_COUNT_1_BIT == vkSamples);
+ // sRGB format images may need to be aliased to linear for various reasons (legacy mode):
+ VkImageCreateFlags createFlags = GrVkFormatIsSRGB(imageDesc.fFormat, nullptr)
+ ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0;
+
const VkImageCreateInfo imageCreateInfo = {
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
NULL, // pNext
- 0, // VkImageCreateFlags
+ createFlags, // VkImageCreateFlags
imageDesc.fImageType, // VkImageType
imageDesc.fFormat, // VkFormat
{ imageDesc.fWidth, imageDesc.fHeight, 1 }, // VkExtent3D