Index: src/gpu/gl/GrGLCaps.cpp |
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp |
index 1d25a2ca2f47eba5fcf1d4362387f9467983b1c4..c2e9627547b5383c311bfb5758ad0c4dd240da19 100644 |
--- a/src/gpu/gl/GrGLCaps.cpp |
+++ b/src/gpu/gl/GrGLCaps.cpp |
@@ -8,6 +8,7 @@ |
#include "GrGLCaps.h" |
+#include "GrContextOptions.h" |
#include "GrGLContext.h" |
#include "glsl/GrGLSLCaps.h" |
#include "SkTSearch.h" |
@@ -27,7 +28,6 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, |
fMaxFragmentTextureUnits = 0; |
fRGBA8RenderbufferSupport = false; |
fBGRAIsInternalFormat = false; |
- fTextureSwizzleSupport = false; |
fUnpackRowLengthSupport = false; |
fUnpackFlipYSupport = false; |
fPackRowLengthSupport = false; |
@@ -94,13 +94,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, |
} |
if (kGL_GrGLStandard == standard) { |
- fTextureSwizzleSupport = version >= GR_GL_VER(3,3) || |
- ctxInfo.hasExtension("GL_ARB_texture_swizzle"); |
- } else { |
- fTextureSwizzleSupport = version >= GR_GL_VER(3,0); |
- } |
- |
- if (kGL_GrGLStandard == standard) { |
fUnpackRowLengthSupport = true; |
fUnpackFlipYSupport = false; |
fPackRowLengthSupport = true; |
@@ -491,6 +484,8 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, |
this->initConfigTexturableTable(ctxInfo, gli, srgbSupport); |
this->initConfigRenderableTable(ctxInfo, srgbSupport); |
this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); |
+ // Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before this point. |
+ this->initConfigSwizzleTable(ctxInfo, glslCaps); |
this->applyOptionsOverrides(contextOptions); |
glslCaps->applyOptionsOverrides(contextOptions); |
@@ -1169,7 +1164,6 @@ SkString GrGLCaps::dump() const { |
r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO")); |
r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO")); |
- r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO")); |
r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO")); |
r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")); |
r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO")); |
@@ -1280,6 +1274,44 @@ void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, |
} |
} |
+void GrGLCaps::initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glslCaps) { |
+ GrGLStandard standard = ctxInfo.standard(); |
+ GrGLVersion version = ctxInfo.version(); |
+ |
+ glslCaps->fMustSwizzleInShader = true; |
+ if (kGL_GrGLStandard == standard) { |
+ if (version >= GR_GL_VER(3,3) || ctxInfo.hasExtension("GL_ARB_texture_swizzle")) { |
+ glslCaps->fMustSwizzleInShader = false; |
+ } |
+ } else { |
+ if (version >= GR_GL_VER(3,0)) { |
+ glslCaps->fMustSwizzleInShader = false; |
+ } |
+ } |
+ |
+ glslCaps->fConfigSwizzle[kUnknown_GrPixelConfig] = nullptr; |
+ if (fTextureRedSupport) { |
+ glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "rrrr"; |
+ glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "rrrr"; |
+ } else { |
+ glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "aaaa"; |
+ glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "aaaa"; |
+ } |
+ glslCaps->fConfigSwizzle[kIndex_8_GrPixelConfig] = "rgba"; |
+ glslCaps->fConfigSwizzle[kRGB_565_GrPixelConfig] = "rgba"; |
+ glslCaps->fConfigSwizzle[kRGBA_4444_GrPixelConfig] = "rgba"; |
+ glslCaps->fConfigSwizzle[kRGBA_8888_GrPixelConfig] = "rgba"; |
+ glslCaps->fConfigSwizzle[kBGRA_8888_GrPixelConfig] = "rgba"; |
+ glslCaps->fConfigSwizzle[kSRGBA_8888_GrPixelConfig] = "rgba"; |
+ glslCaps->fConfigSwizzle[kETC1_GrPixelConfig] = "rgba"; |
+ glslCaps->fConfigSwizzle[kLATC_GrPixelConfig] = "rrrr"; |
+ glslCaps->fConfigSwizzle[kR11_EAC_GrPixelConfig] = "rrrr"; |
+ glslCaps->fConfigSwizzle[kASTC_12x12_GrPixelConfig] = "rgba"; |
+ glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba"; |
+ glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba"; |
+ |
+} |
+void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} |