Revert "Revert "Revert "Revert "Add private grpixelconfigs for alpha_8 and alpha_half""""

This reverts commit 3b2f5b60ff.

Reason for revert: more attempts at a fixed version

Original change's description:
> Revert "Revert "Revert "Add private grpixelconfigs for alpha_8 and alpha_half"""
>
> This reverts commit b5fb7cf016.
>
> Reason for revert: breaking more devices
>
> Original change's description:
> > Revert "Revert "Add private grpixelconfigs for alpha_8 and alpha_half""
> >
> > This reverts commit 0fb6db4be6.
> >
> > Reason for revert: fixed bug
> >
> > Original change's description:
> > > Revert "Add private grpixelconfigs for alpha_8 and alpha_half"
> > >
> > > This reverts commit 33d17cbb00.
> > >
> > > Reason for revert: broke intel bots
> > >
> > > Original change's description:
> > > > Add private grpixelconfigs for alpha_8 and alpha_half
> > > >
> > > > Bug: skia:
> > > > Change-Id: I5191b6e045aea2a5af2b305b5972ad1e638a7ace
> > > > Reviewed-on: https://skia-review.googlesource.com/71763
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com
> > >
> > > Change-Id: I6fff9241f7878f1ec7fad2663df9922c9cd8f628
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:
> > > Reviewed-on: https://skia-review.googlesource.com/72180
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com
> >
> > Change-Id: Ie028961ecbf5934c53cb859e019e548935b3af79
> > Reviewed-on: https://skia-review.googlesource.com/72241
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com
>
> Change-Id: Ieaac3eca2fc4919699c7de61a3c33348e92a7da0
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/72660
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,bsalomon@google.com

Change-Id: Ifcf1b97c2a9493ce9a77a8aa0f4e5a8fb393def3
Reviewed-on: https://skia-review.googlesource.com/72802
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2017-11-17 13:23:40 -05:00 committed by Skia Commit-Bot
parent e5690313a6
commit 68ab18611a
13 changed files with 150 additions and 62 deletions

View File

@ -343,7 +343,11 @@ enum GrPixelConfig {
*/
kRGBA_half_GrPixelConfig,
kLast_GrPixelConfig = kRGBA_half_GrPixelConfig
kPrivateConfig1_GrPixelConfig,
kPrivateConfig2_GrPixelConfig,
kPrivateConfig3_GrPixelConfig,
kLast_GrPixelConfig = kPrivateConfig3_GrPixelConfig
};
static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;

View File

