Experimental: Add R_16 and RG_1616 to Ganesh

This is to support the P016 and P010 YUV formats. Initially, only Vulkan and GL support these formats.

Change-Id: Ie9609e59c12528079f8d379359ddb9bac85b6a29
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218546
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Robert Phillips 2019-06-05 16:55:19 -04:00 committed by Skia Commit-Bot
parent c5fae22bce
commit 93d0146dc6
21 changed files with 294 additions and 81 deletions

View File

@ -60,7 +60,11 @@ enum GrPixelConfig {
kRGBA_half_Clamped_GrPixelConfig,
kRGB_ETC1_GrPixelConfig,
kLast_GrPixelConfig = kRGB_ETC1_GrPixelConfig
// Experimental (for P016 and P010)
kR_16_GrPixelConfig,
kRG_1616_GrPixelConfig,
kLast_GrPixelConfig = kRG_1616_GrPixelConfig
};
static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;
@ -685,7 +689,10 @@ enum GrVertexAttribType {
kInt_GrVertexAttribType,
kUint_GrVertexAttribType,
kLast_GrVertexAttribType = kUint_GrVertexAttribType
// Experimental (for P016 and P010)
kUShort_norm_GrVertexAttribType,
kLast_GrVertexAttribType = kUShort_norm_GrVertexAttribType
};
static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
@ -891,6 +898,9 @@ 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:
return GrSRGBEncoded::kNo;
}
SK_ABORT("Invalid pixel config");
@ -934,6 +944,12 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
case kUnknown_GrPixelConfig:
case kRGB_ETC1_GrPixelConfig:
return 0;
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
return 2;
case kRG_1616_GrPixelConfig:
return 4;
}
SK_ABORT("Invalid pixel config");
return 0;
@ -950,6 +966,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:
return true;
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Alpha_GrPixelConfig:
@ -999,6 +1018,9 @@ 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:
return false;
}
SK_ABORT("Invalid pixel config.");
@ -1025,6 +1047,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:
return false;
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
@ -1053,29 +1078,7 @@ static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) {
switch (config) {
case kRGB_ETC1_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 kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGB_888_GrPixelConfig:
case kRGB_888X_GrPixelConfig:
case kRG_88_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
default:
return false;
}
SK_ABORT("Invalid pixel config");
@ -1089,29 +1092,7 @@ static inline GrPixelConfig GrMakePixelConfigUncompressed(GrPixelConfig config)
switch (config) {
case kRGB_ETC1_GrPixelConfig:
return kRGBA_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 kGray_8_as_Lum_GrPixelConfig:
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGB_888_GrPixelConfig:
case kRGB_888X_GrPixelConfig:
case kRG_88_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
default:
return config;
}
SK_ABORT("Invalid pixel config");
@ -1131,29 +1112,7 @@ static inline size_t GrCompressedFormatDataSize(GrPixelConfig config,
SkASSERT((height & 3) == 0);
return (width >> 2) * (height >> 2) * 8;
case kUnknown_GrPixelConfig:
case kAlpha_8_GrPixelConfig:
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 kRGB_888_GrPixelConfig:
case kRGB_888X_GrPixelConfig:
case kRG_88_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kRGBA_half_Clamped_GrPixelConfig:
default:
SK_ABORT("Unknown compressed pixel config");
return 4 * width * height;
}
@ -1193,6 +1152,9 @@ 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:
return kMedium_GrSLPrecision;
}
SK_ABORT("Unexpected type");
@ -1223,6 +1185,10 @@ enum class GrColorType {
kRG_F32,
kRGBA_F32,
kRGB_ETC1, // This type doesn't appear in SkColorType at all.
// Experimental (for P016 and P010)
kR_16, // Not in SkColorType
kRG_1616, // Not in SkColorType
};
static inline SkColorType GrColorTypeToSkColorType(GrColorType ct) {
@ -1243,6 +1209,9 @@ 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;
}
SK_ABORT("Invalid GrColorType");
return kUnknown_SkColorType;
@ -1288,6 +1257,10 @@ 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;
}
SK_ABORT("Invalid GrColorType");
return kUnknown_SkColorType;
@ -1319,6 +1292,9 @@ 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;
}
SK_ABORT("Invalid GrColorType");
return 0;
@ -1399,6 +1375,14 @@ 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;
case kRG_1616_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kNo;
return GrColorType::kRG_1616;
}
SK_ABORT("Invalid GrPixelConfig");
return GrColorType::kUnknown;
@ -1472,6 +1456,14 @@ static inline GrPixelConfig GrColorTypeToPixelConfig(GrColorType config,
case GrColorType::kRGB_ETC1:
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;
}
SK_ABORT("Invalid GrColorType");
return kUnknown_GrPixelConfig;

