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>
This commit is contained in:
parent
d8d984ecc9
commit
33d17cbb00
@ -343,7 +343,12 @@ enum GrPixelConfig {
|
||||
*/
|
||||
kRGBA_half_GrPixelConfig,
|
||||
|
||||
kLast_GrPixelConfig = kRGBA_half_GrPixelConfig
|
||||
kPrivateConfig1_GrPixelConfig,
|
||||
kPrivateConfig2_GrPixelConfig,
|
||||
kPrivateConfig3_GrPixelConfig,
|
||||
kPrivateConfig4_GrPixelConfig,
|
||||
|
||||
kLast_GrPixelConfig = kPrivateConfig4_GrPixelConfig
|
||||
};
|
||||
static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -800,6 +800,15 @@ 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_Alpha_GrPixelConfig = kPrivateConfig3_GrPixelConfig;
|
||||
static constexpr GrPixelConfig kAlpha_half_as_Red_GrPixelConfig = kPrivateConfig4_GrPixelConfig;
|
||||
|
||||
/**
|
||||
* Utility functions for GrPixelConfig
|
||||
*/
|
||||
@ -813,6 +822,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:
|
||||
@ -820,6 +831,8 @@ static inline bool GrPixelConfigIs8888Unorm(GrPixelConfig config) {
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
case kRG_float_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Alpha_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
return false;
|
||||
}
|
||||
@ -836,6 +849,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:
|
||||
@ -845,6 +860,8 @@ static inline bool GrPixelConfigIsSRGB(GrPixelConfig config) {
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
case kRG_float_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Alpha_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
return false;
|
||||
}
|
||||
@ -866,6 +883,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:
|
||||
@ -873,6 +892,8 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) {
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
case kRG_float_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Alpha_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
return kUnknown_GrPixelConfig;
|
||||
}
|
||||
@ -883,11 +904,15 @@ 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_Alpha_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
return 2;
|
||||
case kRGBA_8888_GrPixelConfig:
|
||||
case kBGRA_8888_GrPixelConfig:
|
||||
@ -915,8 +940,12 @@ 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_Alpha_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_8888_GrPixelConfig:
|
||||
case kBGRA_8888_GrPixelConfig:
|
||||
case kSRGBA_8888_GrPixelConfig:
|
||||
@ -934,7 +963,11 @@ 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_Alpha_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
return true;
|
||||
case kUnknown_GrPixelConfig:
|
||||
case kGray_8_GrPixelConfig:
|
||||
@ -959,10 +992,14 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
case kRG_float_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Alpha_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:
|
||||
@ -984,6 +1021,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:
|
||||
@ -994,6 +1033,8 @@ static inline bool GrPixelConfigIsUnorm(GrPixelConfig config) {
|
||||
return true;
|
||||
case kUnknown_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Alpha_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_8888_sint_GrPixelConfig:
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
case kRG_float_GrPixelConfig:
|
||||
@ -1009,5 +1050,4 @@ static inline GrPixelConfigIsClamped GrGetPixelConfigIsClamped(GrPixelConfig con
|
||||
: GrPixelConfigIsClamped::kYes;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -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,8 @@ 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_Alpha_GrPixelConfig: return "AlphaHalf_asAlpha";
|
||||
case kAlpha_half_as_Red_GrPixelConfig: return "AlphaHalf_asRed";
|
||||
case kRGBA_half_GrPixelConfig: return "RGBAHalf";
|
||||
}
|
||||
SK_ABORT("Invalid pixel config");
|
||||
|
@ -220,22 +220,24 @@ void GrShaderCaps::initSamplerPrecisionTable() {
|
||||
}
|
||||
|
||||
uint8_t* table = fSamplerPrecisions[visibility];
|
||||
table[kUnknown_GrPixelConfig] = lowp;
|
||||
table[kAlpha_8_GrPixelConfig] = lowp;
|
||||
table[kGray_8_GrPixelConfig] = lowp;
|
||||
table[kRGB_565_GrPixelConfig] = lowp;
|
||||
table[kRGBA_4444_GrPixelConfig] = lowp;
|
||||
table[kRGBA_8888_GrPixelConfig] = lowp;
|
||||
table[kBGRA_8888_GrPixelConfig] = lowp;
|
||||
table[kSRGBA_8888_GrPixelConfig] = lowp;
|
||||
table[kSBGRA_8888_GrPixelConfig] = lowp;
|
||||
table[kRGBA_8888_sint_GrPixelConfig] = lowp;
|
||||
table[kRGBA_float_GrPixelConfig] = kHigh_GrSLPrecision;
|
||||
table[kRG_float_GrPixelConfig] = kHigh_GrSLPrecision;
|
||||
table[kAlpha_half_GrPixelConfig] = mediump;
|
||||
table[kRGBA_half_GrPixelConfig] = mediump;
|
||||
|
||||
GR_STATIC_ASSERT(14 == kGrPixelConfigCnt);
|
||||
table[kUnknown_GrPixelConfig] = lowp;
|
||||
table[kAlpha_8_GrPixelConfig] = lowp;
|
||||
table[kAlpha_8_as_Alpha_GrPixelConfig] = lowp;
|
||||
table[kAlpha_8_as_Red_GrPixelConfig] = lowp;
|
||||
table[kGray_8_GrPixelConfig] = lowp;
|
||||
table[kRGB_565_GrPixelConfig] = lowp;
|
||||
table[kRGBA_4444_GrPixelConfig] = lowp;
|
||||
table[kRGBA_8888_GrPixelConfig] = lowp;
|
||||
table[kBGRA_8888_GrPixelConfig] = lowp;
|
||||
table[kSRGBA_8888_GrPixelConfig] = lowp;
|
||||
table[kSBGRA_8888_GrPixelConfig] = lowp;
|
||||
table[kRGBA_8888_sint_GrPixelConfig] = lowp;
|
||||
table[kRGBA_float_GrPixelConfig] = kHigh_GrSLPrecision;
|
||||
table[kRG_float_GrPixelConfig] = kHigh_GrSLPrecision;
|
||||
table[kAlpha_half_GrPixelConfig] = mediump;
|
||||
table[kAlpha_half_as_Alpha_GrPixelConfig] = mediump;
|
||||
table[kAlpha_half_as_Red_GrPixelConfig] = mediump;
|
||||
table[kRGBA_half_GrPixelConfig] = mediump;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -20,11 +20,15 @@ layout(key) in int rangeType;
|
||||
break;
|
||||
case kUnknown_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Alpha_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));
|
||||
|
@ -36,11 +36,15 @@ public:
|
||||
break;
|
||||
case kUnknown_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Alpha_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));
|
||||
|
@ -1947,33 +1947,46 @@ 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;
|
||||
}
|
||||
ConfigInfo& alphaInfo = fConfigTable[kAlpha_8_as_Alpha_GrPixelConfig];
|
||||
alphaInfo.fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
||||
alphaInfo.fFormatType = kNormalizedFixedPoint_FormatType;
|
||||
if (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 && kGL_GrGLStandard== standard) {
|
||||
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;
|
||||
alphaInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
|
||||
redInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
|
||||
}
|
||||
|
||||
if (this->textureRedSupport()) {
|
||||
redInfo.fFlags = ConfigInfo::kTextureable_Flag;
|
||||
if (texelBufferSupport) {
|
||||
redInfo.fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag;
|
||||
}
|
||||
redInfo.fFlags |= allRenderFlags;
|
||||
|
||||
fConfigTable[kAlpha_8_GrPixelConfig] = redInfo;
|
||||
} else {
|
||||
redInfo.fFlags = 0;
|
||||
|
||||
fConfigTable[kAlpha_8_GrPixelConfig] = alphaInfo;
|
||||
}
|
||||
|
||||
fConfigTable[kGray_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
||||
@ -2068,44 +2081,60 @@ 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;
|
||||
}
|
||||
GrGLenum alphaHalfExternalType;
|
||||
if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(3, 0)) {
|
||||
alphaHalfExternalType = GR_GL_HALF_FLOAT;
|
||||
} 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();
|
||||
alphaHalfExternalType = GR_GL_HALF_FLOAT_OES;
|
||||
}
|
||||
|
||||
if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(3, 0)) {
|
||||
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT;
|
||||
} else {
|
||||
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT_OES;
|
||||
}
|
||||
fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType;
|
||||
ConfigInfo& alphaHalf = fConfigTable[kAlpha_half_as_Alpha_GrPixelConfig];
|
||||
alphaHalf.fFormats.fExternalType = alphaHalfExternalType;
|
||||
alphaHalf.fFormatType = kFloat_FormatType;
|
||||
alphaHalf.fFormats.fBaseInternalFormat = GR_GL_ALPHA;
|
||||
alphaHalf.fFormats.fSizedInternalFormat = GR_GL_ALPHA16F;
|
||||
alphaHalf.fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_ALPHA;
|
||||
alphaHalf.fSwizzle = GrSwizzle::AAAA();
|
||||
|
||||
ConfigInfo& redHalf = fConfigTable[kAlpha_half_as_Red_GrPixelConfig];
|
||||
redHalf.fFormats.fExternalType = alphaHalfExternalType;
|
||||
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 (texStorageSupported) {
|
||||
fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
|
||||
alphaHalf.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
|
||||
redHalf.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.
|
||||
if (kGL_GrGLStandard == standard || version <= GR_GL_VER(3, 0)) {
|
||||
alphaHalf.fFlags = ConfigInfo::kTextureable_Flag;
|
||||
}
|
||||
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;
|
||||
if (kGL_GrGLStandard == standard) {
|
||||
alphaHalf.fFlags |= fpRenderFlags;
|
||||
}
|
||||
redHalf.fFlags |= fpRenderFlags;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->textureRedSupport()) {
|
||||
if (texelBufferSupport) {
|
||||
redHalf.fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag;
|
||||
}
|
||||
|
||||
fConfigTable[kAlpha_half_GrPixelConfig] = redHalf;
|
||||
} else {
|
||||
redHalf.fFlags = 0;
|
||||
|
||||
fConfigTable[kAlpha_half_GrPixelConfig] = alphaHalf;
|
||||
}
|
||||
|
||||
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
|
||||
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA16F;
|
||||
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||
@ -2157,8 +2186,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>
|
||||
|
@ -785,11 +785,15 @@ 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_Alpha_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
return 2;
|
||||
case kRGBA_8888_GrPixelConfig:
|
||||
|
@ -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,9 +65,12 @@ 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;
|
||||
case kAlpha_half_as_Alpha_GrPixelConfig:
|
||||
return false;
|
||||
}
|
||||
SK_ABORT("Unexpected config");
|
||||
return false;
|
||||
|
@ -208,7 +208,10 @@ 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 &&
|
||||
kAlpha_half_as_Alpha_GrPixelConfig != config) {
|
||||
shaderCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR();
|
||||
shaderCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA();
|
||||
} else {
|
||||
|
@ -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,9 +60,12 @@ 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;
|
||||
case kAlpha_half_as_Alpha_GrPixelConfig:
|
||||
return false;
|
||||
}
|
||||
SK_ABORT("Unexpected config");
|
||||
return false;
|
||||
|
@ -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,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
|
||||
kRGBA_float_GrPixelConfig,
|
||||
kRG_float_GrPixelConfig,
|
||||
kAlpha_half_GrPixelConfig,
|
||||
kAlpha_half_as_Alpha_GrPixelConfig,
|
||||
kAlpha_half_as_Red_GrPixelConfig,
|
||||
kRGBA_half_GrPixelConfig,
|
||||
};
|
||||
SkASSERT(kGrPixelConfigCnt == SK_ARRAY_COUNT(configs));
|
||||
|
Loading…
Reference in New Issue
Block a user