Add Ganesh support for RGBA_16161616 and RG_half (take 2)

TBR=egdaniel@google.com
Bug: skia:9171
Change-Id: I862c87ba4bd55381b347333cf9ca23cf5389dff6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/220816
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-06-18 08:00:42 -04:00 committed by Skia Commit-Bot
parent a224fc1105
commit 66a46033a6
22 changed files with 307 additions and 76 deletions

View File

@ -59,12 +59,14 @@ enum GrPixelConfig {
kRGBA_half_GrPixelConfig,
kRGBA_half_Clamped_GrPixelConfig,
kRGB_ETC1_GrPixelConfig,
// Experimental (for P016 and P010)
kR_16_GrPixelConfig,
kRG_1616_GrPixelConfig,
kLast_GrPixelConfig = kRG_1616_GrPixelConfig
// Experimental (for Y416 and mutant P016/P010)
kRGBA_16161616_GrPixelConfig,
kRG_half_GrPixelConfig,
kLast_GrPixelConfig = kRG_half_GrPixelConfig
};
static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;
@ -689,10 +691,12 @@ enum GrVertexAttribType {
kInt_GrVertexAttribType,
kUint_GrVertexAttribType,
// Experimental (for P016 and P010)
kUShort_norm_GrVertexAttribType,
kLast_GrVertexAttribType = kUShort_norm_GrVertexAttribType
// Experimental (for Y416)
kUShort4_norm_GrVertexAttribType, // vector of 4 unsigned shorts. 0 -> 0.0f, 65535 -> 1.0f.
kLast_GrVertexAttribType = kUShort4_norm_GrVertexAttribType
};
static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
@ -898,9 +902,11 @@ static inline GrSRGBEncoded GrPixelConfigIsSRGBEncoded(GrPixelConfig config) {
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
case kRGB_ETC1_GrPixelConfig:
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
case kRG_1616_GrPixelConfig:
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
case kRG_half_GrPixelConfig:
return GrSRGBEncoded::kNo;
}
SK_ABORT("Invalid pixel config");
@ -925,6 +931,7 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
case kRG_88_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kR_16_GrPixelConfig:
return 2;
case kRGBA_8888_GrPixelConfig:
case kRGB_888_GrPixelConfig: // Assuming GPUs store this 4-byte aligned.
@ -933,6 +940,7 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRG_1616_GrPixelConfig:
return 4;
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
@ -945,10 +953,10 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
case kRGB_ETC1_GrPixelConfig:
return 0;
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
return 2;
case kRG_1616_GrPixelConfig:
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
return 8;
case kRG_half_GrPixelConfig:
return 4;
}
SK_ABORT("Invalid pixel config");
@ -966,9 +974,9 @@ static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
case kGray_8_as_Red_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kRGB_ETC1_GrPixelConfig:
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
case kRG_1616_GrPixelConfig:
case kRG_half_GrPixelConfig: // Experimental (for mutant P016/P010)
return true;
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
@ -984,6 +992,7 @@ static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRGBA_16161616_GrPixelConfig: // Experimental (for Y416)
case kUnknown_GrPixelConfig:
return false;
}
@ -1018,9 +1027,11 @@ static inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) {
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
case kRGB_ETC1_GrPixelConfig:
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
case kRG_1616_GrPixelConfig:
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
case kRG_half_GrPixelConfig:
return false;
}
SK_ABORT("Invalid pixel config.");
@ -1047,9 +1058,9 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGB_ETC1_GrPixelConfig:
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
case kRG_1616_GrPixelConfig:
case kRGBA_16161616_GrPixelConfig: // Experimental (for Y416)
return false;
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
@ -1057,6 +1068,7 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
case kRG_half_GrPixelConfig: // Experimental (for mutant P016/P010)
return true;
}
SK_ABORT("Invalid pixel config.");
@ -1152,9 +1164,11 @@ static inline GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) {
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
case kRG_1616_GrPixelConfig:
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
case kRG_half_GrPixelConfig:
return kMedium_GrSLPrecision;
}
SK_ABORT("Unexpected type");
@ -1184,11 +1198,14 @@ enum class GrColorType {
kRGBA_F16_Clamped,
kRG_F32,
kRGBA_F32,
kRGB_ETC1, // This type doesn't appear in SkColorType at all.
kRGB_ETC1, // Not in SkColorType
// Experimental (for P016 and P010)
kR_16, // Not in SkColorType
kRG_1616, // Not in SkColorType
kR_16, // Not in SkColorType
kRG_1616, // Not in SkColorType
// Experimental (for Y416 and mutant P016/P010)
kRGBA_16161616, // Not in SkColorType
kRG_half, // Not in SkColorType
};
static inline SkColorType GrColorTypeToSkColorType(GrColorType ct) {
@ -1209,9 +1226,11 @@ static inline SkColorType GrColorTypeToSkColorType(GrColorType ct) {
case GrColorType::kRG_F32: return kUnknown_SkColorType;
case GrColorType::kRGBA_F32: return kRGBA_F32_SkColorType;
case GrColorType::kRGB_ETC1: return kUnknown_SkColorType;
// Experimental (for P016 and P010)
case GrColorType::kR_16: return kUnknown_SkColorType;
case GrColorType::kRG_1616: return kUnknown_SkColorType;
// Experimental (for Y416 and mutant P016/P010)
case GrColorType::kRGBA_16161616: return kUnknown_SkColorType;
case GrColorType::kRG_half: return kUnknown_SkColorType;
}
SK_ABORT("Invalid GrColorType");
return kUnknown_SkColorType;
@ -1257,10 +1276,13 @@ static inline uint32_t GrColorTypeComponentFlags(GrColorType ct) {
kGreen_SkColorTypeComponentFlag;
case GrColorType::kRGBA_F32: return kRGBA_SkColorTypeComponentFlags;
case GrColorType::kRGB_ETC1: return kRGB_SkColorTypeComponentFlags;
// Experimental (for P016 and P010)
case GrColorType::kR_16: return kRed_SkColorTypeComponentFlag;
case GrColorType::kRG_1616: return kRed_SkColorTypeComponentFlag |
kGreen_SkColorTypeComponentFlag;
// Experimental (for Y416 and mutant P016/P010)
case GrColorType::kRGBA_16161616: return kRGBA_SkColorTypeComponentFlags;
case GrColorType::kRG_half: return kRed_SkColorTypeComponentFlag |
kGreen_SkColorTypeComponentFlag;
}
SK_ABORT("Invalid GrColorType");
return kUnknown_SkColorType;
@ -1292,9 +1314,11 @@ static inline int GrColorTypeBytesPerPixel(GrColorType ct) {
case GrColorType::kRGBA_F16_Clamped: return 8;
case GrColorType::kRG_F32: return 8;
case GrColorType::kRGBA_F32: return 16;
// Experimental (for P016 and P010)
case GrColorType::kR_16: return 2;
case GrColorType::kRG_1616: return 4;
// Experimental (for Y416 and mutant P016/P010)
case GrColorType::kRGBA_16161616: return 8;
case GrColorType::kRG_half: return 4;
}
SK_ABORT("Invalid GrColorType");
return 0;
@ -1375,7 +1399,6 @@ static inline GrColorType GrPixelConfigToColorTypeAndEncoding(GrPixelConfig conf
case kGray_8_as_Red_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kNo;
return GrColorType::kGray_8;
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kNo;
return GrColorType::kR_16;
@ -1383,6 +1406,13 @@ static inline GrColorType GrPixelConfigToColorTypeAndEncoding(GrPixelConfig conf
*srgbEncoded = GrSRGBEncoded::kNo;
return GrColorType::kRG_1616;
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kNo;
return GrColorType::kRGBA_16161616;
case kRG_half_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kNo;
return GrColorType::kRG_half;
}
SK_ABORT("Invalid GrPixelConfig");
return GrColorType::kUnknown;
@ -1457,13 +1487,20 @@ static inline GrPixelConfig GrColorTypeToPixelConfig(GrColorType config,
return (GrSRGBEncoded::kYes == srgbEncoded) ? kUnknown_GrPixelConfig
: kRGB_ETC1_GrPixelConfig;
// Experimental (for P016 and P010)
case GrColorType::kR_16:
return (GrSRGBEncoded::kYes == srgbEncoded) ? kUnknown_GrPixelConfig
: kR_16_GrPixelConfig;
case GrColorType::kRG_1616:
return (GrSRGBEncoded::kYes == srgbEncoded) ? kUnknown_GrPixelConfig
: kRG_1616_GrPixelConfig;
// Experimental (for Y416 and mutant P016/P010)
case GrColorType::kRGBA_16161616:
return (GrSRGBEncoded::kYes == srgbEncoded) ? kUnknown_GrPixelConfig
: kRGBA_16161616_GrPixelConfig;
case GrColorType::kRG_half:
return (GrSRGBEncoded::kYes == srgbEncoded) ? kUnknown_GrPixelConfig
: kRG_half_GrPixelConfig;
}
SK_ABORT("Invalid GrColorType");
return kUnknown_GrPixelConfig;

View File

@ -153,9 +153,11 @@ static const char* pixel_config_name(GrPixelConfig config) {
case kRGBA_half_GrPixelConfig: return "RGBAHalf";
case kRGBA_half_Clamped_GrPixelConfig: return "RGBAHalfClamped";
case kRGB_ETC1_GrPixelConfig: return "RGBETC1";
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig: return "R16";
case kRG_1616_GrPixelConfig: return "RG1616";
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig: return "RGBA16161616";
case kRG_half_GrPixelConfig: return "RGHalf";
}
SK_ABORT("Invalid pixel config");
return "<invalid>";

View File

@ -262,7 +262,6 @@ static bool fill_buffer_with_color(GrPixelConfig config, int width, int height,
sk_memset64((uint64_t *) dest, rgbaHalf, width * height);
break;
}
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig: {
uint16_t r16 = SkScalarRoundToInt(colorf.fR * 65535.0f);
sk_memset16((uint16_t*) dest, r16, width * height);
@ -277,6 +276,26 @@ static bool fill_buffer_with_color(GrPixelConfig config, int width, int height,
sk_memset32((uint32_t*) dest, rg1616, width * height);
break;
}
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig: {
uint64_t r16 = SkScalarRoundToInt(colorf.fR * 65535.0f);
uint64_t g16 = SkScalarRoundToInt(colorf.fG * 65535.0f);
uint64_t b16 = SkScalarRoundToInt(colorf.fB * 65535.0f);
uint64_t a16 = SkScalarRoundToInt(colorf.fA * 65535.0f);
uint64_t rgba16161616 = (a16 << 48) | (b16 << 32) | (g16 << 16) | r16;
sk_memset64((uint64_t*) dest, rgba16161616, width * height);
break;
}
case kRG_half_GrPixelConfig: {
uint32_t rHalf = SkFloatToHalf(colorf.fR);
uint32_t gHalf = SkFloatToHalf(colorf.fG);
uint32_t rgHalf = (rHalf << 16) | gHalf;
sk_memset32((uint32_t *) dest, rgHalf, width * height);
break;
}
default:
return false;
break;

View File

@ -353,9 +353,11 @@ static constexpr inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
return sizeof(int32_t);
case kUint_GrVertexAttribType:
return sizeof(uint32_t);
// Experimental (for P016 and P010)
case kUShort_norm_GrVertexAttribType:
return sizeof(uint16_t);
// Experimental (for Y416)
case kUShort4_norm_GrVertexAttribType:
return 4 * sizeof(uint16_t);
}
// GCC fails because SK_ABORT evaluates to non constexpr. clang and cl.exe think this is
// unreachable and don't complain.

View File

@ -72,9 +72,11 @@ static bool valid_premul_color_type(GrColorType ct) {
case GrColorType::kRG_F32: return false;
case GrColorType::kRGBA_F32: return true;
case GrColorType::kRGB_ETC1: return false;
// Experimental (for P016 and P010)
case GrColorType::kR_16: return false;
case GrColorType::kRG_1616: return false;
// Experimental (for Y416 and mutant P016/P010)
case GrColorType::kRGBA_16161616: return false;
case GrColorType::kRG_half: return false;
}
SK_ABORT("Invalid GrColorType");
return false;
@ -108,9 +110,11 @@ static bool valid_premul_config(GrPixelConfig config) {
case kAlpha_half_as_Red_GrPixelConfig: return false;
case kGray_8_as_Lum_GrPixelConfig: return false;
case kGray_8_as_Red_GrPixelConfig: return false;
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig: return false;
case kRG_1616_GrPixelConfig: return false;
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig: return false;
case kRG_half_GrPixelConfig: return false;
}
SK_ABORT("Invalid GrPixelConfig");
return false;

View File

@ -296,9 +296,11 @@ static inline int32_t dither_range_type_for_config(GrPixelConfig dstConfig) {
case kRGB_888X_GrPixelConfig:
case kRG_88_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
case kRG_1616_GrPixelConfig:
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
case kRG_half_GrPixelConfig:
return 0;
case kRGB_565_GrPixelConfig:
return 1;

View File

@ -1977,6 +1977,7 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
// solve many precision issues and no clients actually want this yet.
// hasFP32RenderTargets = true;
halfFPRenderTargetSupport = HalfFPRenderTargetSupport::kAll;
rgIsTexturable = true;
} else if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) {
// This extension only enables half float support rendering for RGBA.
halfFPRenderTargetSupport = HalfFPRenderTargetSupport::kRGBAOnly;
@ -2119,7 +2120,7 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
} // No WebGL support
shaderCaps->fConfigTextureSwizzle[kRGB_ETC1_GrPixelConfig] = GrSwizzle::RGBA();
// Experimental (for P016 and P010)
// 16 bit formats
{
// For desktop:
// GL 3.0 requires support for R16 & RG16
@ -2138,6 +2139,21 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
}
} // No WebGL support
// For desktop:
// GL 3.0 requires support for RGBA16
// For ES:
// GL_EXT_texture_norm16 adds support but it requires ES 3.1
bool rgba16161616Supported = false;
if (GR_IS_GR_GL(standard)) {
if (version >= GR_GL_VER(3, 0)) {
rgba16161616Supported = true;
}
} else if (GR_IS_GR_GL_ES(standard)) {
if (version >= GR_GL_VER(3, 1) && ctxInfo.hasExtension("GL_EXT_texture_norm16")) {
rgba16161616Supported = true;
}
} // No WebGL support
{
ConfigInfo& r16Info = fConfigTable[kR_16_GrPixelConfig];
@ -2147,7 +2163,7 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
r16Info.fFormats.fExternalType = GR_GL_UNSIGNED_SHORT;
r16Info.fFormatType = kNormalizedFixedPoint_FormatType;
if (r16AndRG1616Supported) {
r16Info.fFlags = ConfigInfo::kTextureable_Flag;
r16Info.fFlags = ConfigInfo::kTextureable_Flag | allRenderFlags;
}
// We should only ever be sampling the R channel of this format so don't bother
// with a fancy swizzle.
@ -2163,14 +2179,53 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
rg1616Info.fFormats.fExternalType = GR_GL_UNSIGNED_SHORT;
rg1616Info.fFormatType = kNormalizedFixedPoint_FormatType;
if (r16AndRG1616Supported) {
rg1616Info.fFlags = ConfigInfo::kTextureable_Flag;
rg1616Info.fFlags = ConfigInfo::kTextureable_Flag | allRenderFlags;
}
// We should only ever be sampling the R and G channels of this format so don't bother
// with a fancy swizzle.
shaderCaps->fConfigTextureSwizzle[kRG_1616_GrPixelConfig] = GrSwizzle::RGBA();
}
// Experimental (for Y416)
{
ConfigInfo& rgba16161616Info = fConfigTable[kRGBA_16161616_GrPixelConfig];
rgba16161616Info.fFormats.fBaseInternalFormat = GR_GL_RGBA;
rgba16161616Info.fFormats.fSizedInternalFormat = GR_GL_RGBA16;
rgba16161616Info.fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] = GR_GL_RGBA;
rgba16161616Info.fFormats.fExternalType = GR_GL_UNSIGNED_SHORT;
rgba16161616Info.fFormatType = kNormalizedFixedPoint_FormatType;
if (rgba16161616Supported) {
rgba16161616Info.fFlags = ConfigInfo::kTextureable_Flag | allRenderFlags;
}
shaderCaps->fConfigTextureSwizzle[kRGBA_16161616_GrPixelConfig] = GrSwizzle::RGBA();
}
}
// Experimental (for Y416 and mutant P016/P010)
{
ConfigInfo& rgHalf = fConfigTable[kRG_half_GrPixelConfig];
rgHalf.fFormats.fBaseInternalFormat = GR_GL_RG;
rgHalf.fFormats.fSizedInternalFormat = GR_GL_RG16F;
rgHalf.fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] = GR_GL_RG;
if (GR_IS_GR_GL(standard) || (GR_IS_GR_GL_ES(standard) && version >= GR_GL_VER(3, 0))) {
rgHalf.fFormats.fExternalType = GR_GL_HALF_FLOAT;
} else {
rgHalf.fFormats.fExternalType = GR_GL_HALF_FLOAT_OES;
}
rgHalf.fFormatType = kFloat_FormatType;
if (hasFP16Textures) {
rgHalf.fFlags = rgIsTexturable ? ConfigInfo::kTextureable_Flag : 0;
if (HalfFPRenderTargetSupport::kAll == halfFPRenderTargetSupport) {
rgHalf.fFlags |= fpRenderFlags;
}
}
// We should only ever be sampling the R and G channels of this format so don't bother
// with a fancy swizzle.
shaderCaps->fConfigTextureSwizzle[kRG_half_GrPixelConfig] = GrSwizzle::RGBA();
}
// Bulk populate the texture internal/external formats here and then deal with exceptions below.
@ -3229,13 +3284,19 @@ static GrPixelConfig get_yuva_config(GrGLenum format) {
case GR_GL_R16F:
config = kAlpha_half_as_Red_GrPixelConfig;
break;
// Experimental (for P016 and P010)
case GR_GL_R16:
config = kR_16_GrPixelConfig;
break;
case GR_GL_RG16:
config = kRG_1616_GrPixelConfig;
break;
// Experimental (for Y416 and mutant P016/P010)
case GR_GL_RGBA16:
config = kRGBA_16161616_GrPixelConfig;
break;
case GR_GL_RG16F:
config = kRG_half_GrPixelConfig;
break;
}
return config;
@ -3293,11 +3354,16 @@ static bool format_color_type_valid_pair(GrGLenum format, GrColorType colorType)
return GR_GL_RGBA32F == format;
case GrColorType::kRGB_ETC1:
return GR_GL_COMPRESSED_RGB8_ETC2 == format || GR_GL_COMPRESSED_ETC1_RGB8 == format;
// Experimental (for P016 and P010)
case GrColorType::kR_16:
return GR_GL_R16 == format;
case GrColorType::kRG_1616:
return GR_GL_RG16 == format;
// Experimental (for Y416 and mutant P016/P010)
case GrColorType::kRGBA_16161616:
return GR_GL_RGBA16 == format;
case GrColorType::kRG_half:
return GR_GL_RG16F == format;
}
SK_ABORT("Unknown color type");
return false;

