aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLProgramDesc.cpp
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/gl/GrGLProgramDesc.cpp
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/gl/GrGLProgramDesc.cpp')
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp25
1 files changed, 19 insertions, 6 deletions
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;
}
}