From f2956459f707de596dcb2c79a7ee1fa62d599c0d Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Mon, 9 Jan 2017 15:32:57 -0500 Subject: Add Gray8 pixel config This is still just linear (non-sRGB), but adding sRGB will be the next step. I've verified that this is really making R8 textures when uploading Gray8 bitmaps. Tests pass, and the all_bitmap_configs GM still renders correctly (unlike when we just mapped Gray8 to Alpha8). This adds another pixel config, which could grow our cache footprint, but the benefits of not using 4bpp for 1bpp data should outweigh that? BUG=skia:6110 Change-Id: I4fc4c2479fc25f1d278e174a9bb5b542a0cb184c Reviewed-on: https://skia-review.googlesource.com/6817 Reviewed-by: Brian Salomon Commit-Queue: Brian Osman --- src/gpu/gl/GrGLCaps.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/gpu/gl/GrGLCaps.cpp') diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index d3adc28d4c..bd9380cd20 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -1756,6 +1756,39 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag; } + if (this->textureRedSupport()) { + fConfigTable[kGray_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED; + fConfigTable[kGray_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R8; + fConfigTable[kGray_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = + GR_GL_RED; + fConfigTable[kGray_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRA(); + if (texelBufferSupport) { + fConfigTable[kGray_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag; + } + } else { + fConfigTable[kGray_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_LUMINANCE; + fConfigTable[kGray_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_LUMINANCE8; + fConfigTable[kGray_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = + GR_GL_LUMINANCE; + fConfigTable[kGray_8_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); + } + fConfigTable[kGray_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE; + fConfigTable[kGray_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType; + fConfigTable[kGray_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; +#if 0 // Leaving Gray8 as non-renderable, to keep things simple and match raster + if (this->textureRedSupport() || + (kDesktop_ARB_MSFBOType == this->msFBOType() && + ctxInfo.renderer() != kOSMesa_GrGLRenderer)) { + // desktop ARB extension/3.0+ supports LUMINANCE8 as renderable. + // However, osmesa fails if it used even when GL_ARB_framebuffer_object is present. + // Core profile removes LUMINANCE8 support, but we should have chosen R8 in that case. + fConfigTable[kGray_8_GrPixelConfig].fFlags |= allRenderFlags; + } +#endif + if (texStorageSupported) { + fConfigTable[kGray_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag; + } + // Check for [half] floating point texture support // NOTE: We disallow floating point textures on ES devices if linear filtering modes are not // supported. This is for simplicity, but a more granular approach is possible. Coincidentally, -- cgit v1.2.3