aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2015-11-03 10:33:14 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-03 10:33:14 -0800
commit0c2999974d189ea257f82c9b7672d9afda52f6c2 (patch)
tree96a31dd38b3252f3aadafde6d43dc2ab96167b73 /src/gpu
parent0575131e579641e76798e58a8bb6786f9eebd5f2 (diff)
Revert of Create swizzle table inside of glsl caps (patchset #12 id:210001 of https://codereview.chromium.org/1420033005/ )
Reason for revert: Breaking gm's on nexus7 and s3 Original issue's description: > Create swizzle table inside of glsl caps > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/4036674952f341dab0695c3b054fefa5bb8cdec1 TBR=bsalomon@google.com,robertphillips@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1426653008
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrCaps.cpp2
-rw-r--r--src/gpu/gl/GrGLCaps.cpp46
-rw-r--r--src/gpu/gl/GrGLCaps.h8
-rw-r--r--src/gpu/gl/GrGLGpu.cpp47
-rw-r--r--src/gpu/gl/GrGLGpu.h5
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp25
-rw-r--r--src/gpu/gl/builders/GrGLShaderBuilder.cpp80
-rw-r--r--src/gpu/gl/builders/GrGLShaderBuilder.h8
-rwxr-xr-xsrc/gpu/glsl/GrGLSLCaps.cpp11
-rwxr-xr-xsrc/gpu/glsl/GrGLSLCaps.h14
-rw-r--r--src/gpu/glsl/GrGLSLTextureSampler.h9
11 files changed, 103 insertions, 152 deletions
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 22f6a6de8f..75cecdfb8c 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -77,7 +77,6 @@ SkString GrShaderCaps::dump() const {
void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) {
fDualSourceBlendingSupport = fDualSourceBlendingSupport && !options.fSuppressDualSourceBlending;
- this->onApplyOptionsOverrides(options);
}
///////////////////////////////////////////////////////////////////////////////
@@ -128,7 +127,6 @@ void GrCaps::applyOptionsOverrides(const GrContextOptions& options) {
} else {
fMaxTileSize = options.fMaxTileSizeOverride;
}
- this->onApplyOptionsOverrides(options);
}
static SkString map_flags_to_string(uint32_t flags) {
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index de7fcd5c57..1ce961e37d 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -8,7 +8,6 @@
#include "GrGLCaps.h"
-#include "GrContextOptions.h"
#include "GrGLContext.h"
#include "glsl/GrGLSLCaps.h"
#include "SkTSearch.h"
@@ -28,6 +27,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fMaxFragmentTextureUnits = 0;
fRGBA8RenderbufferSupport = false;
fBGRAIsInternalFormat = false;
+ fTextureSwizzleSupport = false;
fUnpackRowLengthSupport = false;
fUnpackFlipYSupport = false;
fPackRowLengthSupport = false;
@@ -94,6 +94,13 @@ 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;
@@ -492,8 +499,6 @@ 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);
@@ -1172,6 +1177,7 @@ 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"));
@@ -1282,40 +1288,6 @@ void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
}
}
-void GrGLCaps::initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glslCaps) {
- GrGLStandard standard = ctxInfo.standard();
- GrGLVersion version = ctxInfo.version();
-
- if (kGL_GrGLStandard == standard) {
- glslCaps->fMustSwizzleInShader = version >= GR_GL_VER(3,3) ||
- ctxInfo.hasExtension("GL_ARB_texture_swizzle");
- } else {
- glslCaps->fMustSwizzleInShader = version >= GR_GL_VER(3,0);
- }
-
- 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) {}
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 10d62b0298..2ad5827075 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -171,6 +171,9 @@ public:
*/
bool bgraIsInternalFormat() const { return fBGRAIsInternalFormat; }
+ /// GL_ARB_texture_swizzle support
+ bool textureSwizzleSupport() const { return fTextureSwizzleSupport; }
+
/// Is there support for GL_UNPACK_ROW_LENGTH
bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; }
@@ -270,8 +273,6 @@ private:
void initGLSL(const GrGLContextInfo&);
bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
- void onApplyOptionsOverrides(const GrContextOptions& options) override;
-
/**
* Maintains a bit per GrPixelConfig. It is used to avoid redundantly
* performing glCheckFrameBufferStatus for the same config.
@@ -322,8 +323,6 @@ private:
const GrGLInterface* intf,
GrGLSLCaps* glslCaps);
- void initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glslCaps);
-
// tracks configs that have been verified to pass the FBO completeness when
// used as a color attachment
VerifiedColorConfigs fVerifiedColorConfigs;
@@ -341,6 +340,7 @@ private:
bool fRGBA8RenderbufferSupport : 1;
bool fBGRAIsInternalFormat : 1;
+ bool fTextureSwizzleSupport : 1;
bool fUnpackRowLengthSupport : 1;
bool fUnpackFlipYSupport : 1;
bool fPackRowLengthSupport : 1;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 0a8f98a8b4..0e9aa0d917 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2404,34 +2404,19 @@ static inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
return gWrapModes[tm];
}
-static GrGLenum get_component_enum_from_char(char component) {
- switch (component) {
- case 'r':
- return GR_GL_RED;
- case 'g':
- return GR_GL_GREEN;
- case 'b':
- return GR_GL_BLUE;
- case 'a':
- return GR_GL_ALPHA;
- default:
- SkFAIL("Unsupported component");
- return 0;
- }
-}
-
-/** If texture swizzling is available using tex parameters then it is preferred over mangling
- the generated shader code. This potentially allows greater reuse of cached shaders. */
-static void get_tex_param_swizzle(GrPixelConfig config,
- const GrGLSLCaps& caps,
- GrGLenum* glSwizzle) {
- const char* swizzle = "rgba";
- if (!caps.mustSwizzleInShader()) {
- swizzle = caps.getSwizzleMap(config);
- }
-
- for (int i = 0; i < 4; ++i) {
- glSwizzle[i] = get_component_enum_from_char(swizzle[i]);
+const GrGLenum* GrGLGpu::GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps) {
+ if (caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(config)) {
+ if (caps.textureRedSupport()) {
+ static const GrGLenum gRedSmear[] = { GR_GL_RED, GR_GL_RED, GR_GL_RED, GR_GL_RED };
+ return gRedSmear;
+ } else {
+ static const GrGLenum gAlphaSmear[] = { GR_GL_ALPHA, GR_GL_ALPHA,
+ GR_GL_ALPHA, GR_GL_ALPHA };
+ return gAlphaSmear;
+ }
+ } else {
+ static const GrGLenum gStraight[] = { GR_GL_RED, GR_GL_GREEN, GR_GL_BLUE, GR_GL_ALPHA };
+ return gStraight;
}
}
@@ -2500,7 +2485,9 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur
newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX());
newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY());
- get_tex_param_swizzle(texture->config(), *this->glCaps().glslCaps(), newTexParams.fSwizzleRGBA);
+ memcpy(newTexParams.fSwizzleRGBA,
+ GetTexParamSwizzle(texture->config(), this->glCaps()),
+ sizeof(newTexParams.fSwizzleRGBA));
if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) {
this->setTextureUnit(unitIdx);
GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAG_FILTER, newTexParams.fMagFilter));
@@ -2517,7 +2504,7 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur
this->setTextureUnit(unitIdx);
GL_CALL(TexParameteri(target, GR_GL_TEXTURE_WRAP_T, newTexParams.fWrapT));
}
- if (!this->glCaps().glslCaps()->mustSwizzleInShader() &&
+ if (this->glCaps().textureSwizzleSupport() &&
(setAll || memcmp(newTexParams.fSwizzleRGBA,
oldTexParams.fSwizzleRGBA,
sizeof(newTexParams.fSwizzleRGBA)))) {
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 396d488174..c10d79e744 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -128,6 +128,11 @@ public:
bool isTestingOnlyBackendTexture(GrBackendObject id) const override;
void deleteTestingOnlyBackendTexture(GrBackendObject id) const override;
+ /** If texture swizzling is available using tex parameters then it is preferred over mangling
+ the generated shader code. This potentially allows greater reuse of cached shaders. */
+ static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps);
+
+
private:
GrGLGpu(GrGLContext* ctx, GrContext* context);
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 8ff25575c6..a232a63514 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -18,14 +18,26 @@
* present in the texture's config. swizzleComponentMask indicates the channels present in the
* shader swizzle.
*/
-static bool swizzle_requires_alpha_remapping(const GrGLSLCaps& caps, GrPixelConfig config) {
- if (!caps.mustSwizzleInShader()) {
+static bool swizzle_requires_alpha_remapping(const GrGLCaps& caps,
+ uint32_t configComponentMask,
+ uint32_t swizzleComponentMask) {
+ if (caps.textureSwizzleSupport()) {
// Any remapping is handled using texture swizzling not shader modifications.
return false;
}
- const char* swizzleMap = caps.getSwizzleMap(config);
-
- return SkToBool(memcmp(swizzleMap, "rgba", 4));
+ // check if the texture is alpha-only
+ if (kA_GrColorComponentFlag == configComponentMask) {
+ if (caps.textureRedSupport() && (kA_GrColorComponentFlag & swizzleComponentMask)) {
+ // we must map the swizzle 'a's to 'r'.
+ return true;
+ }
+ if (kRGB_GrColorComponentFlags & swizzleComponentMask) {
+ // The 'r', 'g', and/or 'b's must be mapped to 'a' according to our semantics that
+ // alpha-only textures smear alpha across all four channels when read.
+ return true;
+ }
+ }
+ return false;
}
static uint32_t gen_texture_key(const GrProcessor& proc, const GrGLCaps& caps) {
@@ -33,7 +45,8 @@ static uint32_t gen_texture_key(const GrProcessor& proc, const GrGLCaps& caps) {
int numTextures = proc.numTextures();
for (int t = 0; t < numTextures; ++t) {
const GrTextureAccess& access = proc.textureAccess(t);
- if (swizzle_requires_alpha_remapping(*caps.glslCaps(), access.getTexture()->config())) {
+ uint32_t configComponentMask = GrPixelConfigComponentMask(access.getTexture()->config());
+ if (swizzle_requires_alpha_remapping(caps, configComponentMask, access.swizzleMask())) {
key |= 1 << t;
}
}
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.cpp b/src/gpu/gl/builders/GrGLShaderBuilder.cpp
index 2c00bafcf7..03dc1667c7 100644
--- a/src/gpu/gl/builders/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLShaderBuilder.cpp
@@ -6,68 +6,47 @@
*/
#include "GrGLShaderBuilder.h"
+#include "gl/GrGLGpu.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLShaderVar.h"
#include "glsl/GrGLSLTextureSampler.h"
-static void map_swizzle(const char* swizzleMap, const char* swizzle, char* mangledSwizzle) {
- int i;
- for (i = 0; '\0' != swizzle[i]; ++i) {
- switch (swizzle[i]) {
- case 'r':
- mangledSwizzle[i] = swizzleMap[0];
- break;
- case 'g':
- mangledSwizzle[i] = swizzleMap[1];
- break;
- case 'b':
- mangledSwizzle[i] = swizzleMap[2];
- break;
- case 'a':
- mangledSwizzle[i] = swizzleMap[3];
- break;
- default:
- SkFAIL("Unsupported swizzle");
- }
- }
- mangledSwizzle[i] ='\0';
-}
-
-static void append_texture_lookup(SkString* out,
- const GrGLSLCaps* glslCaps,
- const char* samplerName,
- const char* coordName,
- GrPixelConfig config,
- const char* swizzle,
- GrSLType varyingType = kVec2f_GrSLType) {
+namespace {
+void append_texture_lookup(SkString* out,
+ GrGLGpu* gpu,
+ const char* samplerName,
+ const char* coordName,
+ uint32_t configComponentMask,
+ const char* swizzle,
+ GrSLType varyingType = kVec2f_GrSLType) {
SkASSERT(coordName);
out->appendf("%s(%s, %s)",
- GrGLSLTexture2DFunctionName(varyingType, glslCaps->generation()),
+ GrGLSLTexture2DFunctionName(varyingType, gpu->glslGeneration()),
samplerName,
coordName);
char mangledSwizzle[5];
- // This refers to any swizzling we may need to get from some backend internal format to the
- // format used in GrPixelConfig. Some backends will automatically do the sizzling for us.
- if (glslCaps->mustSwizzleInShader()) {
- const char* swizzleMap = glslCaps->getSwizzleMap(config);
- // if the map is simply 'rgba' then we don't need to do any manual swizzling to get us to
- // a GrPixelConfig format.
- if (memcmp(swizzleMap, "rgba", 4)) {
- // Manually 'swizzle' the swizzle using our mapping
- map_swizzle(swizzleMap, swizzle, mangledSwizzle);
- swizzle = mangledSwizzle;
+ // The swizzling occurs using texture params instead of shader-mangling if ARB_texture_swizzle
+ // is available.
+ if (!gpu->glCaps().textureSwizzleSupport() &&
+ (kA_GrColorComponentFlag == configComponentMask)) {
+ char alphaChar = gpu->glCaps().textureRedSupport() ? 'r' : 'a';
+ int i;
+ for (i = 0; '\0' != swizzle[i]; ++i) {
+ mangledSwizzle[i] = alphaChar;
}
+ mangledSwizzle[i] ='\0';
+ swizzle = mangledSwizzle;
}
-
// For shader prettiness we omit the swizzle rather than appending ".rgba".
if (memcmp(swizzle, "rgba", 4)) {
out->appendf(".%s", swizzle);
}
}
+}
GrGLShaderBuilder::GrGLShaderBuilder(GrGLProgramBuilder* program)
: fProgramBuilder(program)
@@ -118,10 +97,10 @@ void GrGLShaderBuilder::appendTextureLookup(SkString* out,
const char* coordName,
GrSLType varyingType) const {
append_texture_lookup(out,
- fProgramBuilder->glslCaps(),
+ fProgramBuilder->gpu(),
fProgramBuilder->getUniformCStr(sampler.fSamplerUniform),
coordName,
- sampler.config(),
+ sampler.configComponentMask(),
sampler.swizzle(),
varyingType);
}
@@ -155,6 +134,19 @@ void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
}
}
+void GrGLShaderBuilder::appendTextureLookup(const char* samplerName,
+ const char* coordName,
+ uint32_t configComponentMask,
+ const char* swizzle) {
+ append_texture_lookup(&this->code(),
+ fProgramBuilder->gpu(),
+ samplerName,
+ coordName,
+ configComponentMask,
+ swizzle,
+ kVec2f_GrSLType);
+}
+
void GrGLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifier interface) {
SkASSERT(fProgramBuilder->glslCaps()->generation() >= k330_GrGLSLGeneration ||
fProgramBuilder->glslCaps()->mustEnableAdvBlendEqs());
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.h b/src/gpu/gl/builders/GrGLShaderBuilder.h
index d63a679e8c..2daea1515b 100644
--- a/src/gpu/gl/builders/GrGLShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLShaderBuilder.h
@@ -126,6 +126,14 @@ protected:
void appendDecls(const VarArray& vars, SkString* out) const;
/*
+ * this super low level function is just for use internally to builders
+ */
+ void appendTextureLookup(const char* samplerName,
+ const char* coordName,
+ uint32_t configComponentMask,
+ const char* swizzle);
+
+ /*
* A general function which enables an extension in a shader if the feature bit is not present
*/
void addFeature(uint32_t featureBit, const char* extensionName);
diff --git a/src/gpu/glsl/GrGLSLCaps.cpp b/src/gpu/glsl/GrGLSLCaps.cpp
index 140cb11494..54d041e3a0 100755
--- a/src/gpu/glsl/GrGLSLCaps.cpp
+++ b/src/gpu/glsl/GrGLSLCaps.cpp
@@ -8,8 +8,6 @@
#include "GrGLSLCaps.h"
-#include "GrContextOptions.h"
-
////////////////////////////////////////////////////////////////////////////////////////////
GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options) {
@@ -27,9 +25,6 @@ GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options) {
fFBFetchColorName = nullptr;
fFBFetchExtensionString = nullptr;
fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction;
-
- fMustSwizzleInShader = false;
- memset(fConfigSwizzle, 0, sizeof(fConfigSwizzle));
}
SkString GrGLSLCaps::dump() const {
@@ -61,9 +56,3 @@ SkString GrGLSLCaps::dump() const {
return r;
}
-void GrGLSLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {
- if (options.fUseShaderSwizzling) {
- fMustSwizzleInShader = true;
- }
-}
-
diff --git a/src/gpu/glsl/GrGLSLCaps.h b/src/gpu/glsl/GrGLSLCaps.h
index e703fb8523..f93ef2766d 100755
--- a/src/gpu/glsl/GrGLSLCaps.h
+++ b/src/gpu/glsl/GrGLSLCaps.h
@@ -82,15 +82,6 @@ public:
return fShaderDerivativeExtensionString;
}
- bool mustSwizzleInShader() const { return fMustSwizzleInShader; }
-
- /**
- * Returns a string which represents how to map from an internal GLFormat to a given
- * GrPixelConfig. The function mustSwizzleInShader determines whether this swizzle is applied
- * in the generated shader code or using sample state in the 3D API.
- */
- const char* getSwizzleMap(GrPixelConfig config) const { return fConfigSwizzle[config]; }
-
GrGLSLGeneration generation() const { return fGLSLGeneration; }
/**
@@ -99,8 +90,6 @@ public:
SkString dump() const override;
private:
- void onApplyOptionsOverrides(const GrContextOptions& options) override;
-
GrGLSLGeneration fGLSLGeneration;
bool fDropsTileOnZeroDivide : 1;
@@ -120,9 +109,6 @@ private:
AdvBlendEqInteraction fAdvBlendEqInteraction;
- bool fMustSwizzleInShader;
- const char* fConfigSwizzle[kGrPixelConfigCnt];
-
friend class GrGLCaps; // For initialization.
typedef GrShaderCaps INHERITED;
diff --git a/src/gpu/glsl/GrGLSLTextureSampler.h b/src/gpu/glsl/GrGLSLTextureSampler.h
index 2de0431f58..2f14cd1013 100644
--- a/src/gpu/glsl/GrGLSLTextureSampler.h
+++ b/src/gpu/glsl/GrGLSLTextureSampler.h
@@ -19,18 +19,19 @@ public:
GrGLSLTextureSampler(UniformHandle uniform, const GrTextureAccess& access)
: fSamplerUniform(uniform)
- , fConfig(access.getTexture()->config()) {
- SkASSERT(kUnknown_GrPixelConfig != fConfig);
+ , fConfigComponentMask(GrPixelConfigComponentMask(access.getTexture()->config())) {
+ SkASSERT(0 != fConfigComponentMask);
memcpy(fSwizzle, access.getSwizzle(), 5);
}
- GrPixelConfig config() const { return fConfig; }
+ // bitfield of GrColorComponentFlags present in the texture's config.
+ uint32_t configComponentMask() const { return fConfigComponentMask; }
// this is .abcd
const char* swizzle() const { return fSwizzle; }
private:
UniformHandle fSamplerUniform;
- GrPixelConfig fConfig;
+ uint32_t fConfigComponentMask;
char fSwizzle[5];
friend class GrGLShaderBuilder;