aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-06-18 12:52:47 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-18 17:13:58 +0000
commit19c1233c447f625c2522e7ecd0a0adecc629bb2f (patch)
tree891e06143986ade3aae8d4176ec8b426f70b896f /src/gpu/glsl
parent146cf3ce7935019ecc63ce9e93450a8c122880d8 (diff)
Change how vertex/instance attributes are handled in geometry processors.
* No longer register vertex/instance attributes on base class, just counts * Separate instance and vertex attributes and remove InputRate and offset * Make attributes constexpr where possible Change-Id: I1f1d5e772fa177a96d2aeb805aab7b69f35bfae6 Reviewed-on: https://skia-review.googlesource.com/132405 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/glsl')
-rw-r--r--src/gpu/glsl/GrGLSLVarying.cpp18
-rw-r--r--src/gpu/glsl/GrGLSLVarying.h2
2 files changed, 12 insertions, 8 deletions
diff --git a/src/gpu/glsl/GrGLSLVarying.cpp b/src/gpu/glsl/GrGLSLVarying.cpp
index f8ec1c24d9..0563406385 100644
--- a/src/gpu/glsl/GrGLSLVarying.cpp
+++ b/src/gpu/glsl/GrGLSLVarying.cpp
@@ -9,14 +9,15 @@
#include "glsl/GrGLSLVarying.h"
#include "glsl/GrGLSLProgramBuilder.h"
-void GrGLSLVaryingHandler::addPassThroughAttribute(const GrGeometryProcessor::Attribute* input,
+void GrGLSLVaryingHandler::addPassThroughAttribute(const GrGeometryProcessor::Attribute& input,
const char* output,
Interpolation interpolation) {
+ SkASSERT(input.isInitialized());
SkASSERT(!fProgramBuilder->primitiveProcessor().willUseGeoShader());
- GrSLType type = GrVertexAttribTypeToSLType(input->type());
+ GrSLType type = GrVertexAttribTypeToSLType(input.type());
GrGLSLVarying v(type);
- this->addVarying(input->name(), &v, interpolation);
- fProgramBuilder->fVS.codeAppendf("%s = %s;", v.vsOut(), input->name());
+ this->addVarying(input.name(), &v, interpolation);
+ fProgramBuilder->fVS.codeAppendf("%s = %s;", v.vsOut(), input.name());
fProgramBuilder->fFS.codeAppendf("%s = %s;", output, v.fsIn());
}
@@ -67,10 +68,13 @@ void GrGLSLVaryingHandler::addVarying(const char* name, GrGLSLVarying* varying,
}
void GrGLSLVaryingHandler::emitAttributes(const GrGeometryProcessor& gp) {
- int vaCount = gp.numAttribs();
+ int vaCount = gp.numVertexAttributes();
for (int i = 0; i < vaCount; i++) {
- const GrGeometryProcessor::Attribute& attr = gp.getAttrib(i);
- this->addAttribute(attr.asShaderVar());
+ this->addAttribute(gp.vertexAttribute(i).asShaderVar());
+ }
+ int iaCount = gp.numInstanceAttributes();
+ for (int i = 0; i < iaCount; i++) {
+ this->addAttribute(gp.instanceAttribute(i).asShaderVar());
}
}
diff --git a/src/gpu/glsl/GrGLSLVarying.h b/src/gpu/glsl/GrGLSLVarying.h
index 57704ad075..0da88a0fbd 100644
--- a/src/gpu/glsl/GrGLSLVarying.h
+++ b/src/gpu/glsl/GrGLSLVarying.h
@@ -104,7 +104,7 @@ public:
* that will be set as the output varying for all emitted vertices.
* TODO it might be nicer behavior to have a flag to declare output inside these calls
*/
- void addPassThroughAttribute(const GrGeometryProcessor::Attribute*, const char* output,
+ void addPassThroughAttribute(const GrGeometryProcessor::Attribute&, const char* output,
Interpolation = Interpolation::kInterpolated);
void emitAttributes(const GrGeometryProcessor& gp);