Remove local variable from GrConvolutionEffect GLSL code; reported to give marginal speedup
on some Intel architectures. Original patch from kondapallykalyan@.
http://codereview.appspot.com/6302070/
git-svn-id: http://skia.googlecode.com/svn/trunk@4250 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 5aaa185..d1ccc91 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -85,7 +85,7 @@
const char* samplerName) {
GrStringBuilder* code = &state->fFSCode;
- code->appendf("\t\tvec4 sum = vec4(0, 0, 0, 0);\n");
+ code->appendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor);
code->appendf("\t\tvec2 coord = %s;\n", state->fSampleCoords.c_str());
@@ -95,14 +95,17 @@
GrStringBuilder kernelIndex;
index.appendS32(i);
fKernelVar->appendArrayAccess(index.c_str(), &kernelIndex);
- code->appendf("\t\tsum += ");
+ code->appendf("\t\t%s += ", outputColor);
state->emitTextureLookup(samplerName, "coord");
code->appendf(" * %s;\n", kernelIndex.c_str());
code->appendf("\t\tcoord += %s;\n",
fImageIncrementVar->getName().c_str());
}
- code->appendf("\t\t%s = sum%s;\n", outputColor, state->fModulate.c_str());
+ if (state->fModulate.size()) {
+ code->appendf("\t\t%s = %s%s;\n", outputColor, outputColor,
+ state->fModulate.c_str());
+ }
}
void GrGLConvolutionEffect::initUniforms(const GrGLInterface* gl,