View File

@ -480,6 +480,7 @@
#define GR_GL_RG16 0x822C
#define GR_GL_R16F 0x822D
#define GR_GL_R32F 0x822E
#define GR_GL_RG16F 0x822F
/* RG sized integer formats */
#define GR_GL_RG8I 0x8237
@ -512,6 +513,7 @@
#define GR_GL_RGBA16F 0x881A
#define GR_GL_RGBA32F 0x8814
#define GR_GL_RG32F 0x8230
#define GR_GL_RGBA16 0x805B
/* RGBA integer sized formats */
#define GR_GL_RGBA8I 0x8D8E

View File

@ -873,6 +873,7 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
case kR_16_GrPixelConfig:
return 2;
case kRGBA_8888_GrPixelConfig:
case kRGB_888_GrPixelConfig: // We're really talking about GrColorType::kRGB_888x here.
@ -883,15 +884,16 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
case kRGBA_1010102_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kRG_1616_GrPixelConfig:
return 4;
case kRGB_ETC1_GrPixelConfig:
case kUnknown_GrPixelConfig:
return 0;
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
return 2;
case kRG_1616_GrPixelConfig:
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
return 8;
case kRG_half_GrPixelConfig:
return 4;
}
SK_ABORT("Invalid pixel config");
@ -3988,14 +3990,20 @@ static bool gl_format_to_pixel_config(GrGLenum format, GrPixelConfig* config) {
case GR_GL_R16F:
*config = kAlpha_half_GrPixelConfig;
return true;
// Experimental (for P016 and P010)
case GR_GL_R16:
*config = kR_16_GrPixelConfig;
return true;
case GR_GL_RG16:
*config = kRG_1616_GrPixelConfig;
return true;
// Experimental (for Y416 and mutant P016/P010)
case GR_GL_RGBA16:
*config = kRGBA_16161616_GrPixelConfig;
return true;
case GR_GL_RG16F:
*config = kRG_half_GrPixelConfig;
return true;
}
SK_ABORT("Unexpected config");

