diff options
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 129 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 4 |
2 files changed, 85 insertions, 48 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 2212459e68..f245d0f551 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -1947,33 +1947,46 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, } fConfigTable[kRGBA_4444_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); - fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE; - fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType; - fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; + ConfigInfo& alphaInfo = fConfigTable[kAlpha_8_as_Alpha_GrPixelConfig]; + alphaInfo.fFormats.fExternalType = GR_GL_UNSIGNED_BYTE; + alphaInfo.fFormatType = kNormalizedFixedPoint_FormatType; + if (kGL_GrGLStandard== standard || version <= GR_GL_VER(3, 0)) { + alphaInfo.fFlags = ConfigInfo::kTextureable_Flag; + } + alphaInfo.fFormats.fBaseInternalFormat = GR_GL_ALPHA; + alphaInfo.fFormats.fSizedInternalFormat = GR_GL_ALPHA8; + alphaInfo.fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_ALPHA; + alphaInfo.fSwizzle = GrSwizzle::AAAA(); + if (fAlpha8IsRenderable && kGL_GrGLStandard== standard) { + alphaInfo.fFlags |= allRenderFlags; + } + + 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[kOther_ExternalFormatUsage] = GR_GL_RED; + redInfo.fSwizzle = GrSwizzle::RRRR(); + + // ES2 Command Buffer does not allow TexStorage with R8_EXT (so Alpha_8 and Gray_8) + if (texStorageSupported && !isCommandBufferES2) { + alphaInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag; + redInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag; + } + if (this->textureRedSupport()) { - fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED; - fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R8; - fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = - GR_GL_RED; - fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); + redInfo.fFlags = ConfigInfo::kTextureable_Flag; if (texelBufferSupport) { - fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag; + redInfo.fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag; } - fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags; + redInfo.fFlags |= allRenderFlags; + + fConfigTable[kAlpha_8_GrPixelConfig] = redInfo; } else { - fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ALPHA; - fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA8; - fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = - GR_GL_ALPHA; - fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::AAAA(); - if (fAlpha8IsRenderable) { - fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags; - } - } + redInfo.fFlags = 0; - // ES2 Command Buffer does not allow TexStorage with R8_EXT (so Alpha_8 and Gray_8) - if (texStorageSupported && !isCommandBufferES2) { - fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag; + fConfigTable[kAlpha_8_GrPixelConfig] = alphaInfo; } fConfigTable[kGray_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE; @@ -2068,44 +2081,60 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, fConfigTable[fpconfig].fSwizzle = GrSwizzle::RGBA(); } - if (this->textureRedSupport()) { - fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED; - fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F; - fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] - = GR_GL_RED; - fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); - if (texelBufferSupport) { - fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= - ConfigInfo::kCanUseWithTexelBuffer_Flag; - } - } else { - fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ALPHA; - fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F; - fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] - = GR_GL_ALPHA; - fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::AAAA(); - } - + GrGLenum alphaHalfExternalType; if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(3, 0)) { - fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT; + alphaHalfExternalType = GR_GL_HALF_FLOAT; } else { - fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT_OES; + alphaHalfExternalType = GR_GL_HALF_FLOAT_OES; } - fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType; + + ConfigInfo& alphaHalf = fConfigTable[kAlpha_half_as_Alpha_GrPixelConfig]; + alphaHalf.fFormats.fExternalType = alphaHalfExternalType; + alphaHalf.fFormatType = kFloat_FormatType; + alphaHalf.fFormats.fBaseInternalFormat = GR_GL_ALPHA; + alphaHalf.fFormats.fSizedInternalFormat = GR_GL_ALPHA16F; + alphaHalf.fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_ALPHA; + alphaHalf.fSwizzle = GrSwizzle::AAAA(); + + ConfigInfo& redHalf = fConfigTable[kAlpha_half_as_Red_GrPixelConfig]; + redHalf.fFormats.fExternalType = alphaHalfExternalType; + redHalf.fFormatType = kFloat_FormatType; + redHalf.fFormats.fBaseInternalFormat = GR_GL_RED; + redHalf.fFormats.fSizedInternalFormat = GR_GL_R16F; + redHalf.fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_RED; + redHalf.fSwizzle = GrSwizzle::RRRR(); + if (texStorageSupported) { - fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag; + alphaHalf.fFlags |= ConfigInfo::kCanUseTexStorage_Flag; + redHalf.fFlags |= ConfigInfo::kCanUseTexStorage_Flag; } if (hasHalfFPTextures) { - fConfigTable[kAlpha_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; - // ES requires either 3.2 or the combination of EXT_color_buffer_half_float and support for - // GL_RED internal format. + if (kGL_GrGLStandard == standard || version <= GR_GL_VER(3, 0)) { + alphaHalf.fFlags = ConfigInfo::kTextureable_Flag; + } + redHalf.fFlags = ConfigInfo::kTextureable_Flag; if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3, 2) || (this->textureRedSupport() && ctxInfo.hasExtension("GL_EXT_color_buffer_half_float"))) { - fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= fpRenderFlags; + if (kGL_GrGLStandard == standard) { + alphaHalf.fFlags |= fpRenderFlags; + } + redHalf.fFlags |= fpRenderFlags; } } + if (this->textureRedSupport()) { + if (texelBufferSupport) { + redHalf.fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag; + } + + fConfigTable[kAlpha_half_GrPixelConfig] = redHalf; + } else { + redHalf.fFlags = 0; + + fConfigTable[kAlpha_half_GrPixelConfig] = alphaHalf; + } + fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA; fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA16F; fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = @@ -2157,8 +2186,12 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, // kAlpha_8_GrPixelConfig. Alpha8 is not a valid signed internal format so we must use the base // internal format for that config when doing TexImage calls. if(kGalliumLLVM_GrGLRenderer == ctxInfo.renderer()) { + SkASSERT(fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat == + fConfigTable[kAlpha_8_as_Alpha_GrPixelConfig].fFormats.fBaseInternalFormat); fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fInternalFormatTexImage = fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat; + fConfigTable[kAlpha_8_as_Alpha_GrPixelConfig].fFormats.fInternalFormatTexImage = + fConfigTable[kAlpha_8_as_Alpha_GrPixelConfig].fFormats.fBaseInternalFormat; } // OpenGL ES 2.0 + GL_EXT_sRGB allows GL_SRGB_ALPHA to be specified as the <format> diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 3b39b20f0e..ad13516ce6 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -785,11 +785,15 @@ bool GrGLGpu::onWritePixels(GrSurface* surface, GrSurfaceOrigin origin, static inline GrGLint config_alignment(GrPixelConfig config) { switch (config) { case kAlpha_8_GrPixelConfig: + case kAlpha_8_as_Alpha_GrPixelConfig: + case kAlpha_8_as_Red_GrPixelConfig: case kGray_8_GrPixelConfig: return 1; case kRGB_565_GrPixelConfig: case kRGBA_4444_GrPixelConfig: case kAlpha_half_GrPixelConfig: + case kAlpha_half_as_Alpha_GrPixelConfig: + case kAlpha_half_as_Red_GrPixelConfig: case kRGBA_half_GrPixelConfig: return 2; case kRGBA_8888_GrPixelConfig: |