aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-12-10 16:41:45 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-11 17:27:38 +0000
commit2326177e3499d96e1e5df68504cc98764d80209a (patch)
tree4178ee42f8e82bb0ea2edcc1399c5663c4954356 /src/gpu/glsl
parent30c48065dd4c200c5b37256ff943bc2032f2a9fb (diff)
CCPR: Don't use instanced draw calls with geometry shaders
It isn't necessary for the vertex shader to know all the points because everything happens in the geometry shader. It's simpler to use regular vertex arrays instead. Bug: skia: Change-Id: I7bf83180476fbe0ab01492611cd72e72b3f7d4f2 Reviewed-on: https://skia-review.googlesource.com/82881 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/glsl')
-rw-r--r--src/gpu/glsl/GrGLSLGeometryProcessor.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
index ab27ffaa7b..9c71042413 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -16,27 +16,37 @@
void GrGLSLGeometryProcessor::emitCode(EmitArgs& args) {
GrGPArgs gpArgs;
this->onEmitCode(args, &gpArgs);
- SkASSERT(kFloat2_GrSLType == gpArgs.fPositionVar.getType() ||
- kFloat3_GrSLType == gpArgs.fPositionVar.getType());
GrGLSLVertexBuilder* vBuilder = args.fVertBuilder;
if (!args.fGP.willUseGeoShader()) {
// Emit the vertex position to the hardware in the normalized window coordinates it expects.
+ SkASSERT(kFloat2_GrSLType == gpArgs.fPositionVar.getType() ||
+ kFloat3_GrSLType == gpArgs.fPositionVar.getType());
vBuilder->emitNormalizedSkPosition(gpArgs.fPositionVar.c_str(), args.fRTAdjustName,
gpArgs.fPositionVar.getType());
+ if (kFloat2_GrSLType == gpArgs.fPositionVar.getType()) {
+ args.fVaryingHandler->setNoPerspective();
+ }
} else {
// Since we have a geometry shader, leave the vertex position in Skia device space for now.
// The geometry Shader will operate in device space, and then convert the final positions to
// normalized hardware window coordinates under the hood, once everything else has finished.
+ // The subclass must call setNoPerspective on the varying handler, if applicable.
vBuilder->codeAppendf("sk_Position = float4(%s", gpArgs.fPositionVar.c_str());
- if (kFloat2_GrSLType == gpArgs.fPositionVar.getType()) {
- vBuilder->codeAppend(", 0");
+ switch (gpArgs.fPositionVar.getType()) {
+ case kFloat_GrSLType:
+ vBuilder->codeAppend(", 0"); // fallthru.
+ case kFloat2_GrSLType:
+ vBuilder->codeAppend(", 0"); // fallthru.
+ case kFloat3_GrSLType:
+ vBuilder->codeAppend(", 1"); // fallthru.
+ case kFloat4_GrSLType:
+ vBuilder->codeAppend(");");
+ break;
+ default:
+ SK_ABORT("Invalid position var type");
+ break;
}
- vBuilder->codeAppend(", 1);");
- }
-
- if (kFloat2_GrSLType == gpArgs.fPositionVar.getType()) {
- args.fVaryingHandler->setNoPerspective();
}
}