@ -9,6 +9,7 @@
#define GrMockOptions_DEFINED
#include "GrTypes.h"
#include "../private/GrTypesPriv.h"
struct GrMockTextureInfo {
int fID;
@ -25,6 +26,8 @@ struct GrMockOptions {
fConfigOptions[kRGBA_8888_GrPixelConfig].fRenderable[0] = true;
fConfigOptions[kRGBA_8888_GrPixelConfig].fTexturable = true;
fConfigOptions[kAlpha_8_GrPixelConfig].fTexturable = true;
fConfigOptions[kAlpha_8_as_Alpha_GrPixelConfig].fTexturable = true;
fConfigOptions[kAlpha_8_as_Red_GrPixelConfig].fTexturable = true;
fConfigOptions[kRGB_565_GrPixelConfig].fTexturable = true;
}

View File

@ -705,6 +705,14 @@ enum class GrMipMapsStatus {
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
*/
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;
/**
* Utility functions for GrPixelConfig
*/
@ -718,6 +726,8 @@ static inline bool GrPixelConfigIs8888Unorm(GrPixelConfig config) {
return true;
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
@ -725,6 +735,7 @@ static inline bool GrPixelConfigIs8888Unorm(GrPixelConfig config) {
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
return false;
}
@ -741,6 +752,8 @@ static inline bool GrPixelConfigIsSRGB(GrPixelConfig config) {
return true;
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
@ -750,6 +763,7 @@ static inline bool GrPixelConfigIsSRGB(GrPixelConfig config) {
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
return false;
}
@ -771,6 +785,8 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) {
return kSBGRA_8888_GrPixelConfig;
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
@ -778,6 +794,7 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) {
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
return kUnknown_GrPixelConfig;
}
@ -788,11 +805,14 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) {
static inline size_t GrBytesPerPixel(GrPixelConfig config) {
switch (config) {
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
return 1;
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
return 2;
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
@ -820,8 +840,11 @@ static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
case kRG_float_GrPixelConfig:
return true;
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
@ -839,7 +862,10 @@ static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
static inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) {
switch (config) {
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
return true;
case kUnknown_GrPixelConfig:
case kGray_8_GrPixelConfig:
@ -864,10 +890,13 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
return true;
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
@ -889,6 +918,8 @@ static inline bool GrPixelConfigIsSint(GrPixelConfig config) {
static inline bool GrPixelConfigIsUnorm(GrPixelConfig config) {
switch (config) {
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
@ -899,6 +930,7 @@ static inline bool GrPixelConfigIsUnorm(GrPixelConfig config) {
return true;
case kUnknown_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
@ -916,6 +948,8 @@ static inline GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) {
switch (config) {
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
@ -929,6 +963,7 @@ static inline GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) {
case kRG_float_GrPixelConfig:
return kHigh_GrSLPrecision;
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
return kMedium_GrSLPrecision;
}
@ -941,5 +976,4 @@ static inline GrPixelConfigIsClamped GrGetPixelConfigIsClamped(GrPixelConfig con
: GrPixelConfigIsClamped::kYes;
}
#endif

View File

@ -14,6 +14,8 @@ static const char* pixel_config_name(GrPixelConfig config) {
switch (config) {
case kUnknown_GrPixelConfig: return "Unknown";
case kAlpha_8_GrPixelConfig: return "Alpha8";
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 kRGB_565_GrPixelConfig: return "RGB565";
case kRGBA_4444_GrPixelConfig: return "RGBA444";
@ -25,6 +27,7 @@ static const char* pixel_config_name(GrPixelConfig config) {
case kRGBA_float_GrPixelConfig: return "RGBAFloat";
case kRG_float_GrPixelConfig: return "RGFloat";
case kAlpha_half_GrPixelConfig: return "AlphaHalf";
case kAlpha_half_as_Red_GrPixelConfig: return "AlphaHalf_asRed";
case kRGBA_half_GrPixelConfig: return "RGBAHalf";
}
SK_ABORT("Invalid pixel config");

View File

@ -368,7 +368,9 @@ GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info, const GrCaps& c
bool GrPixelConfigToColorType(GrPixelConfig config, SkColorType* ctOut) {
SkColorType ct;
switch (config) {
case kAlpha_8_GrPixelConfig:
case kAlpha_8_GrPixelConfig: // fall through
case kAlpha_8_as_Alpha_GrPixelConfig: // fall through
case kAlpha_8_as_Red_GrPixelConfig:
ct = kAlpha_8_SkColorType;
break;
case kGray_8_GrPixelConfig:

View File

@ -20,11 +20,14 @@ layout(key) in int rangeType;
break;
case kUnknown_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
return nullptr;
}
return std::unique_ptr<GrFragmentProcessor>(new GrDitherEffect(rangeType));

View File

@ -36,11 +36,14 @@ public:
break;
case kUnknown_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_8888_sint_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
return nullptr;
}
return std::unique_ptr<GrFragmentProcessor>(new GrDitherEffect(rangeType));

View File

@ -1853,33 +1853,53 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
}
fConfigTable[kRGBA_4444_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
if (this->textureRedSupport()) {
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED;
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R8;
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
GR_GL_RED;
fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
if (texelBufferSupport) {
fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag;
}
fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags;
} else {
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ALPHA;
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA8;
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
GR_GL_ALPHA;
fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
if (fAlpha8IsRenderable) {
fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags;
}
bool alpha8IsValidForGL = kGL_GrGLStandard == standard &&
(!fIsCoreProfile || version <= GR_GL_VER(3, 0));
ConfigInfo& alphaInfo = fConfigTable[kAlpha_8_as_Alpha_GrPixelConfig];
alphaInfo.fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
alphaInfo.fFormatType = kNormalizedFixedPoint_FormatType;
if (alpha8IsValidForGL || (kGL_GrGLStandard != standard && version < GR_GL_VER(3, 0))) {
alphaInfo.fFlags = ConfigInfo::kTextureable_Flag;
}
alphaInfo.fFormats.fBaseInternalFormat = GR_GL_ALPHA;
alphaInfo.fFormats.fSizedInternalFormat = GR_GL_ALPHA8;
alphaInfo.fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_ALPHA;
alphaInfo.fSwizzle = GrSwizzle::AAAA();
if (fAlpha8IsRenderable && alpha8IsValidForGL) {
alphaInfo.fFlags |= allRenderFlags;
}
ConfigInfo& redInfo = fConfigTable[kAlpha_8_as_Red_GrPixelConfig];
redInfo.fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
redInfo.fFormatType = kNormalizedFixedPoint_FormatType;
redInfo.fFormats.fBaseInternalFormat = GR_GL_RED;
redInfo.fFormats.fSizedInternalFormat = GR_GL_R8;
redInfo.fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_RED;
redInfo.fSwizzle = GrSwizzle::RRRR();
// ES2 Command Buffer does not allow TexStorage with R8_EXT (so Alpha_8 and Gray_8)
if (texStorageSupported && !isCommandBufferES2) {
fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
// Angle with es2->GL has a bug where it will hang trying to call TexSubImage on Alpha8
// formats on miplevels > 0. We already disable texturing on gles > 2.0 so just need to
// check that we are not going to OpenGL.
if (GrGLANGLEBackend::kOpenGL != ctxInfo.angleBackend()) {
alphaInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
redInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
if (this->textureRedSupport()) {
redInfo.fFlags |= ConfigInfo::kTextureable_Flag | allRenderFlags;
if (texelBufferSupport) {
redInfo.fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag;
}
fConfigTable[kAlpha_8_GrPixelConfig] = redInfo;
} else {
redInfo.fFlags = 0;
fConfigTable[kAlpha_8_GrPixelConfig] = alphaInfo;
}
fConfigTable[kGray_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
@ -1926,13 +1946,13 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
uint32_t fpRenderFlags = (kGL_GrGLStandard == standard) ? allRenderFlags : nonMSAARenderFlags;
if (kGL_GrGLStandard == standard) {
if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_texture_float")) {
if (version >= GR_GL_VER(3, 0)) {
hasFPTextures = true;
hasHalfFPTextures = true;
rgIsTexturable = true;
}
} else {
if (version >= GR_GL_VER(3, 1)) {
if (version >= GR_GL_VER(3, 0)) {
hasFPTextures = true;
hasHalfFPTextures = true;
rgIsTexturable = true;
@ -1974,43 +1994,37 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
fConfigTable[fpconfig].fSwizzle = GrSwizzle::RGBA();
}
if (this->textureRedSupport()) {
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED;
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F;
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage]
= GR_GL_RED;
fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
if (texelBufferSupport) {
fConfigTable[kAlpha_half_GrPixelConfig].fFlags |=
ConfigInfo::kCanUseWithTexelBuffer_Flag;
}
} else {
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ALPHA;
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F;
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage]
= GR_GL_ALPHA;
fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
}
GrGLenum redHalfExternalType;
if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(3, 0)) {
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT;
redHalfExternalType = GR_GL_HALF_FLOAT;
} else {
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT_OES;
redHalfExternalType = GR_GL_HALF_FLOAT_OES;
}
fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType;
if (texStorageSupported) {
fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
if (hasHalfFPTextures) {
fConfigTable[kAlpha_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
// ES requires either 3.2 or the combination of EXT_color_buffer_half_float and support for
// GL_RED internal format.
ConfigInfo& redHalf = fConfigTable[kAlpha_half_as_Red_GrPixelConfig];
redHalf.fFormats.fExternalType = redHalfExternalType;
redHalf.fFormatType = kFloat_FormatType;
redHalf.fFormats.fBaseInternalFormat = GR_GL_RED;
redHalf.fFormats.fSizedInternalFormat = GR_GL_R16F;
redHalf.fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_RED;
redHalf.fSwizzle = GrSwizzle::RRRR();
if (this->textureRedSupport() && hasHalfFPTextures) {
redHalf.fFlags = ConfigInfo::kTextureable_Flag;
if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3, 2) ||
(this->textureRedSupport() &&
ctxInfo.hasExtension("GL_EXT_color_buffer_half_float"))) {
fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= fpRenderFlags;
redHalf.fFlags |= fpRenderFlags;
}
if (texStorageSupported) {
redHalf.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
if (texelBufferSupport) {
redHalf.fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag;
}
}
fConfigTable[kAlpha_half_GrPixelConfig] = redHalf;
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA16F;
@ -2063,8 +2077,12 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
// kAlpha_8_GrPixelConfig. Alpha8 is not a valid signed internal format so we must use the base
// internal format for that config when doing TexImage calls.
if(kGalliumLLVM_GrGLRenderer == ctxInfo.renderer()) {
SkASSERT(fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat ==
fConfigTable[kAlpha_8_as_Alpha_GrPixelConfig].fFormats.fBaseInternalFormat);
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fInternalFormatTexImage =
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat;
fConfigTable[kAlpha_8_as_Alpha_GrPixelConfig].fFormats.fInternalFormatTexImage =
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>

View File

@ -780,11 +780,14 @@ bool GrGLGpu::onWritePixels(GrSurface* surface, GrSurfaceOrigin origin,
static inline GrGLint config_alignment(GrPixelConfig config) {
switch (config) {
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
case kGray_8_GrPixelConfig:
return 1;
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
return 2;
case kRGBA_8888_GrPixelConfig:

View File

@ -7,6 +7,8 @@
#include "GrMtlUtil.h"
#include "GrTypesPriv.h"
bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
MTLPixelFormat dontCare;
if (!format) {
@ -45,9 +47,12 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
#else
return false;
#endif
case kAlpha_8_GrPixelConfig:
case kAlpha_8_GrPixelConfig: // fall through
case kAlpha_8_as_Red_GrPixelConfig:
*format = MTLPixelFormatR8Unorm;
return true;
case kAlpha_8_as_Alpha_GrPixelConfig:
return false;
case kGray_8_GrPixelConfig:
*format = MTLPixelFormatR8Unorm;
return true;
@ -60,7 +65,8 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
case kRGBA_half_GrPixelConfig:
*format = MTLPixelFormatRGBA16Float;
return true;
case kAlpha_half_GrPixelConfig:
case kAlpha_half_GrPixelConfig: // fall through
case kAlpha_half_as_Red_GrPixelConfig:
*format = MTLPixelFormatR16Float;
return true;
}

View File

@ -208,7 +208,9 @@ void GrVkCaps::initShaderCaps(const VkPhysicalDeviceProperties& properties, uint
// fConfigOutputSwizzle will default to RGBA so we only need to set it for alpha only config.
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
GrPixelConfig config = static_cast<GrPixelConfig>(i);
if (GrPixelConfigIsAlphaOnly(config)) {
// Vulkan doesn't support a single channel format stored in alpha.
if (GrPixelConfigIsAlphaOnly(config) &&
kAlpha_8_as_Alpha_GrPixelConfig != config) {
shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR();
shaderCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA();
} else {

View File

@ -42,9 +42,12 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
// store the data is if it was B4G4R4A4 and swizzle in shaders
*format = VK_FORMAT_B4G4R4A4_UNORM_PACK16;
return true;
case kAlpha_8_GrPixelConfig:
case kAlpha_8_GrPixelConfig: // fall through
case kAlpha_8_as_Red_GrPixelConfig:
*format = VK_FORMAT_R8_UNORM;
return true;
case kAlpha_8_as_Alpha_GrPixelConfig:
return false;
case kGray_8_GrPixelConfig:
*format = VK_FORMAT_R8_UNORM;
return true;
@ -57,7 +60,8 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
case kRGBA_half_GrPixelConfig:
*format = VK_FORMAT_R16G16B16A16_SFLOAT;
return true;
case kAlpha_half_GrPixelConfig:
case kAlpha_half_GrPixelConfig: // fall through
case kAlpha_half_as_Red_GrPixelConfig:
*format = VK_FORMAT_R16_SFLOAT;
return true;
}

View File

@ -82,6 +82,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
GrPixelConfig configs[] = {
kUnknown_GrPixelConfig,
kAlpha_8_GrPixelConfig,
kAlpha_8_as_Alpha_GrPixelConfig,
kAlpha_8_as_Red_GrPixelConfig,
kGray_8_GrPixelConfig,
kRGB_565_GrPixelConfig,
kRGBA_4444_GrPixelConfig,
@ -93,6 +95,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
kRGBA_float_GrPixelConfig,
kRG_float_GrPixelConfig,
kAlpha_half_GrPixelConfig,
kAlpha_half_as_Red_GrPixelConfig,
kRGBA_half_GrPixelConfig,
};
SkASSERT(kGrPixelConfigCnt == SK_ARRAY_COUNT(configs));