GrShaderCaps always stores config texture swizzles.
Previously the swizzles were all "rgba" when GL texture swizzle was
used. This made it impossible to know the component mapping in that
case from API-neutral code.
Change-Id: I5e55fec87f0de2f8d43d8dc7759125482fccd91c
Bug: skia:8962
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218280
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index 344a2a5..05f8505 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -44,8 +44,12 @@
int samplerTypeKey = texture_type_key(textureType);
GR_STATIC_ASSERT(2 == sizeof(caps.configTextureSwizzle(config).asKey()));
+ uint16_t swizzleKey = 0;
+ if (caps.textureSwizzleAppliedInShader()) {
+ swizzleKey = caps.configTextureSwizzle(config).asKey();
+ }
return SkToU32(samplerTypeKey |
- caps.configTextureSwizzle(config).asKey() << kSamplerOrImageTypeKeyBits |
+ swizzleKey << kSamplerOrImageTypeKeyBits |
(GrSLSamplerPrecision(config) << (16 + kSamplerOrImageTypeKeyBits)));
}