diff options
author | egdaniel <egdaniel@google.com> | 2015-11-04 04:23:53 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-04 04:23:53 -0800 |
commit | b7e7d5748d74c7482436b33733d7770484bb62e3 (patch) | |
tree | 29849ef2c2004f4215882b1f1987a4e4445b2d80 /src/gpu/gl/GrGLCaps.cpp | |
parent | df85a7254798f44e1d5b532fd4cbe58826b8d160 (diff) |
Create swizzle table inside of glsl caps
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/4036674952f341dab0695c3b054fefa5bb8cdec1
Review URL: https://codereview.chromium.org/1420033005
Diffstat (limited to 'src/gpu/gl/GrGLCaps.cpp')
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 1ce961e37d..0591f188a5 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; @@ -499,6 +492,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); @@ -1177,7 +1172,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")); @@ -1288,6 +1282,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) {} |