Add gray_8_as_lum and _as_red private grpixelconfigs

Bug: skia:
Change-Id: I70cbd0bc9f7a7a16fb9f0688d272d7afa607700a
Reviewed-on: https://skia-review.googlesource.com/80622
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2017-12-05 16:27:11 -05:00 committed by Skia Commit-Bot
parent 4e5029744d
commit 7af060a8bc
12 changed files with 82 additions and 25 deletions

View File

@ -340,8 +340,10 @@ enum GrPixelConfig {
kPrivateConfig1_GrPixelConfig,
kPrivateConfig2_GrPixelConfig,
kPrivateConfig3_GrPixelConfig,
kPrivateConfig4_GrPixelConfig,
kPrivateConfig5_GrPixelConfig,
kLast_GrPixelConfig = kPrivateConfig3_GrPixelConfig
kLast_GrPixelConfig = kPrivateConfig5_GrPixelConfig
};
static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;

View File

@ -763,11 +763,13 @@ GR_MAKE_BITFIELD_CLASS_OPS(GpuPathRenderers)
/**
* We want to extend the GrPixelConfig enum to add cases for dealing with alpha_8 which is
* internally either alpha8 or red8
* internally either alpha8 or red8. Also for Gray_8 which can be luminance_8 or red_8.
*/
static constexpr GrPixelConfig kAlpha_8_as_Alpha_GrPixelConfig = kPrivateConfig1_GrPixelConfig;
static constexpr GrPixelConfig kAlpha_8_as_Red_GrPixelConfig = kPrivateConfig2_GrPixelConfig;
static constexpr GrPixelConfig kAlpha_half_as_Red_GrPixelConfig = kPrivateConfig3_GrPixelConfig;
static constexpr GrPixelConfig kGray_8_as_Lum_GrPixelConfig = kPrivateConfig4_GrPixelConfig;
static constexpr GrPixelConfig kGray_8_as_Red_GrPixelConfig = kPrivateConfig5_GrPixelConfig;
/**
* Utility functions for GrPixelConfig
@ -785,6 +787,8 @@ static inline bool GrPixelConfigIs8888Unorm(GrPixelConfig config) {
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
@ -811,6 +815,8 @@ static inline bool GrPixelConfigIsSRGB(GrPixelConfig config) {
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
@ -844,6 +850,8 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) {
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
@ -864,6 +872,8 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
return 1;
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
@ -893,6 +903,8 @@ static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
switch (config) {
case kRGB_565_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRG_float_GrPixelConfig:
return true;
case kAlpha_8_GrPixelConfig:
@ -925,6 +937,8 @@ static inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) {
return true;
case kUnknown_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
@ -954,6 +968,8 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
@ -977,6 +993,8 @@ static inline bool GrPixelConfigIsUnorm(GrPixelConfig config) {
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
@ -1007,6 +1025,8 @@ static inline GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) {
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:

View File

@ -17,6 +17,8 @@ static const char* pixel_config_name(GrPixelConfig config) {
case kAlpha_8_as_Alpha_GrPixelConfig: return "Alpha8_asAlpha";
case kAlpha_8_as_Red_GrPixelConfig: return "Alpha8_asRed";
case kGray_8_GrPixelConfig: return "Gray8";
case kGray_8_as_Lum_GrPixelConfig: return "Gray8_asLum";
case kGray_8_as_Red_GrPixelConfig: return "Gray8_asRed";
case kRGB_565_GrPixelConfig: return "RGB565";
case kRGBA_4444_GrPixelConfig: return "RGBA444";
case kRGBA_8888_GrPixelConfig: return "RGBA8888";

View File

@ -373,7 +373,9 @@ bool GrPixelConfigToColorType(GrPixelConfig config, SkColorType* ctOut) {
case kAlpha_8_as_Red_GrPixelConfig:
ct = kAlpha_8_SkColorType;
break;
case kGray_8_GrPixelConfig:
case kGray_8_GrPixelConfig: // fall through
case kGray_8_as_Lum_GrPixelConfig: // fall through
case kGray_8_as_Red_GrPixelConfig:
ct = kGray_8_SkColorType;
break;
case kRGB_565_GrPixelConfig:

View File

@ -6,6 +6,8 @@ layout(key) in int rangeType;
int rangeType;
switch (dstConfig) {
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:

View File

@ -22,6 +22,8 @@ public:
int rangeType;
switch (dstConfig) {
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:

View File

@ -1940,26 +1940,29 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
fConfigTable[kAlpha_8_GrPixelConfig] = alphaInfo;
}
fConfigTable[kGray_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
fConfigTable[kGray_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
fConfigTable[kGray_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
if (this->textureRedSupport()) {
fConfigTable[kGray_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED;
fConfigTable[kGray_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R8;
fConfigTable[kGray_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
GR_GL_RED;
fConfigTable[kGray_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRA();
if (texelBufferSupport) {
fConfigTable[kGray_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag;
}
} else {
fConfigTable[kGray_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_LUMINANCE;
fConfigTable[kGray_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_LUMINANCE8;
fConfigTable[kGray_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
GR_GL_LUMINANCE;
fConfigTable[kGray_8_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
ConfigInfo& grayLumInfo = fConfigTable[kGray_8_as_Lum_GrPixelConfig];
grayLumInfo.fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
grayLumInfo.fFormatType = kNormalizedFixedPoint_FormatType;
grayLumInfo.fFormats.fBaseInternalFormat = GR_GL_LUMINANCE;
grayLumInfo.fFormats.fSizedInternalFormat = GR_GL_LUMINANCE8;
grayLumInfo.fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_LUMINANCE;
grayLumInfo.fSwizzle = GrSwizzle::RGBA();
if ((standard == kGL_GrGLStandard && version <= GR_GL_VER(3, 0)) ||
(standard == kGLES_GrGLStandard && version < GR_GL_VER(3, 0))) {
grayLumInfo.fFlags = ConfigInfo::kTextureable_Flag;
}
#if 0 // Leaving Gray8 as non-renderable, to keep things simple and match raster
ConfigInfo& grayRedInfo = fConfigTable[kGray_8_as_Red_GrPixelConfig];
grayRedInfo.fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
grayRedInfo.fFormatType = kNormalizedFixedPoint_FormatType;
grayRedInfo.fFormats.fBaseInternalFormat = GR_GL_RED;
grayRedInfo.fFormats.fSizedInternalFormat = GR_GL_R8;
grayRedInfo.fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_RED;
grayRedInfo.fSwizzle = GrSwizzle::RRRA();
grayRedInfo.fFlags = ConfigInfo::kTextureable_Flag;
#if 0 // Leaving Gray8 as non-renderable, to keep things simple and match raster. Needs to be
// updated to support Gray8_as_Lum and Gray8_as_red if this is ever enabled.
if (this->textureRedSupport() ||
(kDesktop_ARB_MSFBOType == this->msFBOType() &&
ctxInfo.renderer() != kOSMesa_GrGLRenderer)) {
@ -1970,7 +1973,20 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
}
#endif
if (texStorageSupported && !isCommandBufferES2) {
fConfigTable[kGray_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
if (GrGLANGLEBackend::kOpenGL != ctxInfo.angleBackend()) {
grayLumInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
grayRedInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
if (this->textureRedSupport()) {
if (texelBufferSupport) {
grayRedInfo.fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag;
}
fConfigTable[kGray_8_GrPixelConfig] = grayRedInfo;
} else {
grayRedInfo.fFlags = 0;
fConfigTable[kGray_8_GrPixelConfig] = grayLumInfo;
}
// Check for [half] floating point texture support

View File

@ -786,6 +786,8 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
return 1;
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:

View File

@ -53,9 +53,12 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
return true;
case kAlpha_8_as_Alpha_GrPixelConfig:
return false;
case kGray_8_GrPixelConfig:
case kGray_8_GrPixelConfig: // fall through
case kGray_8_as_Red_GrPixelConfig:
*format = MTLPixelFormatR8Unorm;
return true;
case kGray_8_as_Lum_GrPixelConfig:
return false;
case kRGBA_float_GrPixelConfig:
*format = MTLPixelFormatRGBA32Float;
return true;

View File

@ -214,7 +214,8 @@ void GrVkCaps::initShaderCaps(const VkPhysicalDeviceProperties& properties, uint
shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR();
shaderCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA();
} else {
if (kGray_8_GrPixelConfig == config) {
if (kGray_8_GrPixelConfig == config ||
kGray_8_as_Red_GrPixelConfig == config) {
shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRA();
} else if (kRGBA_4444_GrPixelConfig == config) {
// The vulkan spec does not require R4G4B4A4 to be supported for texturing so we

View File

@ -49,8 +49,11 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
case kAlpha_8_as_Alpha_GrPixelConfig:
return false;
case kGray_8_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
*format = VK_FORMAT_R8_UNORM;
return true;
case kGray_8_as_Lum_GrPixelConfig:
return false;
case kRGBA_float_GrPixelConfig:
*format = VK_FORMAT_R32G32B32A32_SFLOAT;
return true;

View File

@ -85,6 +85,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
kAlpha_8_as_Alpha_GrPixelConfig,
kAlpha_8_as_Red_GrPixelConfig,
kGray_8_GrPixelConfig,
kGray_8_as_Lum_GrPixelConfig,
kGray_8_as_Red_GrPixelConfig,
kRGB_565_GrPixelConfig,
kRGBA_4444_GrPixelConfig,
kRGBA_8888_GrPixelConfig,