Revert "Removed made-up kSBGRA pixel config."

This reverts commit ff95f6ca9d.

Reason for revert: Broke command buffer GLBackendAllocationTest??

Original change's description:
> Removed made-up kSBGRA pixel config.
> 
> We made up this pixel config and don't actually use it ourselves so lets
> kill it for simplicity.
> 
> Change-Id: I6ae1c78fe7ada336a2411d295e8836dfeecb2d5c
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223979
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,robertphillips@google.com,brianosman@google.com

Change-Id: I62e954495a702c7ad050719d8a1d6c4abcea3f60
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223990
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2019-06-26 23:52:02 +00:00 committed by Skia Commit-Bot
parent 7bc178b1d5
commit 70aae53d57
19 changed files with 93 additions and 7 deletions

View File

@ -50,6 +50,7 @@ enum GrPixelConfig {
kRG_88_GrPixelConfig,
kBGRA_8888_GrPixelConfig,
kSRGBA_8888_GrPixelConfig,
kSBGRA_8888_GrPixelConfig,
kRGBA_1010102_GrPixelConfig,
kRGBA_float_GrPixelConfig,
kRG_float_GrPixelConfig,
@ -861,6 +862,7 @@ enum class GrSRGBConversion {
static inline GrSRGBEncoded GrPixelConfigIsSRGBEncoded(GrPixelConfig config) {
switch (config) {
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
return GrSRGBEncoded::kYes;
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
@ -920,6 +922,7 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
case kRGB_888X_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRG_1616_GrPixelConfig:
return 4;
@ -968,6 +971,7 @@ static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
@ -1000,6 +1004,7 @@ static inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) {
case kRG_88_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
@ -1034,6 +1039,7 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGB_ETC1_GrPixelConfig:
case kR_16_GrPixelConfig:
@ -1131,6 +1137,7 @@ static inline GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) {
case kRG_88_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGB_ETC1_GrPixelConfig:
return kLow_GrSLPrecision;
case kRGBA_float_GrPixelConfig:
@ -1339,6 +1346,9 @@ static inline GrColorType GrPixelConfigToColorTypeAndEncoding(GrPixelConfig conf
case kSRGBA_8888_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kYes;
return GrColorType::kRGBA_8888;
case kSBGRA_8888_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kYes;
return GrColorType::kBGRA_8888;
case kRGBA_1010102_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kNo;
return GrColorType::kRGBA_1010102;
@ -1432,7 +1442,7 @@ static inline GrPixelConfig GrColorTypeToPixelConfig(GrColorType config,
: kRG_88_GrPixelConfig;
case GrColorType::kBGRA_8888:
return (GrSRGBEncoded::kYes == srgbEncoded) ? kUnknown_GrPixelConfig
return (GrSRGBEncoded::kYes == srgbEncoded) ? kSBGRA_8888_GrPixelConfig
: kBGRA_8888_GrPixelConfig;
case GrColorType::kRGBA_1010102:

View File

@ -98,8 +98,9 @@ static GrPixelConfig get_blur_config(GrTextureProxy* proxy) {
SkASSERT(kBGRA_8888_GrPixelConfig == config || kRGBA_8888_GrPixelConfig == config ||
kRGB_888_GrPixelConfig == config || kRGBA_4444_GrPixelConfig == config ||
kRGB_565_GrPixelConfig == config || kSRGBA_8888_GrPixelConfig == config ||
kRGBA_half_GrPixelConfig == config || kAlpha_8_GrPixelConfig == config ||
kRGBA_1010102_GrPixelConfig == config || kRGBA_half_Clamped_GrPixelConfig == config);
kSBGRA_8888_GrPixelConfig == config || kRGBA_half_GrPixelConfig == config ||
kAlpha_8_GrPixelConfig == config || kRGBA_1010102_GrPixelConfig == config ||
kRGBA_half_Clamped_GrPixelConfig == config);
return config;
}

View File

@ -144,6 +144,7 @@ static const char* pixel_config_name(GrPixelConfig config) {
case kRG_88_GrPixelConfig: return "RG88";
case kBGRA_8888_GrPixelConfig: return "BGRA8888";
case kSRGBA_8888_GrPixelConfig: return "SRGBA8888";
case kSBGRA_8888_GrPixelConfig: return "SBGRA8888";
case kRGBA_1010102_GrPixelConfig: return "RGBA1010102";
case kRGBA_float_GrPixelConfig: return "RGBAFloat";
case kRG_float_GrPixelConfig: return "RGFloat";

View File

@ -213,6 +213,12 @@ static bool fill_buffer_with_color(GrPixelConfig config, int width, int height,
sk_memset32((uint32_t *) dest, color, width * height);
break;
}
case kSBGRA_8888_GrPixelConfig: {
GrColor swizzled = GrColorPackRGBA(b, g, r, a);
sk_memset32((uint32_t *) dest, swizzled, width * height);
break;
}
case kRGBA_1010102_GrPixelConfig: {
uint32_t r10 = SkScalarRoundToInt(colorf.fR * 1023.0f);
uint32_t g10 = SkScalarRoundToInt(colorf.fG * 1023.0f);

View File

@ -272,10 +272,11 @@ static inline bool color_type_and_config_fallback(GrColorType* ct, GrPixelConfig
*ct = GrColorType::kRGBA_8888;
return true;
case GrColorType::kBGRA_8888:
if (*config != kBGRA_8888_GrPixelConfig) {
if (*config != kBGRA_8888_GrPixelConfig && *config != kSBGRA_8888_GrPixelConfig) {
return false;
}
*config = kRGBA_8888_GrPixelConfig;
*config = (*config == kSBGRA_8888_GrPixelConfig) ? kSRGBA_8888_GrPixelConfig
: kRGBA_8888_GrPixelConfig;
*ct = GrColorType::kRGBA_8888;
return true;
case GrColorType::kRGBA_1010102:

View File

@ -98,6 +98,7 @@ static bool valid_premul_config(GrPixelConfig config) {
case kRG_88_GrPixelConfig: return false;
case kBGRA_8888_GrPixelConfig: return true;
case kSRGBA_8888_GrPixelConfig: return true;
case kSBGRA_8888_GrPixelConfig: return true;
case kRGBA_1010102_GrPixelConfig: return true;
case kRGBA_float_GrPixelConfig: return true;
case kRG_float_GrPixelConfig: return false;

View File

@ -307,6 +307,7 @@ static inline int32_t dither_range_type_for_config(GrPixelConfig dstConfig) {
return 2;
case kUnknown_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:

View File

@ -1745,6 +1745,25 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
if (texStorageSupported && !disablePerFormatTextureStorageForCommandBufferES2) {
fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
// sBGRA is not a "real" thing in OpenGL, but GPUs support it, and on platforms where
// kN32 == BGRA, we need some way to work with it. (The default framebuffer on Windows
// is in this format, for example).
fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_SRGB_ALPHA;
fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_SRGB8_ALPHA8;
// GL does not do srgb<->rgb conversions when transferring between cpu and gpu. Thus, the
// external format is GL_BGRA.
fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] =
GR_GL_BGRA;
fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
fConfigTable[kSBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
if (fSRGBSupport && GR_IS_GR_GL(standard)) {
fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
srgbRenderFlags;
}
if (texStorageSupported) {
fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGB;
if (this->ES2CompatibilitySupport()) {
@ -2245,6 +2264,19 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
fConfigTable[kAlpha_8_as_Alpha_GrPixelConfig].fFormats.fBaseInternalFormat;
}
// OpenGL ES 2.0 + GL_EXT_sRGB allows GL_SRGB_ALPHA to be specified as the <format>
// param to Tex(Sub)Image. ES 2.0 requires the <internalFormat> and <format> params to match.
// Thus, on ES 2.0 we will use GL_SRGB_ALPHA as the <format> param.
// On OpenGL and ES 3.0+ GL_SRGB_ALPHA does not work for the <format> param to glTexImage.
if (GR_IS_GR_GL_ES(standard) && version == GR_GL_VER(2,0)) {
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kTexImage_ExternalFormatUsage] =
GR_GL_SRGB_ALPHA;
// Additionally, because we had to "invent" sBGRA, there is no way to make it work
// in ES 2.0, because there is no <internalFormat> we can use. So just make that format
// unsupported. (If we have no sRGB support at all, this will get overwritten below).
fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = 0;
}
// On ES 2.0 we have to use GL_RGB with glTexImage as the internal/external formats must
// be the same. Moreover, if we write kRGB_888x data to a texture format on non-ES2 we want to
// be sure that we write 1 for alpha not whatever happens to be in the client provided the 'x'
@ -3207,6 +3239,8 @@ GrPixelConfig validate_sized_format(GrGLenum format, SkColorType ct, GrGLStandar
if (GR_IS_GR_GL_ES(standard) || GR_IS_GR_WEBGL(standard)) {
return kBGRA_8888_GrPixelConfig;
}
} else if (GR_GL_SRGB8_ALPHA8 == format) {
return kSBGRA_8888_GrPixelConfig;
}
break;
case kRGBA_1010102_SkColorType:

View File

@ -879,6 +879,7 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
case kRGB_888X_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
@ -3948,7 +3949,7 @@ static bool gl_format_to_pixel_config(GrGLenum format, GrPixelConfig* config) {
*config = kGray_8_GrPixelConfig;
return true;
case GR_GL_SRGB8_ALPHA8:
*config = kSRGBA_8888_GrPixelConfig;
*config = kSRGBA_8888_GrPixelConfig; // aliasing kSBGRA_8888 here
return true;
case GR_GL_RGB10_A2:
*config = kRGBA_1010102_GrPixelConfig;

View File

@ -41,7 +41,8 @@ public:
return false;
}
return kSRGBA_8888_GrPixelConfig == *format.getMockFormat();
return kSRGBA_8888_GrPixelConfig == *format.getMockFormat() ||
kSBGRA_8888_GrPixelConfig == *format.getMockFormat();
}
bool isFormatTexturable(SkColorType, const GrBackendFormat& format) const override {

View File

@ -400,6 +400,10 @@ void GrMtlCaps::initConfigTable() {
info = &fConfigTable[kSRGBA_8888_GrPixelConfig];
info->fFlags = ConfigInfo::kAllFlags;
// SBGRA_8888 uses BGRA8Unorm_sRGB
info = &fConfigTable[kSBGRA_8888_GrPixelConfig];
info->fFlags = ConfigInfo::kAllFlags;
// kRGBA_1010102 uses RGB10A2Unorm
info = &fConfigTable[kRGBA_1010102_GrPixelConfig];
if (this->isMac() || fFamilyGroup >= 3) {
@ -521,6 +525,8 @@ GrPixelConfig validate_sized_format(GrMTLPixelFormat grFormat, SkColorType ct) {
case kBGRA_8888_SkColorType:
if (MTLPixelFormatBGRA8Unorm == format) {
return kBGRA_8888_GrPixelConfig;
} else if (MTLPixelFormatBGRA8Unorm_sRGB == format) {
return kSBGRA_8888_GrPixelConfig;
}
break;
case kRGBA_1010102_SkColorType:

View File

@ -720,6 +720,9 @@ static bool mtl_format_to_pixel_config(MTLPixelFormat format, GrPixelConfig* con
case MTLPixelFormatRGBA8Unorm_sRGB:
*config = kSRGBA_8888_GrPixelConfig;
return true;
case MTLPixelFormatBGRA8Unorm_sRGB:
*config = kSBGRA_8888_GrPixelConfig;
return true;
case MTLPixelFormatRGB10A2Unorm:
*config = kRGBA_1010102_GrPixelConfig;
return true;

View File

@ -49,6 +49,9 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
case kSRGBA_8888_GrPixelConfig:
*format = MTLPixelFormatRGBA8Unorm_sRGB;
return true;
case kSBGRA_8888_GrPixelConfig:
*format = MTLPixelFormatBGRA8Unorm_sRGB;
return true;
case kRGBA_1010102_GrPixelConfig:
*format = MTLPixelFormatRGB10A2Unorm;
return true;

View File

@ -97,6 +97,7 @@ static int get_compatible_format_class(GrPixelConfig config) {
case kRGB_888X_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRG_1616_GrPixelConfig:
return 4;
@ -984,6 +985,8 @@ static GrPixelConfig validate_image_info(VkFormat format, SkColorType ct, bool h
case kBGRA_8888_SkColorType:
if (VK_FORMAT_B8G8R8A8_UNORM == format) {
return kBGRA_8888_GrPixelConfig;
} else if (VK_FORMAT_B8G8R8A8_SRGB == format) {
return kSBGRA_8888_GrPixelConfig;
}
break;
case kRGBA_1010102_SkColorType:

View File

@ -1838,6 +1838,9 @@ static bool vk_format_to_pixel_config(VkFormat format, GrPixelConfig* config) {
case VK_FORMAT_R8G8B8A8_SRGB:
*config = kSRGBA_8888_GrPixelConfig;
return true;
case VK_FORMAT_B8G8R8A8_SRGB:
*config = kSBGRA_8888_GrPixelConfig;
return true;
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
*config = kRGBA_1010102_GrPixelConfig;
return true;

View File

@ -39,6 +39,9 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
case kSRGBA_8888_GrPixelConfig:
*format = VK_FORMAT_R8G8B8A8_SRGB;
return true;
case kSBGRA_8888_GrPixelConfig:
*format = VK_FORMAT_B8G8R8A8_SRGB;
return true;
case kRGBA_1010102_GrPixelConfig:
*format = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
return true;
@ -109,6 +112,8 @@ bool GrVkFormatPixelConfigPairIsValid(VkFormat format, GrPixelConfig config) {
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_R8G8B8_UNORM:
return kRGB_888_GrPixelConfig == config;
case VK_FORMAT_R8G8_UNORM:

View File

@ -415,6 +415,8 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
kRGBA_8888_GrPixelConfig, SkColors::kBlue },
{ kBGRA_8888_SkColorType, GR_GL_BGRA8,
kBGRA_8888_GrPixelConfig, SkColors::kBlue },
{ kBGRA_8888_SkColorType, GR_GL_SRGB8_ALPHA8,
kSBGRA_8888_GrPixelConfig, SkColors::kCyan },
{ kRGBA_1010102_SkColorType, GR_GL_RGB10_A2,
// TODO: readback is busted when alpha = 0.5f (perhaps premul vs. unpremul)
@ -580,6 +582,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) {
{ kRGB_888x_SkColorType, VK_FORMAT_R8G8B8_UNORM, SkColors::kCyan },
{ kBGRA_8888_SkColorType, VK_FORMAT_B8G8R8A8_UNORM, SkColors::kBlue },
{ kBGRA_8888_SkColorType, VK_FORMAT_B8G8R8A8_SRGB, SkColors::kCyan },
{ kRGBA_1010102_SkColorType, VK_FORMAT_A2B10G10R10_UNORM_PACK32, { 0.5f, 0, 0, 1.0f } },
{ kRGB_565_SkColorType, VK_FORMAT_R5G6B5_UNORM_PACK16, SkColors::kRed },

View File

@ -95,6 +95,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
kRG_88_GrPixelConfig,
kBGRA_8888_GrPixelConfig,
kSRGBA_8888_GrPixelConfig,
kSBGRA_8888_GrPixelConfig,
kRGBA_1010102_GrPixelConfig,
kRGBA_float_GrPixelConfig,
kRG_float_GrPixelConfig,

View File

@ -50,6 +50,8 @@ DEF_GPUTEST_FOR_METAL_CONTEXT(MtlBackendAllocationTest, reporter, ctxInfo) {
{ kBGRA_8888_SkColorType, MTLPixelFormatBGRA8Unorm,
kBGRA_8888_GrPixelConfig, SkColors::kBlue },
{ kBGRA_8888_SkColorType, MTLPixelFormatBGRA8Unorm_sRGB,
kSBGRA_8888_GrPixelConfig, SkColors::kCyan },
{ kRGBA_1010102_SkColorType, MTLPixelFormatRGB10A2Unorm,
kRGBA_1010102_GrPixelConfig, { 0.5f, 0, 0, 1.0f } },