View File

@ -156,6 +156,9 @@ 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";
}
SK_ABORT("Invalid pixel config");
return "<invalid>";

View File

@ -262,6 +262,21 @@ 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);
break;
}
case kRG_1616_GrPixelConfig: {
uint16_t r16 = SkScalarRoundToInt(colorf.fR * 65535.0f);
uint16_t g16 = SkScalarRoundToInt(colorf.fG * 65535.0f);
uint32_t rg1616 = r16 << 16 | g16;
sk_memset32((uint32_t*) dest, rg1616, width * height);
break;
}
default:
return false;
break;

View File

@ -353,6 +353,9 @@ 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);
}
// GCC fails because SK_ABORT evaluates to non constexpr. clang and cl.exe think this is
// unreachable and don't complain.

View File

@ -70,6 +70,9 @@ 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;
}
SK_ABORT("Invalid GrColorType");
return false;
@ -103,6 +106,9 @@ 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;
}
SK_ABORT("Invalid GrPixelConfig");
return false;

View File

@ -319,6 +319,9 @@ 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:
return 0;
case kRGB_565_GrPixelConfig:
return 1;

View File

@ -1869,11 +1869,11 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
}
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[kReadPixels_ExternalFormatUsage] = GR_GL_RED;
redInfo.fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
redInfo.fFormatType = kNormalizedFixedPoint_FormatType;
shaderCaps->fConfigTextureSwizzle[kAlpha_8_as_Red_GrPixelConfig] = GrSwizzle::RRRR();
// ES2 Command Buffer does not allow TexStorage with R8_EXT (so Alpha_8 and Gray_8)
@ -1898,11 +1898,11 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
}
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[kReadPixels_ExternalFormatUsage] = GR_GL_LUMINANCE;
grayLumInfo.fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
grayLumInfo.fFormatType = kNormalizedFixedPoint_FormatType;
shaderCaps->fConfigTextureSwizzle[kGray_8_as_Lum_GrPixelConfig] = GrSwizzle::RGBA();
if ((GR_IS_GR_GL(standard) && version <= GR_GL_VER(3, 0)) ||
@ -1912,13 +1912,13 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
}
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[kReadPixels_ExternalFormatUsage] = GR_GL_RED;
shaderCaps->fConfigTextureSwizzle[kGray_8_as_Red_GrPixelConfig] = GrSwizzle::RRRA();
grayRedInfo.fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
grayRedInfo.fFormatType = kNormalizedFixedPoint_FormatType;
grayRedInfo.fFlags = ConfigInfo::kTextureable_Flag;
shaderCaps->fConfigTextureSwizzle[kGray_8_as_Red_GrPixelConfig] = GrSwizzle::RRRA();
// Leaving Gray8 as non-renderable, to keep things simple and match raster. However, we do
// enable the FBOColorAttachment_Flag so that we can bind it to an FBO for copies.
@ -2135,6 +2135,59 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
} // No WebGL support
shaderCaps->fConfigTextureSwizzle[kRGB_ETC1_GrPixelConfig] = GrSwizzle::RGBA();
// Experimental (for P016 and P010)
{
// For desktop:
// GL 3.0 requires support for R16 & RG16
// GL_ARB_texture_rg adds R16 & RG16 support for OpenGL 1.1 and above
// For ES:
// GL_EXT_texture_norm16 adds support but it requires ES 3.1
// There is also the GL_NV_image_formats extension - for further investigation
bool r16AndRG1616Supported = false;
if (GR_IS_GR_GL(standard)) {
if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_texture_rg")) {
r16AndRG1616Supported = true;
}
} else if (GR_IS_GR_GL_ES(standard)) {
if (version >= GR_GL_VER(3, 1) && ctxInfo.hasExtension("GL_EXT_texture_norm16")) {
r16AndRG1616Supported = true;
}
} // No WebGL support
{
ConfigInfo& r16Info = fConfigTable[kR_16_GrPixelConfig];
r16Info.fFormats.fBaseInternalFormat = GR_GL_RED;
r16Info.fFormats.fSizedInternalFormat = GR_GL_R16;
r16Info.fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] = GR_GL_RED;
r16Info.fFormats.fExternalType = GR_GL_UNSIGNED_SHORT;
r16Info.fFormatType = kNormalizedFixedPoint_FormatType;
if (r16AndRG1616Supported) {
r16Info.fFlags = ConfigInfo::kTextureable_Flag;
}
// We should only ever be sampling the R channel of this format so don't bother
// with a fancy swizzle.
shaderCaps->fConfigTextureSwizzle[kR_16_GrPixelConfig] = GrSwizzle::RGBA();
}
{
ConfigInfo& rg1616Info = fConfigTable[kRG_1616_GrPixelConfig];
rg1616Info.fFormats.fBaseInternalFormat = GR_GL_RG;
rg1616Info.fFormats.fSizedInternalFormat = GR_GL_RG16;
rg1616Info.fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] = GR_GL_RG;
rg1616Info.fFormats.fExternalType = GR_GL_UNSIGNED_SHORT;
rg1616Info.fFormatType = kNormalizedFixedPoint_FormatType;
if (r16AndRG1616Supported) {
rg1616Info.fFlags = ConfigInfo::kTextureable_Flag;
}
// 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();
}
}
// Bulk populate the texture internal/external formats here and then deal with exceptions below.
// ES 2.0 requires that the internal/external formats match.
@ -3252,6 +3305,13 @@ 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;
}
return config;
@ -3309,6 +3369,11 @@ 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;
}
SK_ABORT("Unknown color type");
return false;

