Add Ganesh support for LUM16F (take 2)
When Chrome has a LUM16F texture they tell Skia it is R16F. Although this has been working for them so far it causes trouble with some upcoming changes. Change-Id: I2473f70e4f725128f143c2dfb08adb79f3c7c166 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/228565 Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
7c01208e78
commit
ebab03ffbf
@ -36,8 +36,9 @@ enum class GrGLFormat {
|
||||
kRG16,
|
||||
kRGBA16,
|
||||
kRG16F,
|
||||
kLUMINANCE16F,
|
||||
|
||||
kLast = kRG16F
|
||||
kLast = kLUMINANCE16F
|
||||
};
|
||||
|
||||
static constexpr int kGrGLFormatCount = static_cast<int>(GrGLFormat::kLast) + 1;
|
||||
|
@ -55,6 +55,7 @@ enum GrPixelConfig {
|
||||
kRGBA_1010102_GrPixelConfig,
|
||||
kRGBA_float_GrPixelConfig,
|
||||
kAlpha_half_GrPixelConfig,
|
||||
kAlpha_half_as_Lum_GrPixelConfig,
|
||||
kAlpha_half_as_Red_GrPixelConfig,
|
||||
kRGBA_half_GrPixelConfig,
|
||||
kRGBA_half_Clamped_GrPixelConfig,
|
||||
@ -856,6 +857,7 @@ static constexpr bool GrPixelConfigIsSRGB(GrPixelConfig config) {
|
||||
case kRGBA_1010102_GrPixelConfig:
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
case kRGBA_half_Clamped_GrPixelConfig:
|
||||
@ -890,6 +892,7 @@ static constexpr size_t GrBytesPerPixel(GrPixelConfig config) {
|
||||
case kRGBA_4444_GrPixelConfig:
|
||||
case kRG_88_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kR_16_GrPixelConfig:
|
||||
return 2;
|
||||
@ -938,6 +941,7 @@ static constexpr bool GrPixelConfigIsOpaque(GrPixelConfig config) {
|
||||
case kAlpha_8_as_Red_GrPixelConfig:
|
||||
case kRGBA_4444_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_8888_GrPixelConfig:
|
||||
case kBGRA_8888_GrPixelConfig:
|
||||
@ -959,6 +963,7 @@ static constexpr bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) {
|
||||
case kAlpha_8_as_Alpha_GrPixelConfig:
|
||||
case kAlpha_8_as_Red_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
return true;
|
||||
case kUnknown_GrPixelConfig:
|
||||
@ -1013,6 +1018,7 @@ static constexpr bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
|
||||
return false;
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
case kRGBA_half_Clamped_GrPixelConfig:
|
||||
@ -1103,6 +1109,7 @@ static constexpr GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) {
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
return kHigh_GrSLPrecision;
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
case kRGBA_half_Clamped_GrPixelConfig:
|
||||
@ -1458,6 +1465,7 @@ static constexpr GrColorType GrPixelConfigToColorType(GrPixelConfig config) {
|
||||
return GrColorType::kAlpha_8;
|
||||
case kAlpha_8_as_Red_GrPixelConfig:
|
||||
return GrColorType::kAlpha_8;
|
||||
case kAlpha_half_as_Lum_GrPixelConfig: // fall through
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
return GrColorType::kAlpha_F16;
|
||||
case kGray_8_as_Lum_GrPixelConfig:
|
||||
|
@ -153,6 +153,7 @@ static const char* pixel_config_name(GrPixelConfig config) {
|
||||
case kRGBA_1010102_GrPixelConfig: return "RGBA1010102";
|
||||
case kRGBA_float_GrPixelConfig: return "RGBAFloat";
|
||||
case kAlpha_half_GrPixelConfig: return "AlphaHalf";
|
||||
case kAlpha_half_as_Lum_GrPixelConfig: return "AlphaHalf_asLum";
|
||||
case kAlpha_half_as_Red_GrPixelConfig: return "AlphaHalf_asRed";
|
||||
case kRGBA_half_GrPixelConfig: return "RGBAHalf";
|
||||
case kRGBA_half_Clamped_GrPixelConfig: return "RGBAHalfClamped";
|
||||
@ -398,7 +399,8 @@ bool GrCaps::AreConfigsCompatible(GrPixelConfig genericConfig, GrPixelConfig spe
|
||||
break;
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
compatible = kAlpha_half_GrPixelConfig == specificConfig || // bc of the mock context
|
||||
kAlpha_half_as_Red_GrPixelConfig == specificConfig;
|
||||
kAlpha_half_as_Red_GrPixelConfig == specificConfig ||
|
||||
kAlpha_half_as_Lum_GrPixelConfig == specificConfig;
|
||||
break;
|
||||
case kRGB_888_GrPixelConfig:
|
||||
compatible = kRGB_888_GrPixelConfig == specificConfig ||
|
||||
|
@ -235,6 +235,7 @@ static bool fill_buffer_with_color(GrPixelConfig config, int width, int height,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kAlpha_half_as_Lum_GrPixelConfig: // fall through
|
||||
case kAlpha_half_as_Red_GrPixelConfig: // fall through
|
||||
case kAlpha_half_GrPixelConfig: {
|
||||
SkHalf alphaHalf = SkFloatToHalf(colorf.fA);
|
||||
|
@ -1374,6 +1374,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
||||
uint32_t fpRenderFlags = (GR_IS_GR_GL(standard)) ? msaaRenderFlags : nonMSAARenderFlags;
|
||||
|
||||
if (GR_IS_GR_GL(standard)) {
|
||||
// TODO: it seems like GL_ARB_texture_float GL_ARB_color_buffer_float should be taken
|
||||
// into account here
|
||||
if (version >= GR_GL_VER(3, 0)) {
|
||||
hasFP16Textures = true;
|
||||
halfFPRenderTargetSupport = HalfFPRenderTargetSupport::kAll;
|
||||
@ -1839,6 +1841,67 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
||||
}
|
||||
}
|
||||
|
||||
// LUMINANCE16F
|
||||
{
|
||||
// NOTE: We disallow lum16f on ES devices if linear filtering modes are not
|
||||
// supported. This is for simplicity, but a more granular approach is possible.
|
||||
bool lum16FSupported = false;
|
||||
|
||||
if (GR_IS_GR_GL(standard)) {
|
||||
if (version >= GR_GL_VER(3, 0)) {
|
||||
lum16FSupported = true;
|
||||
} else if (ctxInfo.hasExtension("GL_ARB_texture_float")) {
|
||||
lum16FSupported = true;
|
||||
}
|
||||
} else if (GR_IS_GR_GL_ES(standard)) {
|
||||
if (version >= GR_GL_VER(3, 0)) {
|
||||
lum16FSupported = true;
|
||||
} else if (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
|
||||
ctxInfo.hasExtension("GL_OES_texture_float")) {
|
||||
lum16FSupported = true;
|
||||
} else if (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
|
||||
ctxInfo.hasExtension("GL_OES_texture_half_float")) {
|
||||
lum16FSupported = true;
|
||||
}
|
||||
} // No WebGL support
|
||||
|
||||
if (formatWorkarounds.fDisableLuminance16F) {
|
||||
lum16FSupported = false;
|
||||
}
|
||||
|
||||
FormatInfo& info = this->getFormatInfo(GrGLFormat::kLUMINANCE16F);
|
||||
info.fFormatType = FormatType::kFloat;
|
||||
info.fBaseInternalFormat = GR_GL_LUMINANCE;
|
||||
info.fSizedInternalFormat = GR_GL_LUMINANCE16F;
|
||||
info.fInternalFormatForTexImage =
|
||||
texImageSupportsSizedInternalFormat ? GR_GL_LUMINANCE16F : GR_GL_LUMINANCE;
|
||||
info.fInternalFormatForRenderbuffer =
|
||||
renderbufferStorageSupportsSizedInternalFormat ? GR_GL_LUMINANCE16F
|
||||
: GR_GL_LUMINANCE;
|
||||
info.fDefaultExternalType = halfFloatType;
|
||||
|
||||
if (lum16FSupported) {
|
||||
info.fFlags = FormatInfo::kTextureable_Flag;
|
||||
}
|
||||
if (texStorageSupported &&
|
||||
!formatWorkarounds.fDisablePerFormatTextureStorageForCommandBufferES2) {
|
||||
info.fFlags |= FormatInfo::kCanUseTexStorage_Flag;
|
||||
}
|
||||
|
||||
if (lum16FSupported) {
|
||||
// kAlpha_F16
|
||||
{
|
||||
uint32_t flags = ColorTypeInfo::kUploadData_Flag;
|
||||
info.fColorTypeInfos.emplace_back(GrColorType::kAlpha_F16, flags);
|
||||
|
||||
int idx = static_cast<int>(GrColorType::kAlpha_F16);
|
||||
if (fColorTypeToFormatTable[idx] == GrGLFormat::kUnknown) {
|
||||
this->setColorTypeFormat(GrColorType::kAlpha_F16, GrGLFormat::kLUMINANCE16F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RGB8
|
||||
{
|
||||
FormatInfo& info = this->getFormatInfo(GrGLFormat::kRGB8);
|
||||
@ -2461,17 +2524,38 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
|
||||
rgbaF32Info.fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] = GR_GL_RGBA;
|
||||
rgbaF32Info.fFormats.fExternalType = GR_GL_FLOAT;
|
||||
|
||||
GrGLenum redHalfExternalType;
|
||||
if (GR_IS_GR_GL(standard) ||
|
||||
(GR_IS_GR_GL_ES(standard) && version >= GR_GL_VER(3, 0))) {
|
||||
redHalfExternalType = GR_GL_HALF_FLOAT;
|
||||
} else {
|
||||
redHalfExternalType = GR_GL_HALF_FLOAT_OES;
|
||||
// single channel half formats
|
||||
{
|
||||
GrGLenum halfExternalType;
|
||||
if (GR_IS_GR_GL(standard) ||
|
||||
(GR_IS_GR_GL_ES(standard) && version >= GR_GL_VER(3, 0))) {
|
||||
halfExternalType = GR_GL_HALF_FLOAT;
|
||||
} else {
|
||||
halfExternalType = GR_GL_HALF_FLOAT_OES;
|
||||
}
|
||||
|
||||
// RED16F
|
||||
{
|
||||
ConfigInfo& redHalf = fConfigTable[kAlpha_half_as_Red_GrPixelConfig];
|
||||
redHalf.fFormats.fExternalType = halfExternalType;
|
||||
redHalf.fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] = GR_GL_RED;
|
||||
|
||||
if (textureRedSupport) {
|
||||
fConfigTable[kAlpha_half_GrPixelConfig] = redHalf;
|
||||
}
|
||||
}
|
||||
|
||||
// LUM16F
|
||||
{
|
||||
ConfigInfo& lumHalf = fConfigTable[kAlpha_half_as_Lum_GrPixelConfig];
|
||||
lumHalf.fFormats.fExternalType = halfExternalType;
|
||||
lumHalf.fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] = GR_GL_LUMINANCE;
|
||||
|
||||
if (!textureRedSupport) {
|
||||
fConfigTable[kAlpha_half_GrPixelConfig] = lumHalf;
|
||||
}
|
||||
}
|
||||
}
|
||||
ConfigInfo& redHalf = fConfigTable[kAlpha_half_as_Red_GrPixelConfig];
|
||||
redHalf.fFormats.fExternalType = redHalfExternalType;
|
||||
redHalf.fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] = GR_GL_RED;
|
||||
fConfigTable[kAlpha_half_GrPixelConfig] = redHalf;
|
||||
|
||||
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat[kReadPixels_ExternalFormatUsage] =
|
||||
GR_GL_RGBA;
|
||||
@ -3225,6 +3309,11 @@ void GrGLCaps::applyDriverCorrectnessWorkarounds(const GrGLContextInfo& ctxInfo,
|
||||
|
||||
// Mali-400 fails ReadPixels tests, mostly with non-0xFF alpha values when read as GL_RGBA8.
|
||||
formatWorkarounds->fDisableRGB8ForMali400 = kMali4xx_GrGLRenderer == ctxInfo.renderer();
|
||||
|
||||
// On the Intel Iris 6100, interacting with LUM16F seems to confuse the driver. After
|
||||
// writing to/reading from a LUM16F texture reads from/writes to other formats behave
|
||||
// erratically.
|
||||
formatWorkarounds->fDisableLuminance16F = kIntelBroadwell_GrGLRenderer == ctxInfo.renderer();
|
||||
}
|
||||
|
||||
void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {
|
||||
@ -3411,6 +3500,8 @@ GrGLFormat GrGLCaps::pixelConfigToFormat(GrPixelConfig config) const {
|
||||
return GrGLFormat::kLUMINANCE8;
|
||||
case kGray_8_as_Red_GrPixelConfig:
|
||||
return GrGLFormat::kR8;
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
return GrGLFormat::kLUMINANCE16F;
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
return GrGLFormat::kR16F;
|
||||
case kRGB_ETC1_GrPixelConfig: {
|
||||
@ -3512,7 +3603,9 @@ static GrPixelConfig validate_sized_format(GrGLenum format, GrColorType ct, GrGL
|
||||
}
|
||||
break;
|
||||
case GrColorType::kAlpha_F16:
|
||||
if (GR_GL_R16F == format) {
|
||||
if (GR_GL_LUMINANCE16F == format) {
|
||||
return kAlpha_half_as_Lum_GrPixelConfig;
|
||||
} else if (GR_GL_R16F == format) {
|
||||
return kAlpha_half_as_Red_GrPixelConfig;
|
||||
}
|
||||
break;
|
||||
@ -3610,6 +3703,9 @@ static GrPixelConfig get_yuva_config(GrGLenum format) {
|
||||
case GR_GL_RGB10_A2:
|
||||
config = kRGBA_1010102_GrPixelConfig;
|
||||
break;
|
||||
case GR_GL_LUMINANCE16F:
|
||||
config = kAlpha_half_as_Lum_GrPixelConfig;
|
||||
break;
|
||||
case GR_GL_R16F:
|
||||
config = kAlpha_half_as_Red_GrPixelConfig;
|
||||
break;
|
||||
@ -3688,7 +3784,7 @@ static bool format_color_type_valid_pair(GrGLenum format, GrColorType colorType)
|
||||
case GrColorType::kGray_8:
|
||||
return GR_GL_LUMINANCE8 == format || GR_GL_R8 == format;
|
||||
case GrColorType::kAlpha_F16:
|
||||
return GR_GL_R16F == format;
|
||||
return GR_GL_R16F == format || GR_GL_LUMINANCE16F == format;
|
||||
case GrColorType::kRGBA_F16:
|
||||
return GR_GL_RGBA16F == format;
|
||||
case GrColorType::kRGBA_F16_Clamped:
|
||||
@ -3736,12 +3832,13 @@ static GrSwizzle get_swizzle(const GrBackendFormat& format, GrColorType colorTyp
|
||||
}
|
||||
break;
|
||||
case GrColorType::kAlpha_F16:
|
||||
SkASSERT(glFormat == GR_GL_R16F);
|
||||
SkASSERT(glFormat == GR_GL_R16F || glFormat == GR_GL_LUMINANCE16F);
|
||||
if (forOutput) {
|
||||
return GrSwizzle::AAAA();
|
||||
} else {
|
||||
return GrSwizzle::RRRR();
|
||||
}
|
||||
break;
|
||||
case GrColorType::kGray_8:
|
||||
if (glFormat == GR_GL_R8) {
|
||||
if (!forOutput) {
|
||||
@ -3753,9 +3850,11 @@ static GrSwizzle get_swizzle(const GrBackendFormat& format, GrColorType colorTyp
|
||||
if (!forOutput) {
|
||||
return GrSwizzle::RGB1();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return GrSwizzle::RGBA();
|
||||
}
|
||||
|
||||
return GrSwizzle::RGBA();
|
||||
}
|
||||
|
||||
|
@ -481,6 +481,7 @@ private:
|
||||
bool fDisableNonRedSingleChannelTexStorageForANGLEGL = false;
|
||||
bool fDisableBGRATextureStorageForIntelWindowsES = false;
|
||||
bool fDisableRGB8ForMali400 = false;
|
||||
bool fDisableLuminance16F = false;
|
||||
};
|
||||
|
||||
void applyDriverCorrectnessWorkarounds(const GrGLContextInfo&, const GrContextOptions&,
|
||||
|
@ -461,6 +461,7 @@
|
||||
|
||||
/* Luminance sized formats */
|
||||
#define GR_GL_LUMINANCE8 0x8040
|
||||
#define GR_GL_LUMINANCE16F 0x881E
|
||||
|
||||
/* Alpha sized formats */
|
||||
#define GR_GL_ALPHA8 0x803C
|
||||
|
@ -875,6 +875,7 @@ static inline GrGLint config_alignment(GrPixelConfig config) {
|
||||
case kRGBA_4444_GrPixelConfig:
|
||||
case kRG_88_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
case kRGBA_half_Clamped_GrPixelConfig:
|
||||
@ -3750,7 +3751,6 @@ static GrPixelConfig gl_format_to_pixel_config(GrGLFormat format) {
|
||||
case GrGLFormat::kRGBA4: return kRGBA_4444_GrPixelConfig;
|
||||
case GrGLFormat::kRGBA32F: return kRGBA_float_GrPixelConfig;
|
||||
case GrGLFormat::kRGBA16F: return kRGBA_half_GrPixelConfig;
|
||||
case GrGLFormat::kR16F: return kAlpha_half_GrPixelConfig;
|
||||
case GrGLFormat::kR16: return kR_16_GrPixelConfig;
|
||||
case GrGLFormat::kRG16: return kRG_1616_GrPixelConfig;
|
||||
case GrGLFormat::kRGBA16: return kRGBA_16161616_GrPixelConfig;
|
||||
@ -3759,6 +3759,9 @@ static GrPixelConfig gl_format_to_pixel_config(GrGLFormat format) {
|
||||
|
||||
// Configs with multiple equivalent formats.
|
||||
|
||||
case GrGLFormat::kR16F: return kAlpha_half_GrPixelConfig;
|
||||
case GrGLFormat::kLUMINANCE16F: return kAlpha_half_GrPixelConfig;
|
||||
|
||||
case GrGLFormat::kALPHA8: return kAlpha_8_GrPixelConfig;
|
||||
case GrGLFormat::kR8: return kAlpha_8_GrPixelConfig;
|
||||
|
||||
|
@ -608,6 +608,7 @@ bool GrGLFormatIsCompressed(GrGLFormat format) {
|
||||
case GrGLFormat::kRGB565:
|
||||
case GrGLFormat::kRGBA16F:
|
||||
case GrGLFormat::kR16F:
|
||||
case GrGLFormat::kLUMINANCE16F:
|
||||
case GrGLFormat::kRGB8:
|
||||
case GrGLFormat::kRG8:
|
||||
case GrGLFormat::kRGB10_A2:
|
||||
@ -639,6 +640,7 @@ bool GrGLFormatToCompressionType(GrGLFormat format, SkImage::CompressionType* co
|
||||
case GrGLFormat::kRGB565:
|
||||
case GrGLFormat::kRGBA16F:
|
||||
case GrGLFormat::kR16F:
|
||||
case GrGLFormat::kLUMINANCE16F:
|
||||
case GrGLFormat::kRGB8:
|
||||
case GrGLFormat::kRG8:
|
||||
case GrGLFormat::kRGB10_A2:
|
||||
@ -666,6 +668,7 @@ size_t GrGLBytesPerFormat(GrGLFormat glFormat) {
|
||||
case GrGLFormat::kRGBA4:
|
||||
case GrGLFormat::kRG8:
|
||||
case GrGLFormat::kR16F:
|
||||
case GrGLFormat::kLUMINANCE16F:
|
||||
case GrGLFormat::kR16:
|
||||
return 2;
|
||||
|
||||
|
@ -283,6 +283,7 @@ static constexpr GrGLFormat GrGLFormatFromGLEnum(GrGLenum glFormat) {
|
||||
case GR_GL_BGRA8: return GrGLFormat::kBGRA8;
|
||||
case GR_GL_RGB565: return GrGLFormat::kRGB565;
|
||||
case GR_GL_RGBA16F: return GrGLFormat::kRGBA16F;
|
||||
case GR_GL_LUMINANCE16F: return GrGLFormat::kLUMINANCE16F;
|
||||
case GR_GL_R16F: return GrGLFormat::kR16F;
|
||||
case GR_GL_RGB8: return GrGLFormat::kRGB8;
|
||||
case GR_GL_RG8: return GrGLFormat::kRG8;
|
||||
|
@ -91,6 +91,8 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
*format = MTLPixelFormatR16Float;
|
||||
return true;
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
return false;
|
||||
case kRGB_ETC1_GrPixelConfig:
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
*format = MTLPixelFormatETC2_RGB8;
|
||||
|
@ -93,6 +93,7 @@ static int get_compatible_format_class(GrPixelConfig config) {
|
||||
case kUnknown_GrPixelConfig:
|
||||
case kAlpha_8_as_Alpha_GrPixelConfig:
|
||||
case kGray_8_as_Lum_GrPixelConfig:
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
SK_ABORT("Unsupported Vulkan pixel config");
|
||||
return 0;
|
||||
|
||||
|
@ -77,6 +77,8 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
*format = VK_FORMAT_R16_SFLOAT;
|
||||
return true;
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
return false;
|
||||
case kR_16_GrPixelConfig:
|
||||
*format = VK_FORMAT_R16_UNORM;
|
||||
return true;
|
||||
|
@ -1143,18 +1143,19 @@ void GLSLCodeGenerator::writeModifiers(const Modifiers& modifiers,
|
||||
switch (modifiers.fLayout.fFormat) {
|
||||
case Layout::Format::kUnspecified:
|
||||
break;
|
||||
case Layout::Format::kRGBA32F: // fall through
|
||||
case Layout::Format::kRGBA32F: // fall through
|
||||
case Layout::Format::kR32F:
|
||||
this->write("highp ");
|
||||
break;
|
||||
case Layout::Format::kRGBA16F: // fall through
|
||||
case Layout::Format::kR16F: // fall through
|
||||
case Layout::Format::kRGBA16F: // fall through
|
||||
case Layout::Format::kR16F: // fall through
|
||||
case Layout::Format::kLUMINANCE16F: // fall through
|
||||
case Layout::Format::kRG16F:
|
||||
this->write("mediump ");
|
||||
break;
|
||||
case Layout::Format::kRGBA8: // fall through
|
||||
case Layout::Format::kR8: // fall through
|
||||
case Layout::Format::kRGBA8I: // fall through
|
||||
case Layout::Format::kRGBA8: // fall through
|
||||
case Layout::Format::kR8: // fall through
|
||||
case Layout::Format::kRGBA8I: // fall through
|
||||
case Layout::Format::kR8I:
|
||||
this->write("lowp ");
|
||||
break;
|
||||
|
@ -60,6 +60,7 @@ struct Layout {
|
||||
kR32F,
|
||||
kRGBA16F,
|
||||
kR16F,
|
||||
kLUMINANCE16F,
|
||||
kRGBA8,
|
||||
kR8,
|
||||
kRGBA8I,
|
||||
@ -102,6 +103,7 @@ struct Layout {
|
||||
case Format::kR32F: return "r32f";
|
||||
case Format::kRGBA16F: return "rgba16f";
|
||||
case Format::kR16F: return "r16f";
|
||||
case Format::kLUMINANCE16F: return "lum16f";
|
||||
case Format::kRGBA8: return "rgba8";
|
||||
case Format::kR8: return "r8";
|
||||
case Format::kRGBA8I: return "rgba8i";
|
||||
@ -124,6 +126,9 @@ struct Layout {
|
||||
} else if (str == "r16f") {
|
||||
*format = Format::kR16F;
|
||||
return true;
|
||||
} else if (str == "lum16f") {
|
||||
*format = Format::kLUMINANCE16F;
|
||||
return true;
|
||||
} else if (str == "rgba8") {
|
||||
*format = Format::kRGBA8;
|
||||
return true;
|
||||
|
@ -558,6 +558,8 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
|
||||
kRG_88_GrPixelConfig, { 0.5f, 0.5f, 0, 0 }},
|
||||
{ kUnknown_SkColorType, GR_GL_R16F,
|
||||
kAlpha_half_as_Red_GrPixelConfig, { 1.0f, 0, 0, 0.5f }},
|
||||
{ kUnknown_SkColorType, GR_GL_LUMINANCE16F,
|
||||
kAlpha_half_as_Lum_GrPixelConfig, kGrayCol },
|
||||
{ kUnknown_SkColorType, GR_GL_COMPRESSED_RGB8_ETC2,
|
||||
kRGB_ETC1_GrPixelConfig, SkColors::kRed },
|
||||
{ kUnknown_SkColorType, GR_GL_COMPRESSED_ETC1_RGB8,
|
||||
|
@ -130,7 +130,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
|
||||
config == kAlpha_8_as_Red_GrPixelConfig ||
|
||||
config == kGray_8_as_Lum_GrPixelConfig ||
|
||||
config == kGray_8_as_Red_GrPixelConfig ||
|
||||
config == kAlpha_half_as_Red_GrPixelConfig) {
|
||||
config == kAlpha_half_as_Red_GrPixelConfig ||
|
||||
config == kAlpha_half_as_Lum_GrPixelConfig) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -240,7 +241,8 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
|
||||
uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0;
|
||||
for (int i = 0; i < kSize * kSize; ++i) {
|
||||
if (cmp != data.get()[i]) {
|
||||
ERRORF(reporter, "Failed on config %d", desc.fConfig);
|
||||
ERRORF(reporter, "Failed on conf %d (pix %d) 0x%x != 0x%x",
|
||||
desc.fConfig, i, cmp, data.get()[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -262,7 +264,8 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
|
||||
if (GrBackendApi::kOpenGL == context->backend() &&
|
||||
(desc.fConfig == kAlpha_8_as_Alpha_GrPixelConfig ||
|
||||
desc.fConfig == kAlpha_8_as_Red_GrPixelConfig ||
|
||||
desc.fConfig == kAlpha_half_as_Red_GrPixelConfig)) {
|
||||
desc.fConfig == kAlpha_half_as_Red_GrPixelConfig ||
|
||||
desc.fConfig == kAlpha_half_as_Lum_GrPixelConfig)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -300,7 +303,8 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
|
||||
uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0;
|
||||
for (int i = 0; i < kSize * kSize; ++i) {
|
||||
if (cmp != data.get()[i]) {
|
||||
ERRORF(reporter, "Failed on config %d", desc.fConfig);
|
||||
ERRORF(reporter, "Failed on conf %d (pix %d) 0x%x != 0x%x",
|
||||
desc.fConfig, i, cmp, data.get()[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user