From a46f69bf6f3283c8ee71674617f3eb27ad905565 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Thu, 22 Jun 2017 13:52:50 -0400 Subject: [PATCH] [M60 cherry pick] Suppress rendererability of kAlpha8 GL_CHROMIUM_framebuffer_multisample for ANGLE D3D9 For ANGLE D3D9 ES2 we're seeing GL_CHROMIUM_framebuffer_multisample but not GL_ANGLE_framebuffer_multisample. The same occurs for ANGLE D3D11 ES2 but kAlpha8 is renderable in that case. TBR=bsalomon@google.com No-Tree-Checks: true No-Try: true No-Presubmit: true Bug: 730082 Change-Id: I2b1ca8da85428426ccdfd2c31d1aa0fd59acb8f9 Reviewed-on: https://skia-review.googlesource.com/20513 Reviewed-by: Ravi Mistry Reviewed-by: Brian Salomon Commit-Queue: Robert Phillips --- src/gpu/gl/GrGLCaps.cpp | 44 ++++++++++++++++++++++++++------------------ src/gpu/gl/GrGLCaps.h | 12 +++++++----- src/gpu/gl/GrGLGpu.cpp | 1 - 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 7a043af..5bdc702 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -33,6 +33,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, fPackFlipYSupport = false; fTextureUsageSupport = false; fTextureRedSupport = false; + fAlpha8IsRenderable = false; fImagingSupport = false; fVertexArrayObjectSupport = false; fDirectStateAccessSupport = false; @@ -1020,11 +1021,13 @@ void GrGLCaps::initFSAASupport(const GrContextOptions& contextOptions, const GrG fMSFBOType = kES_IMG_MsToTexture_MSFBOType; } else if (fUsesMixedSamples) { fMSFBOType = kMixedSamples_MSFBOType; - } else if (ctxInfo.version() >= GR_GL_VER(3,0) || - ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) { + } else if (ctxInfo.version() >= GR_GL_VER(3,0)) { + fMSFBOType = kStandard_MSFBOType; + fAlpha8IsRenderable = true; + } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) { fMSFBOType = kStandard_MSFBOType; } else if (ctxInfo.hasExtension("GL_ANGLE_framebuffer_multisample")) { - fMSFBOType = kEXT_MSFBOType; + fMSFBOType = kStandard_MSFBOType; } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) { fMSFBOType = kES_Apple_MSFBOType; } @@ -1033,10 +1036,18 @@ void GrGLCaps::initFSAASupport(const GrContextOptions& contextOptions, const GrG fMSFBOType = kMixedSamples_MSFBOType; } else if (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { + fMSFBOType = kStandard_MSFBOType; + if (!fIsCoreProfile && ctxInfo.renderer() != kOSMesa_GrGLRenderer) { + // Core profile removes ALPHA8 support. + // OpenGL 3.0+ (and GL_ARB_framebuffer_object) supports ALPHA8 as renderable. + // However, osmesa fails if it is used even when GL_ARB_framebuffer_object is + // present. + fAlpha8IsRenderable = true; + } } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") && ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) { - fMSFBOType = kEXT_MSFBOType; + fMSFBOType = kStandard_MSFBOType; } } @@ -1173,7 +1184,6 @@ SkString GrGLCaps::dump() const { static const char* kMSFBOExtStr[] = { "None", - "EXT", "Standard", "Apple", "IMG MS To Texture", @@ -1181,12 +1191,11 @@ SkString GrGLCaps::dump() const { "MixedSamples", }; GR_STATIC_ASSERT(0 == kNone_MSFBOType); - GR_STATIC_ASSERT(1 == kEXT_MSFBOType); - GR_STATIC_ASSERT(2 == kStandard_MSFBOType); - GR_STATIC_ASSERT(3 == kES_Apple_MSFBOType); - GR_STATIC_ASSERT(4 == kES_IMG_MsToTexture_MSFBOType); - GR_STATIC_ASSERT(5 == kES_EXT_MsToTexture_MSFBOType); - GR_STATIC_ASSERT(6 == kMixedSamples_MSFBOType); + GR_STATIC_ASSERT(1 == kStandard_MSFBOType); + GR_STATIC_ASSERT(2 == kES_Apple_MSFBOType); + GR_STATIC_ASSERT(3 == kES_IMG_MsToTexture_MSFBOType); + GR_STATIC_ASSERT(4 == kES_EXT_MsToTexture_MSFBOType); + GR_STATIC_ASSERT(5 == kMixedSamples_MSFBOType); GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1); static const char* kInvalidateFBTypeStr[] = { @@ -1223,6 +1232,7 @@ SkString GrGLCaps::dump() const { r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO")); r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); + r.appendf("Alpha8 is renderable: %s\n", (fAlpha8IsRenderable ? "YES" : "NO")); r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ? "YES": "NO")); @@ -1747,20 +1757,18 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, if (texelBufferSupport) { fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseWithTexelBuffer_Flag; } + fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags; } 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; + } } - if (this->textureRedSupport() || - (kStandard_MSFBOType == this->msFBOType() && ctxInfo.renderer() != kOSMesa_GrGLRenderer)) { - // OpenGL 3.0+ (and GL_ARB_framebuffer_object) supports ALPHA8 as renderable. - // However, osmesa fails if it used even when GL_ARB_framebuffer_object is present. - // Core profile removes ALPHA8 support, but we should have chosen R8 in that case. - fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags; - } + if (texStorageSupported) { fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag; } diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index b7273a0..f23d544 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -41,11 +41,9 @@ public: */ kNone_MSFBOType = 0, /** - * OpenGL < 3.0 with GL_EXT_framebuffer_object. Doesn't allow rendering to ALPHA. - */ - kEXT_MSFBOType, - /** - * OpenGL 3.0+, OpenGL ES 3.0+, and GL_ARB_framebuffer_object. + * OpenGL 3.0+, OpenGL ES 3.0+, GL_ARB_framebuffer_object, + * GL_CHROMIUM_framebuffer_multisample, GL_ANGLE_framebuffer_multisample, + * or GL_EXT_framebuffer_multisample */ kStandard_MSFBOType, /** @@ -285,6 +283,9 @@ public: /// Is there support for GL_RED and GL_R8 bool textureRedSupport() const { return fTextureRedSupport; } + /// Is GL_ALPHA8 renderable + bool alpha8IsRenderable() const { return fAlpha8IsRenderable; } + /// Is GL_ARB_IMAGING supported bool imagingSupport() const { return fImagingSupport; } @@ -416,6 +417,7 @@ private: bool fPackFlipYSupport : 1; bool fTextureUsageSupport : 1; bool fTextureRedSupport : 1; + bool fAlpha8IsRenderable: 1; bool fImagingSupport : 1; bool fVertexArrayObjectSupport : 1; bool fDirectStateAccessSupport : 1; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 81ee87c..19912ba 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1145,7 +1145,6 @@ static bool renderbuffer_storage_msaa(const GrGLContext& ctx, CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); switch (ctx.caps()->msFBOType()) { - case GrGLCaps::kEXT_MSFBOType: case GrGLCaps::kStandard_MSFBOType: case GrGLCaps::kMixedSamples_MSFBOType: GL_ALLOC_CALL(ctx.interface(), -- 2.7.4