View File

@ -887,6 +887,12 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
case kRGB_ETC1_GrPixelConfig:
case kUnknown_GrPixelConfig:
return 0;
// Experimental (for P016 and P010)
case kR_16_GrPixelConfig:
return 2;
case kRG_1616_GrPixelConfig:
return 4;
}
SK_ABORT("Invalid pixel config");
return 0;
@ -4020,6 +4026,14 @@ 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;
}
SK_ABORT("Unexpected config");

View File

@ -633,6 +633,12 @@ size_t GrGLBytesPerFormat(GrGLenum glFormat) {
case GR_GL_COMPRESSED_RGB8_ETC2: // fall through
case GR_GL_COMPRESSED_ETC1_RGB8:
return 0;
// Experimental (for P016 and P010)
case GR_GL_R16:
return 2;
case GR_GL_RG16:
return 4;
}
SK_ABORT("Invalid GL format");

View File

@ -74,6 +74,9 @@ 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};
}
SK_ABORT("Unknown vertex attrib type");
return {false, 0, 0};

View File

@ -446,6 +446,13 @@ void GrMtlCaps::initConfigTable() {
info = &fConfigTable[kRGBA_half_Clamped_GrPixelConfig];
info->fFlags = ConfigInfo::kAllFlags;
// Experimental (for P016 and P010)
info = &fConfigTable[kR_16_GrPixelConfig];
info->fFlags = 0;
info = &fConfigTable[kRG_1616_GrPixelConfig];
info->fFlags = 0;
}
void GrMtlCaps::initStencilFormat(id<MTLDevice> physDev) {
@ -578,6 +585,13 @@ static GrPixelConfig get_yuva_config(GrMTLPixelFormat grFormat) {
case MTLPixelFormatBGRA8Unorm:
return kBGRA_8888_GrPixelConfig;
break;
// Experimental (for P016 and P010)
case MTLPixelFormatR16Unorm:
return kR_16_GrPixelConfig;
break;
case MTLPixelFormatRG16Unorm:
return kRG_1616_GrPixelConfig;
break;
default:
return kUnknown_GrPixelConfig;
break;
@ -652,6 +666,11 @@ 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;
}
SK_ABORT("Unknown color type");
return false;

View File

@ -756,6 +756,13 @@ 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;
default:
return false;
}

