From 2326177e3499d96e1e5df68504cc98764d80209a Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Sun, 10 Dec 2017 16:41:45 -0700 Subject: 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 Commit-Queue: Chris Dalton --- src/gpu/glsl/GrGLSLGeometryProcessor.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/gpu/glsl') 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(); } } -- cgit v1.2.3