Switch from querying swizzle on caps to using swizzles stored on proxies.
Change-Id: I03f4a3affd6dda7a83bee8eec768dcaa93a6b801
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/220534
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index 05f8505..0ea5417 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -39,14 +39,14 @@
return SkToU16(value);
}
-static uint32_t sampler_key(GrTextureType textureType, GrPixelConfig config,
- const GrShaderCaps& caps) {
+static uint32_t sampler_key(GrTextureType textureType, const GrSwizzle& swizzle,
+ GrPixelConfig config, const GrShaderCaps& caps) {
int samplerTypeKey = texture_type_key(textureType);
- GR_STATIC_ASSERT(2 == sizeof(caps.configTextureSwizzle(config).asKey()));
+ GR_STATIC_ASSERT(2 == sizeof(swizzle.asKey()));
uint16_t swizzleKey = 0;
if (caps.textureSwizzleAppliedInShader()) {
- swizzleKey = caps.configTextureSwizzle(config).asKey();
+ swizzleKey = swizzle.asKey();
}
return SkToU32(samplerTypeKey |
swizzleKey << kSamplerOrImageTypeKeyBits |
@@ -63,7 +63,8 @@
for (int i = 0; i < numTextureSamplers; ++i) {
const GrFragmentProcessor::TextureSampler& sampler = fp.textureSampler(i);
const GrTexture* tex = sampler.peekTexture();
- k32[i] = sampler_key(tex->texturePriv().textureType(), tex->config(), caps);
+ k32[i] = sampler_key(tex->texturePriv().textureType(), sampler.swizzle(), tex->config(),
+ caps);
uint32_t extraSamplerKey = gpu->getExtraSamplerKeyForProgram(
sampler.samplerState(), sampler.proxy()->backendFormat());
if (extraSamplerKey) {
@@ -86,7 +87,7 @@
uint32_t* k32 = b->add32n(numTextureSamplers);
for (int i = 0; i < numTextureSamplers; ++i) {
const GrPrimitiveProcessor::TextureSampler& sampler = pp.textureSampler(i);
- k32[i] = sampler_key(sampler.textureType(), sampler.config(), caps);
+ k32[i] = sampler_key(sampler.textureType(), sampler.swizzle(), sampler.config(), caps);
uint32_t extraSamplerKey = sampler.extraSamplerKey();
if (extraSamplerKey) {
SkASSERT(sampler.textureType() == GrTextureType::kExternal);
@@ -245,7 +246,7 @@
// make sure any padding in the header is zeroed.
memset(header, 0, kHeaderSize);
- header->fOutputSwizzle = shaderCaps.configOutputSwizzle(renderTarget->config()).asKey();
+ header->fOutputSwizzle = pipeline.outputSwizzle().asKey();
header->fColorFragmentProcessorCnt = pipeline.numColorFragmentProcessors();
header->fCoverageFragmentProcessorCnt = pipeline.numCoverageFragmentProcessors();
// Fail if the client requested more processors than the key can fit.