View File

@ -141,6 +141,9 @@ 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;
}
SK_ABORT("Unknown vertex attribute type");
return MTLVertexFormatInvalid;

View File

@ -104,6 +104,12 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
#else
return false;
#endif
case kR_16_GrPixelConfig:
*format = MTLPixelFormatR16Unorm;
return true;
case kRG_1616_GrPixelConfig:
*format = MTLPixelFormatRG16Unorm;
return true;
}
SK_ABORT("Unexpected config");
return false;

View File

@ -110,6 +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:
return 4;
}
SK_ABORT("Invalid pixel config");
return 0;
@ -713,6 +718,9 @@ 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:
return false;
default:
SK_ABORT("Unsupported VkFormat");
@ -739,7 +747,11 @@ static constexpr VkFormat kVkFormats[] = {
VK_FORMAT_R32G32_SFLOAT,
VK_FORMAT_R8G8B8A8_SRGB,
VK_FORMAT_B8G8R8A8_SRGB,
VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
// Experimental (for P016 and P010)
VK_FORMAT_R16_UNORM,
VK_FORMAT_R16G16_UNORM,
};
const GrVkCaps::FormatInfo& GrVkCaps::getFormatInfo(VkFormat format) const {
@ -1078,6 +1090,11 @@ 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;
default:
return kUnknown_GrPixelConfig;
}
@ -1140,6 +1157,11 @@ 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;
}
SK_ABORT("Unknown color type");
return false;

View File

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

View File

@ -1829,6 +1829,13 @@ 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;
default:
return false;
}

View File

@ -74,6 +74,9 @@ 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;
}
SK_ABORT("Unknown vertex attrib type");
return VK_FORMAT_UNDEFINED;

View File

@ -83,6 +83,13 @@ 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;
}
SK_ABORT("Unexpected config");
return false;
@ -129,6 +136,11 @@ 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;
default:
return false;
}
@ -153,6 +165,10 @@ 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:
return true;
default:
return false;
@ -290,6 +306,12 @@ 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:
return 4;
default:
SK_ABORT("Invalid Vk format");
return 0;

View File

@ -454,6 +454,12 @@ 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 },
};
for (auto combo : combinations) {
@ -593,7 +599,11 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) {
{ kUnknown_SkColorType, VK_FORMAT_R32G32_SFLOAT, { 0.7f, 0.7f, 0, 0 } },
{ 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 },
{ 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 },
};
for (auto combo : combinations) {

View File

@ -104,6 +104,10 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
kRGBA_half_GrPixelConfig,
kRGBA_half_Clamped_GrPixelConfig,
kRGB_ETC1_GrPixelConfig,
// Experimental (for P016 and P010)
kR_16_GrPixelConfig,
kRG_1616_GrPixelConfig,
};
GR_STATIC_ASSERT(kGrPixelConfigCnt == SK_ARRAY_COUNT(configs));