Start removing uses of VkFormatToPixelConfig in vulkan backend
Bug: skia:
Change-Id: I2c8e86b9e8ca6a33913be347a3c65af963c5fd12
Reviewed-on: https://skia-review.googlesource.com/84341
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp
index 1b20605..cb0046e 100644
--- a/src/gpu/vk/GrVkUtil.cpp
+++ b/src/gpu/vk/GrVkUtil.cpp
@@ -106,6 +106,63 @@
}
}
+bool GrVkFormatPixelConfigPairIsValid(VkFormat format, GrPixelConfig config) {
+ switch (format) {
+ case VK_FORMAT_R8G8B8A8_UNORM:
+ return kRGBA_8888_GrPixelConfig == config;
+ case VK_FORMAT_B8G8R8A8_UNORM:
+ return kBGRA_8888_GrPixelConfig == config;
+ case VK_FORMAT_R8G8B8A8_SRGB:
+ return kSRGBA_8888_GrPixelConfig == config;
+ case VK_FORMAT_B8G8R8A8_SRGB:
+ return kSBGRA_8888_GrPixelConfig == config;
+ case VK_FORMAT_R8G8B8A8_SINT:
+ return kRGBA_8888_sint_GrPixelConfig == config;
+ case VK_FORMAT_R5G6B5_UNORM_PACK16:
+ return kRGB_565_GrPixelConfig == config;
+ case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
+ // R4G4B4A4 is not required to be supported so we actually
+ // store RGBA_4444 data as B4G4R4A4.
+ return kRGBA_4444_GrPixelConfig == config;
+ case VK_FORMAT_R8_UNORM:
+ return kAlpha_8_GrPixelConfig == config ||
+ kAlpha_8_as_Red_GrPixelConfig == config ||
+ kGray_8_GrPixelConfig == config ||
+ kGray_8_as_Red_GrPixelConfig == config;
+ case VK_FORMAT_R32G32B32A32_SFLOAT:
+ return kRGBA_float_GrPixelConfig == config;
+ case VK_FORMAT_R32G32_SFLOAT:
+ return kRG_float_GrPixelConfig == config;
+ case VK_FORMAT_R16G16B16A16_SFLOAT:
+ return kRGBA_half_GrPixelConfig == config;
+ case VK_FORMAT_R16_SFLOAT:
+ return kAlpha_half_GrPixelConfig == config ||
+ kAlpha_half_as_Red_GrPixelConfig == config;
+ default:
+ return false;
+ }
+}
+
+bool GrVkFormatIsSupported(VkFormat format) {
+ switch (format) {
+ case VK_FORMAT_R8G8B8A8_UNORM:
+ case VK_FORMAT_B8G8R8A8_UNORM:
+ case VK_FORMAT_R8G8B8A8_SRGB:
+ case VK_FORMAT_B8G8R8A8_SRGB:
+ case VK_FORMAT_R8G8B8A8_SINT:
+ case VK_FORMAT_R5G6B5_UNORM_PACK16:
+ case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
+ case VK_FORMAT_R8_UNORM:
+ case VK_FORMAT_R32G32B32A32_SFLOAT:
+ case VK_FORMAT_R32G32_SFLOAT:
+ case VK_FORMAT_R16G16B16A16_SFLOAT:
+ case VK_FORMAT_R16_SFLOAT:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool GrVkFormatIsSRGB(VkFormat format, VkFormat* linearFormat) {
VkFormat linearFmt = format;
switch (format) {