View File

@ -612,6 +612,7 @@ size_t GrGLBytesPerFormat(GrGLenum glFormat) {
case GR_GL_RGBA4:
case GR_GL_RG8:
case GR_GL_R16F:
case GR_GL_R16:
return 2;
case GR_GL_RGB8:
@ -621,6 +622,7 @@ size_t GrGLBytesPerFormat(GrGLenum glFormat) {
case GR_GL_SRGB8_ALPHA8:
case GR_GL_BGRA8:
case GR_GL_RGB10_A2:
case GR_GL_RG16:
return 4;
case GR_GL_RGBA16F:
@ -634,11 +636,11 @@ size_t GrGLBytesPerFormat(GrGLenum glFormat) {
case GR_GL_COMPRESSED_ETC1_RGB8:
return 0;
// Experimental (for P016 and P010)
case GR_GL_R16:
return 2;
case GR_GL_RG16:
// Experimental (for Y416 and mutant P016/P010)
case GR_GL_RG16F:
return 4;
case GR_GL_RGBA16:
return 8;
}
SK_ABORT("Invalid GL format");

View File

@ -74,9 +74,10 @@ static AttribLayout attrib_layout(GrVertexAttribType type) {
return {false, 1, GR_GL_INT};
case kUint_GrVertexAttribType:
return {false, 1, GR_GL_UNSIGNED_INT};
// Experimental (for P016 and P010)
case kUShort_norm_GrVertexAttribType:
return {true, 1, GR_GL_UNSIGNED_SHORT};
case kUShort4_norm_GrVertexAttribType:
return {true, 4, GR_GL_UNSIGNED_SHORT};
}
SK_ABORT("Unknown vertex attrib type");
return {false, 0, 0};

View File

@ -411,7 +411,6 @@ void GrMtlCaps::initConfigTable() {
info = &fConfigTable[kRGBA_half_Clamped_GrPixelConfig];
info->fFlags = ConfigInfo::kAllFlags;
// Experimental (for P016 and P010)
// R_16 uses R16Unorm
info = &fConfigTable[kR_16_GrPixelConfig];
if (this->isMac()) {
@ -427,6 +426,20 @@ void GrMtlCaps::initConfigTable() {
} else {
info->fFlags = ConfigInfo::kTextureable_Flag | ConfigInfo::kRenderable_Flag;
}
// Experimental (for Y416 and mutant P016/P010)
// RGBA_16161616 uses RGBA16Unorm
info = &fConfigTable[kRGBA_16161616_GrPixelConfig];
if (this->isMac()) {
info->fFlags = ConfigInfo::kAllFlags;
} else {
info->fFlags = ConfigInfo::kTextureable_Flag | ConfigInfo::kRenderable_Flag;
}
// RG_half uses RG16Float
info = &fConfigTable[kRG_half_GrPixelConfig];
info->fFlags = ConfigInfo::kAllFlags;
}
void GrMtlCaps::initStencilFormat(id<MTLDevice> physDev) {
@ -562,13 +575,19 @@ static GrPixelConfig get_yuva_config(GrMTLPixelFormat grFormat) {
case MTLPixelFormatRGB10A2Unorm:
return kRGBA_1010102_GrPixelConfig;
break;
// Experimental (for P016 and P010)
case MTLPixelFormatR16Unorm:
return kR_16_GrPixelConfig;
break;
case MTLPixelFormatRG16Unorm:
return kRG_1616_GrPixelConfig;
break;
// Experimental (for Y416 and mutant P016/P010)
case MTLPixelFormatRGBA16Unorm:
return kRGBA_16161616_GrPixelConfig;
break;
case MTLPixelFormatRG16Float:
return kRG_half_GrPixelConfig;
break;
default:
return kUnknown_GrPixelConfig;
break;
@ -643,11 +662,15 @@ static bool format_color_type_valid_pair(MTLPixelFormat format, GrColorType colo
#else
return MTLPixelFormatETC2_RGB8 == format;
#endif
// Experimental (for P016 and P010)
case GrColorType::kR_16:
return MTLPixelFormatR16Unorm == format;
case GrColorType::kRG_1616:
return MTLPixelFormatRG16Unorm == format;
// Experimental (for Y416 and mutant P016/P010)
case GrColorType::kRGBA_16161616:
return MTLPixelFormatRGBA16Unorm == format;
case GrColorType::kRG_half:
return MTLPixelFormatRG16Float == format;
}
SK_ABORT("Unknown color type");
return false;

View File

@ -753,13 +753,20 @@ static bool mtl_format_to_pixel_config(MTLPixelFormat format, GrPixelConfig* con
*config = kRGB_ETC1_GrPixelConfig;
return true;
#endif
// Experimental (for P016 and P010)
case MTLPixelFormatR16Unorm:
*config = kR_16_GrPixelConfig;
return true;
case MTLPixelFormatRG16Unorm:
*config = kRG_1616_GrPixelConfig;
return true;
// Experimental (for Y416 and mutant P016/P010)
case MTLPixelFormatRGBA16Unorm:
*config = kRGBA_16161616_GrPixelConfig;
return true;
case MTLPixelFormatRG16Float:
*config = kRG_half_GrPixelConfig;
return true;
default:
return false;
}

View File

@ -141,9 +141,11 @@ static inline MTLVertexFormat attribute_type_to_mtlformat(GrVertexAttribType typ
return MTLVertexFormatInt;
case kUint_GrVertexAttribType:
return MTLVertexFormatUInt;
// Experimental (for P016 and P010)
case kUShort_norm_GrVertexAttribType:
return MTLVertexFormatUShortNormalized;
// Experimental (for Y416)
case kUShort4_norm_GrVertexAttribType:
return MTLVertexFormatUShort4Normalized;
}
SK_ABORT("Unknown vertex attribute type");
return MTLVertexFormatInvalid;

View File

@ -110,6 +110,14 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
case kRG_1616_GrPixelConfig:
*format = MTLPixelFormatRG16Unorm;
return true;
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
*format = MTLPixelFormatRGBA16Unorm;
return true;
case kRG_half_GrPixelConfig:
*format = MTLPixelFormatRG16Float;
return true;
}
SK_ABORT("Unexpected config");
return false;

View File

@ -85,6 +85,7 @@ static int get_compatible_format_class(GrPixelConfig config) {
case kRG_88_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kR_16_GrPixelConfig:
return 2;
case kRGB_888_GrPixelConfig:
return 3;
@ -94,6 +95,7 @@ static int get_compatible_format_class(GrPixelConfig config) {
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRG_1616_GrPixelConfig:
return 4;
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
@ -108,10 +110,11 @@ static int get_compatible_format_class(GrPixelConfig config) {
case kGray_8_as_Lum_GrPixelConfig:
SK_ABORT("Unsupported Vulkan pixel config");
return 0;
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
return 2;
case kRG_1616_GrPixelConfig:
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
return 8;
case kRG_half_GrPixelConfig:
return 4;
}
SK_ABORT("Invalid pixel config");
@ -672,9 +675,11 @@ static bool format_is_srgb(VkFormat format) {
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R16G16B16A16_SFLOAT:
case VK_FORMAT_R16_SFLOAT:
// Experimental (for P016 and P010)
case VK_FORMAT_R16_UNORM:
case VK_FORMAT_R16G16_UNORM:
// Experimental (for Y416 and mutant P016/P010)
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R16G16_SFLOAT:
return false;
default:
SK_ABORT("Unsupported VkFormat");
@ -702,10 +707,11 @@ static constexpr VkFormat kVkFormats[] = {
VK_FORMAT_R8G8B8A8_SRGB,
VK_FORMAT_B8G8R8A8_SRGB,
VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
// Experimental (for P016 and P010)
VK_FORMAT_R16_UNORM,
VK_FORMAT_R16G16_UNORM,
// Experimental (for Y416 and mutant P016/P010)
VK_FORMAT_R16G16B16A16_UNORM,
VK_FORMAT_R16G16_SFLOAT,
};
const GrVkCaps::FormatInfo& GrVkCaps::getFormatInfo(VkFormat format) const {
@ -1044,11 +1050,15 @@ static GrPixelConfig get_yuva_config(VkFormat vkFormat) {
return kBGRA_8888_GrPixelConfig;
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
return kRGBA_1010102_GrPixelConfig;
// Experimental (for P016 and P010)
case VK_FORMAT_R16_UNORM:
return kR_16_GrPixelConfig;
case VK_FORMAT_R16G16_UNORM:
return kRG_1616_GrPixelConfig;
// Experimental (for Y416 and mutant P016/P010)
case VK_FORMAT_R16G16B16A16_UNORM:
return kRGBA_16161616_GrPixelConfig;
case VK_FORMAT_R16G16_SFLOAT:
return kRG_half_GrPixelConfig;
default:
return kUnknown_GrPixelConfig;
}
@ -1111,11 +1121,15 @@ static bool format_color_type_valid_pair(VkFormat vkFormat, GrColorType colorTyp
return VK_FORMAT_R32G32B32A32_SFLOAT == vkFormat;
case GrColorType::kRGB_ETC1:
return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK == vkFormat;
// Experimental (for P016 and P010)
case GrColorType::kR_16:
return VK_FORMAT_R16_UNORM == vkFormat;
case GrColorType::kRG_1616:
return VK_FORMAT_R16G16_UNORM == vkFormat;
// Experimental (for Y416 and mutant P016/P010)
case GrColorType::kRGBA_16161616:
return VK_FORMAT_R16G16B16A16_UNORM == vkFormat;
case GrColorType::kRG_half:
return VK_FORMAT_R16G16_SFLOAT == vkFormat;
}
SK_ABORT("Unknown color type");
return false;

View File

@ -218,7 +218,7 @@ private:
SkTDArray<int> fColorSampleCounts;
};
static const size_t kNumVkFormats = 19;
static const size_t kNumVkFormats = 21;
FormatInfo fFormatTable[kNumVkFormats];
const FormatInfo& getFormatInfo(VkFormat) const;

View File

@ -1822,13 +1822,19 @@ static bool vk_format_to_pixel_config(VkFormat format, GrPixelConfig* config) {
case VK_FORMAT_R16_SFLOAT:
*config = kAlpha_half_GrPixelConfig;
return true;
// Experimental (for P016 and P010)
case VK_FORMAT_R16_UNORM:
*config = kR_16_GrPixelConfig;
return true;
case VK_FORMAT_R16G16_UNORM:
*config = kRG_1616_GrPixelConfig;
return true;
// Experimental (for Y416 and mutant P016/P010)
case VK_FORMAT_R16G16B16A16_UNORM:
*config = kRGBA_16161616_GrPixelConfig;
return true;
case VK_FORMAT_R16G16_SFLOAT:
*config = kRG_half_GrPixelConfig;
return true;
default:
return false;
}

View File

@ -74,9 +74,11 @@ static inline VkFormat attrib_type_to_vkformat(GrVertexAttribType type) {
return VK_FORMAT_R32_SINT;
case kUint_GrVertexAttribType:
return VK_FORMAT_R32_UINT;
// Experimental (for P016 and P010)
case kUShort_norm_GrVertexAttribType:
return VK_FORMAT_R16_UNORM;
// Experimental (for Y416)
case kUShort4_norm_GrVertexAttribType:
return VK_FORMAT_R16G16B16A16_UNORM;
}
SK_ABORT("Unknown vertex attrib type");
return VK_FORMAT_UNDEFINED;

View File

@ -83,13 +83,20 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
case kAlpha_half_as_Red_GrPixelConfig:
*format = VK_FORMAT_R16_SFLOAT;
return true;
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
*format = VK_FORMAT_R16_UNORM;
return true;
case kRG_1616_GrPixelConfig:
*format = VK_FORMAT_R16G16_UNORM;
return true;
// Experimental (for Y416 and mutant P016/P010)
case kRGBA_16161616_GrPixelConfig:
*format = VK_FORMAT_R16G16B16A16_UNORM;
return true;
case kRG_half_GrPixelConfig:
*format = VK_FORMAT_R16G16_SFLOAT;
return true;
}
SK_ABORT("Unexpected config");
return false;
@ -136,11 +143,15 @@ bool GrVkFormatPixelConfigPairIsValid(VkFormat format, GrPixelConfig config) {
case VK_FORMAT_R16_SFLOAT:
return kAlpha_half_GrPixelConfig == config ||
kAlpha_half_as_Red_GrPixelConfig == config;
// Experimental (for P016 and P010)
case VK_FORMAT_R16_UNORM:
return kR_16_GrPixelConfig == config;
case VK_FORMAT_R16G16_UNORM:
return kRG_1616_GrPixelConfig == config;
// Experimental (for Y416 and mutant P016/P010)
case VK_FORMAT_R16G16B16A16_UNORM:
return kRGBA_16161616_GrPixelConfig == config;
case VK_FORMAT_R16G16_SFLOAT:
return kRG_half_GrPixelConfig == config;
default:
return false;
}
@ -165,10 +176,11 @@ bool GrVkFormatIsSupported(VkFormat format) {
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R16G16B16A16_SFLOAT:
case VK_FORMAT_R16_SFLOAT:
// Experimental (for P016 and P010)
case VK_FORMAT_R16_UNORM:
case VK_FORMAT_R16G16_UNORM:
// Experimental (for Y416 and mutant P016/P010)
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R16G16_SFLOAT:
return true;
default:
return false;
@ -284,6 +296,7 @@ size_t GrVkBytesPerFormat(VkFormat vkFormat) {
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
case VK_FORMAT_R8G8_UNORM:
case VK_FORMAT_R16_SFLOAT:
case VK_FORMAT_R16_UNORM:
return 2;
case VK_FORMAT_R8G8B8_UNORM:
@ -294,6 +307,7 @@ size_t GrVkBytesPerFormat(VkFormat vkFormat) {
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_B8G8R8A8_SRGB:
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
case VK_FORMAT_R16G16_UNORM:
return 4;
case VK_FORMAT_R16G16B16A16_SFLOAT:
@ -306,10 +320,10 @@ size_t GrVkBytesPerFormat(VkFormat vkFormat) {
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
return 0;
// Experimental (for P016 and P010)
case VK_FORMAT_R16_UNORM:
return 2;
case VK_FORMAT_R16G16_UNORM:
// Experimental (for Y416 and mutant P016/P010)
case VK_FORMAT_R16G16B16A16_UNORM:
return 8;
case VK_FORMAT_R16G16_SFLOAT:
return 4;
default:

View File

@ -454,12 +454,17 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
kRGB_ETC1_GrPixelConfig, SkColors::kRed },
{ kUnknown_SkColorType, GR_GL_COMPRESSED_ETC1_RGB8,
kRGB_ETC1_GrPixelConfig, SkColors::kRed },
// Experimental (for P016 and P010)
{ kUnknown_SkColorType, GR_GL_R16,
kR_16_GrPixelConfig, SkColors::kRed },
{ kUnknown_SkColorType, GR_GL_RG16,
kRG_1616_GrPixelConfig, SkColors::kYellow },
kRG_1616_GrPixelConfig, SkColors::kYellow },
// Experimental (for Y416 and mutant P016/P010)
{ kUnknown_SkColorType, GR_GL_RGBA16,
kRGBA_16161616_GrPixelConfig, SkColors::kLtGray },
{ kUnknown_SkColorType, GR_GL_RG16F,
kRG_half_GrPixelConfig, SkColors::kYellow },
};
for (auto combo : combinations) {
@ -600,10 +605,12 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) {
{ kUnknown_SkColorType, VK_FORMAT_R8G8_UNORM, { 0.5f, 0.5f, 0, 0 } },
{ kUnknown_SkColorType, VK_FORMAT_R16_SFLOAT, { 1.0f, 0, 0, 0.5f } },
{ kUnknown_SkColorType, VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, SkColors::kRed },
// Experimental (for P016 and P010)
{ kUnknown_SkColorType, VK_FORMAT_R16_UNORM, SkColors::kRed },
{ kUnknown_SkColorType, VK_FORMAT_R16G16_UNORM, SkColors::kYellow },
// Experimental (for Y416 and mutant P016/P010)
{ kUnknown_SkColorType, VK_FORMAT_R16G16B16A16_UNORM, SkColors::kLtGray },
{ kUnknown_SkColorType, VK_FORMAT_R16G16_SFLOAT, SkColors::kYellow },
};
for (auto combo : combinations) {

View File

@ -105,9 +105,12 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
kRGBA_half_Clamped_GrPixelConfig,
kRGB_ETC1_GrPixelConfig,
// Experimental (for P016 and P010)
kR_16_GrPixelConfig,
kRG_1616_GrPixelConfig,
// Experimental (for Y416 and mutant P016/P010)
kRGBA_16161616_GrPixelConfig,
kRG_half_GrPixelConfig,
};
GR_STATIC_ASSERT(kGrPixelConfigCnt == SK_ARRAY_COUNT(configs));