Index: src/gpu/vk/GrVkUtil.cpp |
diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp |
index a6a9d4c1a1df29072efb33b1d2650c6cbf98fe7a..760b20b4580e7f75de814d032b59cd954077aae5 100644 |
--- a/src/gpu/vk/GrVkUtil.cpp |
+++ b/src/gpu/vk/GrVkUtil.cpp |
@@ -118,6 +118,105 @@ bool GrVkFormatToPixelConfig(VkFormat format, GrPixelConfig* config) { |
return true; |
} |
+bool GrVkFormatIsSRGB(VkFormat format, VkFormat* linearFormat) { |
+ VkFormat linearFmt = format; |
+ switch (format) { |
+ case VK_FORMAT_R8_SRGB: |
+ linearFmt = VK_FORMAT_R8_UNORM; |
+ break; |
+ case VK_FORMAT_R8G8_SRGB: |
+ linearFmt = VK_FORMAT_R8G8_UNORM; |
+ break; |
+ case VK_FORMAT_R8G8B8_SRGB: |
+ linearFmt = VK_FORMAT_R8G8B8_UNORM; |
+ break; |
+ case VK_FORMAT_B8G8R8_SRGB: |
+ linearFmt = VK_FORMAT_B8G8R8_UNORM; |
+ break; |
+ case VK_FORMAT_R8G8B8A8_SRGB: |
+ linearFmt = VK_FORMAT_R8G8B8A8_UNORM; |
+ break; |
+ case VK_FORMAT_B8G8R8A8_SRGB: |
+ linearFmt = VK_FORMAT_B8G8R8A8_UNORM; |
+ break; |
+ case VK_FORMAT_A8B8G8R8_SRGB_PACK32: |
+ linearFmt = VK_FORMAT_A8B8G8R8_UNORM_PACK32; |
+ break; |
+ case VK_FORMAT_BC1_RGB_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_BC1_RGB_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_BC1_RGBA_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_BC2_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_BC2_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_BC3_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_BC3_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_BC7_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_BC7_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_4x4_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_5x4_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_5x5_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_6x5_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_6x6_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_8x5_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_8x6_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_8x8_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_10x5_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_10x6_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_10x8_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_10x10_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_12x10_UNORM_BLOCK; |
+ break; |
+ case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: |
+ linearFmt = VK_FORMAT_ASTC_12x12_UNORM_BLOCK; |
+ break; |
+ default: |
+ break; |
+ } |
+ if (linearFormat) { |
+ *linearFormat = linearFmt; |
+ } |
+ return (linearFmt != format); |
+} |
+ |
bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples) { |
switch (samples) { |
case 0: // fall through |