GrGLProgramBuilder cleanup
Only call addInputVars and computeCountsAndStrides in one place
(we were calling the latter twice when getting GLSL from the
cache, for some reason).
Add/edit some better comments.
Change-Id: I860fa241fc89a33cd5da243d0b549a5a5b5b88cf
Bug: skia:9402
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/243658
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index d53af2d..38c15ff 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -304,7 +304,11 @@
}
}
if (!usedProgramBinaries) {
- // either a cache miss, or we got something other than binaries from the cache
+ // Either a cache miss, or we got something other than binaries from the cache
+
+ /*
+ Fragment Shader
+ */
if (glsl[kFragment_GrShaderType].empty()) {
// Don't have cached GLSL, need to compile SkSL->GLSL
if (fFS.fForceHighPrecision) {
@@ -321,18 +325,18 @@
return nullptr;
}
inputs = fs->fInputs;
- this->addInputVars(inputs);
- } else {
- // we've pulled GLSL and inputs from the cache, but still need to do some setup
- this->addInputVars(inputs);
- this->computeCountsAndStrides(programID, primProc, false);
}
+
+ this->addInputVars(inputs);
if (!this->compileAndAttachShaders(glsl[kFragment_GrShaderType], programID,
GR_GL_FRAGMENT_SHADER, &shadersToDelete, errorHandler)) {
cleanup_program(fGpu, programID, shadersToDelete);
return nullptr;
}
+ /*
+ Vertex Shader
+ */
if (glsl[kVertex_GrShaderType].empty()) {
// Don't have cached GLSL, need to compile SkSL->GLSL
std::unique_ptr<SkSL::Program> vs = GrSkSLtoGLSL(gpu()->glContext(),
@@ -352,12 +356,15 @@
return nullptr;
}
- // NVPR actually requires a vertex shader to compile
- bool useNvpr = primProc.isPathRendering();
- if (!useNvpr) {
+ // This also binds vertex attribute locations. NVPR doesn't really use vertices,
+ // even though it requires a vertex shader in the program.
+ if (!primProc.isPathRendering()) {
this->computeCountsAndStrides(programID, primProc, true);
}
+ /*
+ Geometry Shader
+ */
if (primProc.willUseGeoShader()) {
if (glsl[kGeometry_GrShaderType].empty()) {
// Don't have cached GLSL, need to compile SkSL->GLSL