Revert "Revert "Add 1010102 support to Ganesh""

This reverts commit ded47a5014.

Bug: skia:
Change-Id: I7d7552e6ccc8591cae91426407ab13b628b93b68
Reviewed-on: https://skia-review.googlesource.com/111760
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2018-03-02 11:01:10 -05:00 committed by Skia Commit-Bot
parent fde6fa0903
commit 10fc6fddf2
30 changed files with 209 additions and 72 deletions

View File

@ -314,6 +314,11 @@ enum GrPixelConfig {
*/
kSBGRA_8888_GrPixelConfig,
/**
* Premultiplied.
*/
kRGBA_1010102_GrPixelConfig,
/**
* Byte order is r, g, b, a. This color format is 32 bits per channel
*/

View File

@ -797,6 +797,7 @@ static inline GrSRGBEncoded GrPixelConfigIsSRGBEncoded(GrPixelConfig config) {
case kRGBA_4444_GrPixelConfig:
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
@ -832,6 +833,7 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) {
case kGray_8_as_Red_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
@ -861,6 +863,7 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
return 4;
case kRGBA_half_GrPixelConfig:
return 8;
@ -893,6 +896,7 @@ static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kUnknown_GrPixelConfig:
@ -920,6 +924,7 @@ static inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) {
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 kRGBA_half_GrPixelConfig:
@ -950,6 +955,7 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
return false;
}
SK_ABORT("Invalid pixel config");
@ -970,6 +976,7 @@ static inline bool GrPixelConfigIsUnorm(GrPixelConfig config) {
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
return true;
case kUnknown_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
@ -1008,6 +1015,7 @@ static inline GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) {
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_half_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
return kMedium_GrSLPrecision;
}
SK_ABORT("Unexpected type");
@ -1033,6 +1041,7 @@ enum class GrColorType {
kABGR_4444, // This name differs from SkColorType. kARGB_4444_SkColorType is misnamed.
kRGBA_8888,
kBGRA_8888,
kRGBA_1010102,
kGray_8,
kAlpha_F16,
kRGBA_F16,
@ -1042,17 +1051,18 @@ enum class GrColorType {
static inline SkColorType GrColorTypeToSkColorType(GrColorType ct) {
switch (ct) {
case GrColorType::kUnknown: return kUnknown_SkColorType;
case GrColorType::kAlpha_8: return kAlpha_8_SkColorType;
case GrColorType::kRGB_565: return kRGB_565_SkColorType;
case GrColorType::kABGR_4444: return kARGB_4444_SkColorType;
case GrColorType::kRGBA_8888: return kRGBA_8888_SkColorType;
case GrColorType::kBGRA_8888: return kBGRA_8888_SkColorType;
case GrColorType::kGray_8: return kGray_8_SkColorType;
case GrColorType::kAlpha_F16: return kUnknown_SkColorType;
case GrColorType::kRGBA_F16: return kRGBA_F16_SkColorType;
case GrColorType::kRG_F32: return kUnknown_SkColorType;
case GrColorType::kRGBA_F32: return kUnknown_SkColorType;
case GrColorType::kUnknown: return kUnknown_SkColorType;
case GrColorType::kAlpha_8: return kAlpha_8_SkColorType;
case GrColorType::kRGB_565: return kRGB_565_SkColorType;
case GrColorType::kABGR_4444: return kARGB_4444_SkColorType;
case GrColorType::kRGBA_8888: return kRGBA_8888_SkColorType;
case GrColorType::kBGRA_8888: return kBGRA_8888_SkColorType;
case GrColorType::kRGBA_1010102: return kRGBA_1010102_SkColorType;
case GrColorType::kGray_8: return kGray_8_SkColorType;
case GrColorType::kAlpha_F16: return kUnknown_SkColorType;
case GrColorType::kRGBA_F16: return kRGBA_F16_SkColorType;
case GrColorType::kRG_F32: return kUnknown_SkColorType;
case GrColorType::kRGBA_F32: return kUnknown_SkColorType;
}
SK_ABORT("Invalid GrColorType");
return kUnknown_SkColorType;
@ -1069,7 +1079,7 @@ static inline GrColorType SkColorTypeToGrColorType(SkColorType ct) {
case kRGB_888x_SkColorType: return GrColorType::kUnknown;
case kGray_8_SkColorType: return GrColorType::kGray_8;
case kRGBA_F16_SkColorType: return GrColorType::kRGBA_F16;
case kRGBA_1010102_SkColorType: return GrColorType::kUnknown;
case kRGBA_1010102_SkColorType: return GrColorType::kRGBA_1010102;
case kRGB_101010x_SkColorType: return GrColorType::kUnknown;
}
SK_ABORT("Invalid SkColorType");
@ -1078,17 +1088,18 @@ static inline GrColorType SkColorTypeToGrColorType(SkColorType ct) {
static inline int GrColorTypeBytesPerPixel(GrColorType ct) {
switch (ct) {
case GrColorType::kUnknown: return 0;
case GrColorType::kAlpha_8: return 1;
case GrColorType::kRGB_565: return 2;
case GrColorType::kABGR_4444: return 2;
case GrColorType::kRGBA_8888: return 4;
case GrColorType::kBGRA_8888: return 4;
case GrColorType::kGray_8: return 1;
case GrColorType::kAlpha_F16: return 2;
case GrColorType::kRGBA_F16: return 8;
case GrColorType::kRG_F32: return 8;
case GrColorType::kRGBA_F32: return 16;
case GrColorType::kUnknown: return 0;
case GrColorType::kAlpha_8: return 1;
case GrColorType::kRGB_565: return 2;
case GrColorType::kABGR_4444: return 2;
case GrColorType::kRGBA_8888: return 4;
case GrColorType::kBGRA_8888: return 4;
case GrColorType::kRGBA_1010102: return 4;
case GrColorType::kGray_8: return 1;
case GrColorType::kAlpha_F16: return 2;
case GrColorType::kRGBA_F16: return 8;
case GrColorType::kRG_F32: return 8;
case GrColorType::kRGBA_F32: return 16;
}
SK_ABORT("Invalid GrColorType");
return 0;
@ -1096,17 +1107,18 @@ static inline int GrColorTypeBytesPerPixel(GrColorType ct) {
static inline int GrColorTypeIsAlphaOnly(GrColorType ct) {
switch (ct) {
case GrColorType::kUnknown: return false;
case GrColorType::kAlpha_8: return true;
case GrColorType::kRGB_565: return false;
case GrColorType::kABGR_4444: return false;
case GrColorType::kRGBA_8888: return false;
case GrColorType::kBGRA_8888: return false;
case GrColorType::kGray_8: return false;
case GrColorType::kAlpha_F16: return true;
case GrColorType::kRGBA_F16: return false;
case GrColorType::kRG_F32: return false;
case GrColorType::kRGBA_F32: return false;
case GrColorType::kUnknown: return false;
case GrColorType::kAlpha_8: return true;
case GrColorType::kRGB_565: return false;
case GrColorType::kABGR_4444: return false;
case GrColorType::kRGBA_8888: return false;
case GrColorType::kBGRA_8888: return false;
case GrColorType::kRGBA_1010102: return false;
case GrColorType::kGray_8: return false;
case GrColorType::kAlpha_F16: return true;
case GrColorType::kRGBA_F16: return false;
case GrColorType::kRG_F32: return false;
case GrColorType::kRGBA_F32: return false;
}
SK_ABORT("Invalid GrColorType");
return false;
@ -1142,6 +1154,9 @@ static inline GrColorType GrPixelConfigToColorTypeAndEncoding(GrPixelConfig conf
case kSBGRA_8888_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kYes;
return GrColorType::kBGRA_8888;
case kRGBA_1010102_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kNo;
return GrColorType::kRGBA_1010102;
case kRGBA_float_GrPixelConfig:
*srgbEncoded = GrSRGBEncoded::kNo;
return GrColorType::kRGBA_F32;
@ -1208,6 +1223,10 @@ static inline GrPixelConfig GrColorTypeToPixelConfig(GrColorType config,
return (GrSRGBEncoded::kYes == srgbEncoded) ? kSBGRA_8888_GrPixelConfig
: kBGRA_8888_GrPixelConfig;
case GrColorType::kRGBA_1010102:
return (GrSRGBEncoded::kYes == srgbEncoded) ? kUnknown_GrPixelConfig
: kRGBA_1010102_GrPixelConfig;
case GrColorType::kRGBA_F32:
return (GrSRGBEncoded::kYes == srgbEncoded) ? kUnknown_GrPixelConfig
: kRGBA_float_GrPixelConfig;

View File

@ -164,6 +164,7 @@
"--nocpu",
"--config",
"vk",
"vk1010102",
"--src",
"tests",
"gm",

View File

@ -169,6 +169,7 @@
"gldft",
"glsrgb",
"glmsaa8",
"gl1010102",
"--src",
"tests",
"gm",

View File

@ -169,6 +169,7 @@
"gldft",
"glsrgb",
"glmsaa8",
"gl1010102",
"--src",
"tests",
"gm",

View File

@ -169,6 +169,7 @@
"gldft",
"glsrgb",
"glmsaa8",
"gl1010102",
"--src",
"tests",
"gm",

View File

@ -212,6 +212,13 @@ def dm_flags(api, bot):
if 'Vulkan' in bot:
configs = ['vk']
# Test 1010102 on our Linux/NVIDIA bots
if 'QuadroP400' in bot and api.vars.is_linux:
if 'Vulkan' in bot:
configs.append('vk1010102')
else:
configs.append('gl1010102')
if 'ChromeOS' in bot:
# Just run GLES for now - maybe add gles_msaa4 in the future
configs = ['gles']

View File

@ -2880,6 +2880,7 @@ int SkCanvas::LayerIter::y() const { return fImpl->getY(); }
///////////////////////////////////////////////////////////////////////////////
// TODO: This still disagrees with SkSurfaceValidateRasterInfo
static bool supported_for_raster_canvas(const SkImageInfo& info) {
switch (info.alphaType()) {
case kPremul_SkAlphaType:
@ -2894,6 +2895,7 @@ static bool supported_for_raster_canvas(const SkImageInfo& info) {
case kRGB_565_SkColorType:
case kN32_SkColorType:
case kRGBA_F16_SkColorType:
case kRGBA_1010102_SkColorType:
break;
default:
return false;

View File

@ -235,7 +235,8 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
SkASSERT(kBGRA_8888_GrPixelConfig == config || kRGBA_8888_GrPixelConfig == config ||
kRGBA_4444_GrPixelConfig == config || kRGB_565_GrPixelConfig == config ||
kSRGBA_8888_GrPixelConfig == config || kSBGRA_8888_GrPixelConfig == config ||
kRGBA_half_GrPixelConfig == config || kAlpha_8_GrPixelConfig == config);
kRGBA_half_GrPixelConfig == config || kAlpha_8_GrPixelConfig == config ||
kRGBA_1010102_GrPixelConfig == config);
const int width = dstBounds.width();
const int height = dstBounds.height();

View File

@ -27,6 +27,7 @@ static const char* pixel_config_name(GrPixelConfig config) {
case kBGRA_8888_GrPixelConfig: return "BGRA8888";
case kSRGBA_8888_GrPixelConfig: return "SRGBA8888";
case kSBGRA_8888_GrPixelConfig: return "SBGRA8888";
case kRGBA_1010102_GrPixelConfig: return "RGBA1010102";
case kRGBA_float_GrPixelConfig: return "RGBAFloat";
case kRG_float_GrPixelConfig: return "RGFloat";
case kAlpha_half_GrPixelConfig: return "AlphaHalf";

View File

@ -630,6 +630,7 @@ static bool valid_premul_config(GrPixelConfig config) {
case kBGRA_8888_GrPixelConfig: return true;
case kSRGBA_8888_GrPixelConfig: return true;
case kSBGRA_8888_GrPixelConfig: return true;
case kRGBA_1010102_GrPixelConfig: return true;
case kRGBA_float_GrPixelConfig: return true;
case kRG_float_GrPixelConfig: return false;
case kAlpha_half_GrPixelConfig: return false;
@ -646,17 +647,18 @@ static bool valid_premul_config(GrPixelConfig config) {
static bool valid_premul_color_type(GrColorType ct) {
switch (ct) {
case GrColorType::kUnknown: return false;
case GrColorType::kAlpha_8: return false;
case GrColorType::kRGB_565: return false;
case GrColorType::kABGR_4444: return true;
case GrColorType::kRGBA_8888: return true;
case GrColorType::kBGRA_8888: return true;
case GrColorType::kGray_8: return false;
case GrColorType::kAlpha_F16: return false;
case GrColorType::kRGBA_F16: return true;
case GrColorType::kRG_F32: return false;
case GrColorType::kRGBA_F32: return true;
case GrColorType::kUnknown: return false;
case GrColorType::kAlpha_8: return false;
case GrColorType::kRGB_565: return false;
case GrColorType::kABGR_4444: return true;
case GrColorType::kRGBA_8888: return true;
case GrColorType::kBGRA_8888: return true;
case GrColorType::kRGBA_1010102: return true;
case GrColorType::kGray_8: return false;
case GrColorType::kAlpha_F16: return false;
case GrColorType::kRGBA_F16: return true;
case GrColorType::kRG_F32: return false;
case GrColorType::kRGBA_F32: return true;
}
SK_ABORT("Invalid GrColorType");
return false;
@ -1321,6 +1323,7 @@ static inline GrPixelConfig GrPixelConfigFallback(GrPixelConfig config) {
case kRGB_565_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
return kRGBA_8888_GrPixelConfig;
case kSBGRA_8888_GrPixelConfig:
return kSRGBA_8888_GrPixelConfig;

View File

@ -1713,9 +1713,15 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
SkBackingFit fit = kNever_TileUsage == cinfo.fTileUsage ? SkBackingFit::kApprox
: SkBackingFit::kExact;
GrPixelConfig config = fRenderTargetContext->colorSpaceInfo().config();
if (kRGBA_1010102_GrPixelConfig == config) {
// If the original device is 1010102, fall back to 8888 so that we have a usable alpha
// channel in the layer.
config = kRGBA_8888_GrPixelConfig;
}
sk_sp<GrRenderTargetContext> rtc(fContext->makeDeferredRenderTargetContext(
fit, cinfo.fInfo.width(), cinfo.fInfo.height(),
fRenderTargetContext->colorSpaceInfo().config(),
fit, cinfo.fInfo.width(), cinfo.fInfo.height(), config,
fRenderTargetContext->colorSpaceInfo().refColorSpace(),
fRenderTargetContext->numStencilSamples(), GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin, &props));

View File

@ -264,7 +264,7 @@ GrPixelConfig SkImageInfo2GrPixelConfig(const SkColorType type, SkColorSpace* cs
return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB())
? kSBGRA_8888_GrPixelConfig : kBGRA_8888_GrPixelConfig;
case kRGBA_1010102_SkColorType:
return kUnknown_GrPixelConfig;
return kRGBA_1010102_GrPixelConfig;
case kRGB_101010x_SkColorType:
return kUnknown_GrPixelConfig;
case kGray_8_SkColorType:
@ -311,6 +311,9 @@ bool GrPixelConfigToColorType(GrPixelConfig config, SkColorType* ctOut) {
case kSBGRA_8888_GrPixelConfig:
ct = kBGRA_8888_SkColorType;
break;
case kRGBA_1010102_GrPixelConfig:
ct = kRGBA_1010102_SkColorType;
break;
case kRGBA_half_GrPixelConfig:
ct = kRGBA_F16_SkColorType;
break;

View File

@ -28,6 +28,7 @@ layout(key) in int rangeType;
rangeType = 2;
break;
case kUnknown_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_float_GrPixelConfig:

View File

@ -37,6 +37,7 @@ public:
rangeType = 2;
break;
case kUnknown_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kAlpha_half_GrPixelConfig:
case kAlpha_half_as_Red_GrPixelConfig:
case kRGBA_float_GrPixelConfig:

View File

@ -1611,6 +1611,25 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
}
fConfigTable[kRGBA_4444_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
fConfigTable[kRGBA_1010102_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
fConfigTable[kRGBA_1010102_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGB10_A2;
fConfigTable[kRGBA_1010102_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
GR_GL_RGBA;
fConfigTable[kRGBA_1010102_GrPixelConfig].fFormats.fExternalType =
GR_GL_UNSIGNED_INT_2_10_10_10_REV;
fConfigTable[kRGBA_1010102_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3, 0)) {
fConfigTable[kRGBA_1010102_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
allRenderFlags;
}
if (texStorageSupported) {
fConfigTable[kRGBA_1010102_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
if (texelBufferSupport) {
fConfigTable[kRGBA_1010102_GrPixelConfig].fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag;
}
fConfigTable[kRGBA_1010102_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
bool alpha8IsValidForGL = kGL_GrGLStandard == standard &&
(!fIsCoreProfile || version <= GR_GL_VER(3, 0));
@ -2519,7 +2538,10 @@ bool validate_sized_format(GrGLenum format, SkColorType ct, GrPixelConfig* confi
}
break;
case kRGBA_1010102_SkColorType:
return false;
if (GR_GL_RGB10_A2 == format) {
*config = kRGBA_1010102_GrPixelConfig;
}
break;
case kRGB_101010x_SkColorType:
return false;
case kGray_8_SkColorType:

View File

@ -508,6 +508,7 @@
#define GR_GL_RGBA4 0x8056
#define GR_GL_RGB5_A1 0x8057
#define GR_GL_RGBA8 0x8058
#define GR_GL_RGB10_A2 0x8059
#define GR_GL_SRGB8_ALPHA8 0x8C43
#define GR_GL_RGBA16F 0x881A
#define GR_GL_RGBA32F 0x8814
@ -529,6 +530,7 @@
#define GR_GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GR_GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GR_GL_UNSIGNED_SHORT_5_6_5 0x8363
#define GR_GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
/* Shaders */
#define GR_GL_FRAGMENT_SHADER 0x8B30

View File

@ -800,6 +800,7 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
case kRGBA_1010102_GrPixelConfig:
case kRGBA_float_GrPixelConfig:
case kRG_float_GrPixelConfig:
return 4;

View File

@ -504,6 +504,8 @@ GrPixelConfig GrGLSizedFormatToPixelConfig(GrGLenum sizedFormat) {
return kRGB_565_GrPixelConfig;
case GR_GL_RGBA4:
return kRGBA_4444_GrPixelConfig;
case GR_GL_RGB10_A2:
return kRGBA_1010102_GrPixelConfig;
case GR_GL_LUMINANCE8:
return kGray_8_GrPixelConfig;
case GR_GL_RGBA32F:

View File

@ -30,9 +30,12 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
case kSBGRA_8888_GrPixelConfig:
*format = MTLPixelFormatBGRA8Unorm_sRGB;
return true;
case kRGBA_1010102_GrPixelConfig:
*format = MTLPixelFormatRGB10A2Unorm;
return true;
case kRGB_565_GrPixelConfig:
#ifdef SK_BUILD_FOR_IOS
*format = MTLPixelFormatR5G6B5Unorm;
*format = MTLPixelFormatB5G6R5Unorm;
return true;
#else
return false;
@ -84,6 +87,8 @@ GrPixelConfig GrMTLFormatToPixelConfig(MTLPixelFormat format) {
return kSRGBA_8888_GrPixelConfig;
case MTLPixelFormatBGRA8Unorm_sRGB:
return kSBGRA_8888_GrPixelConfig;
case MTLPixelFormatRGB10A2Unorm:
return kRGBA_1010102_GrPixelConfig;
#ifdef SK_BUILD_FOR_IOS
case MTLPixelFormatB5G6R5Unorm:
return kRGB_565_GrPixelConfig;

View File

@ -489,7 +489,10 @@ bool validate_image_info(VkFormat format, SkColorType ct, GrPixelConfig* config)
}
break;
case kRGBA_1010102_SkColorType:
return false;
if (VK_FORMAT_A2B10G10R10_UNORM_PACK32 == format) {
*config = kRGBA_1010102_GrPixelConfig;
}
break;
case kRGB_101010x_SkColorType:
return false;
case kGray_8_SkColorType:

View File

@ -31,6 +31,9 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
case kSBGRA_8888_GrPixelConfig:
*format = VK_FORMAT_B8G8R8A8_SRGB;
return true;
case kRGBA_1010102_GrPixelConfig:
*format = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
return true;
case kRGB_565_GrPixelConfig:
*format = VK_FORMAT_R5G6B5_UNORM_PACK16;
return true;
@ -79,6 +82,8 @@ GrPixelConfig GrVkFormatToPixelConfig(VkFormat format) {
return kSRGBA_8888_GrPixelConfig;
case VK_FORMAT_B8G8R8A8_SRGB:
return kSBGRA_8888_GrPixelConfig;
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
return kRGBA_1010102_GrPixelConfig;
case VK_FORMAT_R5G6B5_UNORM_PACK16:
return kRGB_565_GrPixelConfig;
break;
@ -111,6 +116,8 @@ bool GrVkFormatPixelConfigPairIsValid(VkFormat format, GrPixelConfig config) {
return kSRGBA_8888_GrPixelConfig == config;
case VK_FORMAT_B8G8R8A8_SRGB:
return kSBGRA_8888_GrPixelConfig == config;
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
return kRGBA_1010102_GrPixelConfig == config;
case VK_FORMAT_R5G6B5_UNORM_PACK16:
return kRGB_565_GrPixelConfig == config;
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
@ -143,6 +150,7 @@ bool GrVkFormatIsSupported(VkFormat format) {
case VK_FORMAT_R8G8B8A8_SRGB:
case VK_FORMAT_B8G8R8A8_SRGB:
case VK_FORMAT_R8G8B8A8_SINT:
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
case VK_FORMAT_R8_UNORM:

View File

@ -92,6 +92,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
kBGRA_8888_GrPixelConfig,
kSRGBA_8888_GrPixelConfig,
kSBGRA_8888_GrPixelConfig,
kRGBA_1010102_GrPixelConfig,
kRGBA_float_GrPixelConfig,
kRG_float_GrPixelConfig,
kAlpha_half_GrPixelConfig,

View File

@ -90,10 +90,12 @@ DEF_TEST(PictureImageGenerator, reporter) {
{ kRGBA_8888_SkColorType, kPremul_SkAlphaType, kRGBA_8888_SkColorType == kN32_SkColorType },
{ kBGRA_8888_SkColorType, kPremul_SkAlphaType, kBGRA_8888_SkColorType == kN32_SkColorType },
{ kRGBA_F16_SkColorType, kPremul_SkAlphaType, true },
{ kRGBA_1010102_SkColorType, kPremul_SkAlphaType, true },
{ kRGBA_8888_SkColorType, kUnpremul_SkAlphaType, false },
{ kBGRA_8888_SkColorType, kUnpremul_SkAlphaType, false },
{ kRGBA_F16_SkColorType, kUnpremul_SkAlphaType, false },
{ kRGBA_1010102_SkColorType, kUnpremul_SkAlphaType, false },
};
auto colorspace = SkColorSpace::MakeSRGB();

View File

@ -104,7 +104,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
for (auto widthHeight : { 100, 128, 1048576 }) {
for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig,
kRGBA_8888_GrPixelConfig }) {
kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) {
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
for (auto numSamples : {1, 4, 16, 128}) {
@ -196,7 +196,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
return;
}
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType }) {
for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType,
kRGBA_1010102_SkColorType }) {
for (auto numSamples : {1, 4}) {
GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, caps);
SkASSERT(kUnknown_GrPixelConfig != config);

View File

@ -25,11 +25,17 @@ static const int X_SIZE = 13;
static const int Y_SIZE = 13;
static void validate_alpha_data(skiatest::Reporter* reporter, int w, int h, const uint8_t* actual,
size_t actualRowBytes, const uint8_t* expected, SkString extraMsg) {
size_t actualRowBytes, const uint8_t* expected, SkString extraMsg,
GrPixelConfig config) {
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
uint8_t a = actual[y * actualRowBytes + x];
uint8_t e = expected[y * w + x];
if (kRGBA_1010102_GrPixelConfig == config) {
// This config only preserves two bits of alpha
a >>= 6;
e >>= 6;
}
if (e != a) {
ERRORF(reporter,
"Failed alpha readback. Expected: 0x%02x, Got: 0x%02x at (%d,%d), %s",
@ -87,9 +93,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, result, "Initial A8 writePixels failed");
size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE;
std::unique_ptr<uint8_t[]> readback(new uint8_t[nonZeroRowBytes * Y_SIZE]);
size_t bufLen = nonZeroRowBytes * Y_SIZE;
std::unique_ptr<uint8_t[]> readback(new uint8_t[bufLen]);
// clear readback to something non-zero so we can detect readback failures
memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
memset(readback.get(), kClearValue, bufLen);
// read the texture back
result = sContext->readPixels(ii, readback.get(), rowBytes, 0, 0);
@ -99,7 +106,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
SkString msg;
msg.printf("rb:%d A8", SkToU32(rowBytes));
validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes,
alphaData, msg);
alphaData, msg, kAlpha_8_GrPixelConfig);
// Now try writing to a single channel surface (if we could create one).
if (surf) {
@ -113,7 +120,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
canvas->drawRect(rect, paint);
memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
// Workaround for a bug in old GCC/glibc used in our Chromecast toolchain:
// error: call to '__warn_memset_zero_len' declared with attribute warning:
// memset used with constant zero length parameter; this could be due
// to transposed parameters
// See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294
if (bufLen > 0) {
memset(readback.get(), kClearValue, bufLen);
}
result = surf->readPixels(ii, readback.get(), nonZeroRowBytes, 0, 0);
REPORTER_ASSERT(reporter, result, "A8 readPixels after clear failed");
@ -136,7 +150,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
static const GrPixelConfig kRGBAConfigs[] {
kRGBA_8888_GrPixelConfig,
kBGRA_8888_GrPixelConfig,
kSRGBA_8888_GrPixelConfig
kSRGBA_8888_GrPixelConfig,
kRGBA_1010102_GrPixelConfig,
};
for (int y = 0; y < Y_SIZE; ++y) {
@ -200,7 +215,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
SkString msg;
msg.printf("rt:%d, rb:%d 8888", rt, SkToU32(rowBytes));
validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes,
alphaData, msg);
alphaData, msg, config);
}
}
}

View File

@ -80,12 +80,15 @@ DEF_TEST(SpecialSurface_Raster2, reporter) {
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu1, reporter, ctxInfo) {
sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.grContext(),
kSmallerSize, kSmallerSize,
kRGBA_8888_GrPixelConfig,
nullptr));
test_surface(surf, reporter, 0);
for (auto config : { kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) {
if (!ctxInfo.grContext()->caps()->isConfigRenderable(config)) {
continue;
}
sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.grContext(),
kSmallerSize, kSmallerSize,
config, nullptr));
test_surface(surf, reporter, 0);
}
}
#endif

View File

@ -932,6 +932,7 @@ static void test_surface_creation_and_snapshot_with_color_space(
skiatest::Reporter* reporter,
const char* prefix,
bool f16Support,
bool supports1010102,
std::function<sk_sp<SkSurface>(const SkImageInfo&)> surfaceMaker) {
auto srgbColorSpace = SkColorSpace::MakeSRGB();
@ -960,6 +961,7 @@ static void test_surface_creation_and_snapshot_with_color_space(
{ kRGBA_F16_SkColorType, oddColorSpace, false, "F16-odd" },
{ kRGB_565_SkColorType, srgbColorSpace, false, "565-srgb" },
{ kAlpha_8_SkColorType, srgbColorSpace, false, "A8-srgb" },
{ kRGBA_1010102_SkColorType, nullptr, true, "1010102-nullptr" },
};
for (auto& testConfig : testConfigs) {
@ -970,7 +972,8 @@ static void test_surface_creation_and_snapshot_with_color_space(
// For some GPU contexts (eg ANGLE), we don't have f16 support, so we should fail to create
// any surface of that type:
bool shouldWork = testConfig.fShouldWork &&
(f16Support || kRGBA_F16_SkColorType != testConfig.fColorType);
(f16Support || kRGBA_F16_SkColorType != testConfig.fColorType) &&
(supports1010102 || kRGBA_1010102_SkColorType != testConfig.fColorType);
auto surface(surfaceMaker(info));
REPORTER_ASSERT(reporter, SkToBool(surface) == shouldWork, fullTestName.c_str());
@ -990,7 +993,8 @@ DEF_TEST(SurfaceCreationWithColorSpace, reporter) {
return SkSurface::MakeRaster(info);
};
test_surface_creation_and_snapshot_with_color_space(reporter, "raster", true, surfaceMaker);
test_surface_creation_and_snapshot_with_color_space(reporter, "raster", true, true,
surfaceMaker);
}
#if SK_SUPPORT_GPU
@ -998,11 +1002,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter,
GrContext* context = ctxInfo.grContext();
bool f16Support = context->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig);
bool supports1010102 = context->caps()->isConfigRenderable(kRGBA_1010102_GrPixelConfig);
auto surfaceMaker = [context](const SkImageInfo& info) {
return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
};
test_surface_creation_and_snapshot_with_color_space(reporter, "gpu", f16Support, surfaceMaker);
test_surface_creation_and_snapshot_with_color_space(reporter, "gpu", f16Support,
supports1010102, surfaceMaker);
std::vector<GrBackendTexture> backendTextures;
auto wrappedSurfaceMaker = [ context, &backendTextures ](const SkImageInfo& info) {
@ -1028,7 +1034,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter,
};
test_surface_creation_and_snapshot_with_color_space(reporter, "wrapped", f16Support,
wrappedSurfaceMaker);
supports1010102, wrappedSurfaceMaker);
context->flush();

View File

@ -110,7 +110,8 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
"mtl",
"gl4444",
"gl565",
"gltestthreading"
"gltestthreading",
"gl1010102",
});
SkCommandLineConfigArray configs;
@ -200,6 +201,9 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
REPORTER_ASSERT(reporter, configs[35]->asConfigGpu()->getAlphaType() == kOpaque_SkAlphaType);
REPORTER_ASSERT(reporter, configs[36]->asConfigGpu());
REPORTER_ASSERT(reporter, configs[36]->asConfigGpu()->getTestThreading());
REPORTER_ASSERT(reporter, configs[37]->asConfigGpu());
REPORTER_ASSERT(reporter, configs[37]->asConfigGpu()->getColorType() ==
kRGBA_1010102_SkColorType);
#endif
}

View File

@ -46,9 +46,11 @@ static const struct {
{ "gl4444", "gpu", "api=gl,color=4444" },
{ "gl565", "gpu", "api=gl,color=565" },
{ "glf16", "gpu", "api=gl,color=f16" },
{ "gl1010102", "gpu", "api=gl,color=1010102" },
{ "glsrgb", "gpu", "api=gl,color=srgb" },
{ "glsrgbnl", "gpu", "api=gl,color=srgbnl" },
{ "glesf16", "gpu", "api=gles,color=f16" },
{ "gles1010102", "gpu", "api=gles,color=1010102" },
{ "glessrgb", "gpu", "api=gles,color=srgb" },
{ "glessrgbnl", "gpu", "api=gles,color=srgbnl" },
{ "glsrgb", "gpu", "api=gl,color=srgb" },
@ -77,6 +79,7 @@ static const struct {
{ "mock", "gpu", "api=mock" }
#ifdef SK_VULKAN
,{ "vk", "gpu", "api=vulkan" }
,{ "vk1010102", "gpu", "api=vulkan,color=1010102" }
,{ "vksrgb", "gpu", "api=vulkan,color=srgb" }
,{ "vkwide", "gpu", "api=vulkan,color=f16_wide" }
,{ "vkmsaa4", "gpu", "api=vulkan,samples=4" }
@ -84,6 +87,7 @@ static const struct {
#endif
#ifdef SK_METAL
,{ "mtl", "gpu", "api=metal" }
,{ "mtl1010102", "gpu", "api=metal,color=1010102" }
,{ "mtlsrgb", "gpu", "api=metal,color=srgb" }
,{ "mtlwide", "gpu", "api=metal,color=f16_wide" }
,{ "mtlmsaa4", "gpu", "api=metal,samples=4" }
@ -140,6 +144,7 @@ static const char configExtendedHelp[] =
"\t\t4444\t\t\tLinear 4444.\n"
"\t\t565\t\t\tLinear 565.\n"
"\t\tf16{_gamut}\t\tLinear 16-bit floating point.\n"
"\t\t1010102\t\tLinear 1010102.\n"
"\t\tsrgb{_gamut}\t\tsRGB 8888.\n"
"\t gamut\ttype: string\tdefault: srgb.\n"
"\t Select color gamut for f16 or sRGB format buffers.\n"
@ -321,6 +326,10 @@ static bool parse_option_gpu_color(const SkString& value,
*alphaType = kOpaque_SkAlphaType;
*outColorSpace = nullptr;
return true;
} else if (value.equals("1010102")) {
*outColorType = kRGBA_1010102_SkColorType;
*outColorSpace = nullptr;
return true;
}
SkTArray<SkString> commands;