joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/glsl/GrGLSLGeometryProcessor.h" |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "src/gpu/GrCoordTransform.h" |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 11 | #include "src/gpu/GrPipeline.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" |
| 13 | #include "src/gpu/glsl/GrGLSLUniformHandler.h" |
| 14 | #include "src/gpu/glsl/GrGLSLVarying.h" |
| 15 | #include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h" |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 16 | |
Ethan Nicholas | d3a95c2 | 2020-06-03 13:24:46 -0400 | [diff] [blame^] | 17 | #include <unordered_map> |
| 18 | |
egdaniel | e659a58 | 2015-11-13 09:55:43 -0800 | [diff] [blame] | 19 | void GrGLSLGeometryProcessor::emitCode(EmitArgs& args) { |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 20 | GrGPArgs gpArgs; |
| 21 | this->onEmitCode(args, &gpArgs); |
Chris Dalton | c17bf32 | 2017-10-24 10:59:03 -0600 | [diff] [blame] | 22 | |
Chris Dalton | 5a2f962 | 2019-12-27 14:56:38 -0700 | [diff] [blame] | 23 | if (args.fGP.willUseTessellationShaders()) { |
| 24 | // Tessellation shaders are temporarily responsible for integrating their own code strings |
| 25 | // while we work out full support. |
| 26 | return; |
| 27 | } |
| 28 | |
Chris Dalton | c17bf32 | 2017-10-24 10:59:03 -0600 | [diff] [blame] | 29 | GrGLSLVertexBuilder* vBuilder = args.fVertBuilder; |
| 30 | if (!args.fGP.willUseGeoShader()) { |
| 31 | // Emit the vertex position to the hardware in the normalized window coordinates it expects. |
Chris Dalton | 2326177 | 2017-12-10 16:41:45 -0700 | [diff] [blame] | 32 | SkASSERT(kFloat2_GrSLType == gpArgs.fPositionVar.getType() || |
| 33 | kFloat3_GrSLType == gpArgs.fPositionVar.getType()); |
Chris Dalton | c17bf32 | 2017-10-24 10:59:03 -0600 | [diff] [blame] | 34 | vBuilder->emitNormalizedSkPosition(gpArgs.fPositionVar.c_str(), args.fRTAdjustName, |
| 35 | gpArgs.fPositionVar.getType()); |
Chris Dalton | 2326177 | 2017-12-10 16:41:45 -0700 | [diff] [blame] | 36 | if (kFloat2_GrSLType == gpArgs.fPositionVar.getType()) { |
| 37 | args.fVaryingHandler->setNoPerspective(); |
| 38 | } |
Chris Dalton | c17bf32 | 2017-10-24 10:59:03 -0600 | [diff] [blame] | 39 | } else { |
| 40 | // Since we have a geometry shader, leave the vertex position in Skia device space for now. |
| 41 | // The geometry Shader will operate in device space, and then convert the final positions to |
| 42 | // normalized hardware window coordinates under the hood, once everything else has finished. |
Chris Dalton | 2326177 | 2017-12-10 16:41:45 -0700 | [diff] [blame] | 43 | // The subclass must call setNoPerspective on the varying handler, if applicable. |
Chris Dalton | c17bf32 | 2017-10-24 10:59:03 -0600 | [diff] [blame] | 44 | vBuilder->codeAppendf("sk_Position = float4(%s", gpArgs.fPositionVar.c_str()); |
Chris Dalton | 2326177 | 2017-12-10 16:41:45 -0700 | [diff] [blame] | 45 | switch (gpArgs.fPositionVar.getType()) { |
| 46 | case kFloat_GrSLType: |
| 47 | vBuilder->codeAppend(", 0"); // fallthru. |
| 48 | case kFloat2_GrSLType: |
| 49 | vBuilder->codeAppend(", 0"); // fallthru. |
| 50 | case kFloat3_GrSLType: |
| 51 | vBuilder->codeAppend(", 1"); // fallthru. |
| 52 | case kFloat4_GrSLType: |
| 53 | vBuilder->codeAppend(");"); |
| 54 | break; |
| 55 | default: |
| 56 | SK_ABORT("Invalid position var type"); |
| 57 | break; |
Chris Dalton | c17bf32 | 2017-10-24 10:59:03 -0600 | [diff] [blame] | 58 | } |
cdalton | c08f196 | 2016-02-12 12:14:06 -0800 | [diff] [blame] | 59 | } |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 60 | } |
| 61 | |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 62 | void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb, |
egdaniel | 0eafe79 | 2015-11-20 14:01:22 -0800 | [diff] [blame] | 63 | GrGLSLVaryingHandler* varyingHandler, |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 64 | GrGLSLUniformHandler* uniformHandler, |
Brian Salomon | 04460cc | 2017-12-06 14:47:42 -0500 | [diff] [blame] | 65 | const GrShaderVar& localCoordsVar, |
egdaniel | e659a58 | 2015-11-13 09:55:43 -0800 | [diff] [blame] | 66 | const SkMatrix& localMatrix, |
bsalomon | a624bf3 | 2016-09-20 09:12:47 -0700 | [diff] [blame] | 67 | FPCoordTransformHandler* handler) { |
Brian Salomon | 706851d | 2020-02-20 14:18:00 -0500 | [diff] [blame] | 68 | // We only require localCoordsVar to be valid if there is a coord transform that needs |
| 69 | // it. CTs on FPs called with explicit coords do not require a local coord. |
| 70 | auto getLocalCoords = [&localCoordsVar, |
| 71 | localCoords = SkString(), |
| 72 | localCoordLength = int()]() mutable { |
| 73 | if (localCoords.isEmpty()) { |
| 74 | localCoordLength = GrSLTypeVecLength(localCoordsVar.getType()); |
| 75 | SkASSERT(GrSLTypeIsFloatType(localCoordsVar.getType())); |
| 76 | SkASSERT(localCoordLength == 2 || localCoordLength == 3); |
| 77 | if (localCoordLength == 3) { |
| 78 | localCoords = localCoordsVar.getName(); |
| 79 | } else { |
| 80 | localCoords.printf("float3(%s, 1)", localCoordsVar.c_str()); |
| 81 | } |
| 82 | } |
| 83 | return std::make_tuple(localCoords, localCoordLength); |
| 84 | }; |
Brian Salomon | 04460cc | 2017-12-06 14:47:42 -0500 | [diff] [blame] | 85 | |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 86 | GrShaderVar transformVar; |
Brian Salomon | 7d8b397 | 2019-11-26 22:34:44 -0500 | [diff] [blame] | 87 | for (int i = 0; *handler; ++*handler, ++i) { |
| 88 | auto [coordTransform, fp] = handler->get(); |
Brian Salomon | 706851d | 2020-02-20 14:18:00 -0500 | [diff] [blame] | 89 | // Add uniform for coord transform matrix. |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 90 | SkString matrix; |
Brian Salomon | 706851d | 2020-02-20 14:18:00 -0500 | [diff] [blame] | 91 | if (!fp.isSampledWithExplicitCoords() || !coordTransform.isNoOp()) { |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 92 | SkString strUniName; |
| 93 | strUniName.printf("CoordTransformMatrix_%d", i); |
Brian Salomon | 2fade72 | 2020-03-20 12:35:32 -0400 | [diff] [blame] | 94 | auto flag = fp.isSampledWithExplicitCoords() ? kFragment_GrShaderFlag |
| 95 | : kVertex_GrShaderFlag; |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 96 | auto& uni = fInstalledTransforms.push_back(); |
Brian Salomon | 14ed885 | 2020-03-24 10:43:38 -0400 | [diff] [blame] | 97 | if (fp.isSampledWithExplicitCoords() && coordTransform.matrix().isScaleTranslate()) { |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 98 | uni.fType = kFloat4_GrSLType; |
| 99 | } else { |
| 100 | uni.fType = kFloat3x3_GrSLType; |
| 101 | } |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 102 | const char* matrixName; |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 103 | uni.fHandle = |
Ethan Nicholas | 16464c3 | 2020-04-06 13:53:05 -0400 | [diff] [blame] | 104 | uniformHandler->addUniform(&fp, flag, uni.fType, strUniName.c_str(), |
| 105 | &matrixName); |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 106 | matrix = matrixName; |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 107 | transformVar = uniformHandler->getUniformVariable(uni.fHandle); |
Brian Salomon | 706851d | 2020-02-20 14:18:00 -0500 | [diff] [blame] | 108 | } else { |
| 109 | // Install a coord transform that will be skipped. |
| 110 | fInstalledTransforms.push_back(); |
| 111 | handler->omitCoordsForCurrCoordTransform(); |
| 112 | continue; |
| 113 | } |
| 114 | |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 115 | GrShaderVar fsVar; |
Brian Salomon | 706851d | 2020-02-20 14:18:00 -0500 | [diff] [blame] | 116 | // Add varying if required and register varying and matrix uniform. |
| 117 | if (!fp.isSampledWithExplicitCoords()) { |
| 118 | auto [localCoordsStr, localCoordLength] = getLocalCoords(); |
| 119 | GrGLSLVarying v(kFloat2_GrSLType); |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 120 | if (localMatrix.hasPerspective() || coordTransform.matrix().hasPerspective() || |
Brian Salomon | 706851d | 2020-02-20 14:18:00 -0500 | [diff] [blame] | 121 | localCoordLength == 3) { |
| 122 | v = GrGLSLVarying(kFloat3_GrSLType); |
Ethan Nicholas | d4efe68 | 2019-08-29 16:10:13 -0400 | [diff] [blame] | 123 | } |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 124 | SkString strVaryingName; |
| 125 | strVaryingName.printf("TransformedCoords_%d", i); |
Brian Salomon | 706851d | 2020-02-20 14:18:00 -0500 | [diff] [blame] | 126 | varyingHandler->addVarying(strVaryingName.c_str(), &v); |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 127 | |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 128 | SkASSERT(fInstalledTransforms.back().fType == kFloat3x3_GrSLType); |
Ethan Nicholas | bffad83 | 2020-05-05 14:31:55 -0400 | [diff] [blame] | 129 | if (fp.sampleMatrix().fKind != SkSL::SampleMatrix::Kind::kConstantOrUniform) { |
| 130 | if (v.type() == kFloat2_GrSLType) { |
| 131 | vb->codeAppendf("%s = (%s * %s).xy;", v.vsOut(), matrix.c_str(), |
| 132 | localCoordsStr.c_str()); |
| 133 | } else { |
| 134 | vb->codeAppendf("%s = %s * %s;", v.vsOut(), matrix.c_str(), |
| 135 | localCoordsStr.c_str()); |
| 136 | } |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 137 | } |
Ben Wagner | dabd98c | 2020-03-25 15:17:18 -0400 | [diff] [blame] | 138 | fsVar = GrShaderVar(SkString(v.fsIn()), v.type(), GrShaderVar::TypeModifier::In); |
Ethan Nicholas | afe2c90 | 2020-04-28 13:55:02 -0400 | [diff] [blame] | 139 | fTransformInfos.push_back({ v.vsOut(), v.type(), matrix, localCoordsStr, &fp }); |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 140 | } |
Ethan Nicholas | afe2c90 | 2020-04-28 13:55:02 -0400 | [diff] [blame] | 141 | handler->specifyCoordsForCurrCoordTransform(transformVar, fsVar); |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | |
| 145 | void GrGLSLGeometryProcessor::emitTransformCode(GrGLSLVertexBuilder* vb, |
| 146 | GrGLSLUniformHandler* uniformHandler) { |
Ethan Nicholas | d3a95c2 | 2020-06-03 13:24:46 -0400 | [diff] [blame^] | 147 | std::unordered_map<const GrFragmentProcessor*, const char*> localCoordsMap; |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 148 | for (const auto& tr : fTransformInfos) { |
| 149 | switch (tr.fFP->sampleMatrix().fKind) { |
Ethan Nicholas | d3a95c2 | 2020-06-03 13:24:46 -0400 | [diff] [blame^] | 150 | case SkSL::SampleMatrix::Kind::kConstantOrUniform: { |
| 151 | SkString localCoords; |
| 152 | localCoordsMap.insert({ tr.fFP, tr.fName }); |
| 153 | if (tr.fFP->sampleMatrix().fBase) { |
| 154 | SkASSERT(localCoordsMap[tr.fFP->sampleMatrix().fBase]); |
| 155 | localCoords = SkStringPrintf("float3(%s, 1)", |
| 156 | localCoordsMap[tr.fFP->sampleMatrix().fBase]); |
| 157 | } else { |
| 158 | localCoords = tr.fLocalCoords.c_str(); |
| 159 | } |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 160 | vb->codeAppend("{\n"); |
| 161 | uniformHandler->writeUniformMappings(tr.fFP->sampleMatrix().fOwner, vb); |
| 162 | if (tr.fType == kFloat2_GrSLType) { |
| 163 | vb->codeAppendf("%s = (%s * %s * %s).xy", tr.fName, |
Ethan Nicholas | afe2c90 | 2020-04-28 13:55:02 -0400 | [diff] [blame] | 164 | tr.fFP->sampleMatrix().fExpression.c_str(), tr.fMatrix.c_str(), |
Ethan Nicholas | d3a95c2 | 2020-06-03 13:24:46 -0400 | [diff] [blame^] | 165 | localCoords.c_str()); |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 166 | } else { |
| 167 | SkASSERT(tr.fType == kFloat3_GrSLType); |
| 168 | vb->codeAppendf("%s = %s * %s * %s", tr.fName, |
Ethan Nicholas | afe2c90 | 2020-04-28 13:55:02 -0400 | [diff] [blame] | 169 | tr.fFP->sampleMatrix().fExpression.c_str(), tr.fMatrix.c_str(), |
Ethan Nicholas | d3a95c2 | 2020-06-03 13:24:46 -0400 | [diff] [blame^] | 170 | localCoords.c_str()); |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 171 | } |
| 172 | vb->codeAppend(";\n"); |
| 173 | vb->codeAppend("}\n"); |
Ethan Nicholas | d3a95c2 | 2020-06-03 13:24:46 -0400 | [diff] [blame^] | 174 | } |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 175 | default: |
| 176 | break; |
| 177 | } |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 178 | } |
| 179 | } |
| 180 | |
bsalomon | a624bf3 | 2016-09-20 09:12:47 -0700 | [diff] [blame] | 181 | void GrGLSLGeometryProcessor::setTransformDataHelper(const SkMatrix& localMatrix, |
| 182 | const GrGLSLProgramDataManager& pdman, |
Brian Salomon | c241b58 | 2019-11-27 08:57:17 -0500 | [diff] [blame] | 183 | const CoordTransformRange& transformRange) { |
bsalomon | a624bf3 | 2016-09-20 09:12:47 -0700 | [diff] [blame] | 184 | int i = 0; |
Brian Salomon | c241b58 | 2019-11-27 08:57:17 -0500 | [diff] [blame] | 185 | for (auto [transform, fp] : transformRange) { |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 186 | if (fInstalledTransforms[i].fHandle.isValid()) { |
| 187 | SkMatrix m; |
Brian Salomon | b10a662 | 2020-02-20 13:36:01 -0500 | [diff] [blame] | 188 | if (fp.isSampledWithExplicitCoords()) { |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 189 | m = GetTransformMatrix(transform, SkMatrix::I()); |
Brian Salomon | b10a662 | 2020-02-20 13:36:01 -0500 | [diff] [blame] | 190 | } else { |
| 191 | m = GetTransformMatrix(transform, localMatrix); |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 192 | } |
Mike Reed | 2c38315 | 2019-12-18 16:47:47 -0500 | [diff] [blame] | 193 | if (!SkMatrixPriv::CheapEqual(fInstalledTransforms[i].fCurrentValue, m)) { |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 194 | if (fInstalledTransforms[i].fType == kFloat4_GrSLType) { |
| 195 | float values[4] = {m.getScaleX(), m.getTranslateX(), |
| 196 | m.getScaleY(), m.getTranslateY()}; |
Brian Salomon | 14ed885 | 2020-03-24 10:43:38 -0400 | [diff] [blame] | 197 | SkASSERT(m.isScaleTranslate()); |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 198 | pdman.set4fv(fInstalledTransforms[i].fHandle.toIndex(), 1, values); |
| 199 | } else { |
Brian Salomon | 14ed885 | 2020-03-24 10:43:38 -0400 | [diff] [blame] | 200 | SkASSERT(!m.isScaleTranslate() || !fp.isSampledWithExplicitCoords()); |
Brian Salomon | 8d1dcd7 | 2020-03-20 21:06:41 -0400 | [diff] [blame] | 201 | SkASSERT(fInstalledTransforms[i].fType == kFloat3x3_GrSLType); |
| 202 | pdman.setSkMatrix(fInstalledTransforms[i].fHandle.toIndex(), m); |
| 203 | } |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 204 | fInstalledTransforms[i].fCurrentValue = m; |
| 205 | } |
bsalomon | a624bf3 | 2016-09-20 09:12:47 -0700 | [diff] [blame] | 206 | } |
| 207 | ++i; |
| 208 | } |
| 209 | SkASSERT(i == fInstalledTransforms.count()); |
| 210 | } |
| 211 | |
Brian Salomon | 7f23543 | 2017-08-16 09:41:48 -0400 | [diff] [blame] | 212 | void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder, |
| 213 | GrGPArgs* gpArgs, |
| 214 | const char* posName) { |
Ethan Nicholas | 8aa4569 | 2017-09-20 11:24:15 -0400 | [diff] [blame] | 215 | gpArgs->fPositionVar.set(kFloat2_GrSLType, "pos2"); |
| 216 | vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName); |
joshualitt | 5559ca2 | 2015-05-21 15:50:36 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Brian Salomon | 7f23543 | 2017-08-16 09:41:48 -0400 | [diff] [blame] | 219 | void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder, |
| 220 | GrGLSLUniformHandler* uniformHandler, |
| 221 | GrGPArgs* gpArgs, |
| 222 | const char* posName, |
| 223 | const SkMatrix& mat, |
| 224 | UniformHandle* viewMatrixUniform) { |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 225 | if (mat.isIdentity()) { |
Ethan Nicholas | 8aa4569 | 2017-09-20 11:24:15 -0400 | [diff] [blame] | 226 | gpArgs->fPositionVar.set(kFloat2_GrSLType, "pos2"); |
| 227 | vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName); |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 228 | } else { |
joshualitt | 5559ca2 | 2015-05-21 15:50:36 -0700 | [diff] [blame] | 229 | const char* viewMatrixName; |
Ethan Nicholas | 16464c3 | 2020-04-06 13:53:05 -0400 | [diff] [blame] | 230 | *viewMatrixUniform = uniformHandler->addUniform(nullptr, |
| 231 | kVertex_GrShaderFlag, |
Ethan Nicholas | 8aa4569 | 2017-09-20 11:24:15 -0400 | [diff] [blame] | 232 | kFloat3x3_GrSLType, |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 233 | "uViewM", |
| 234 | &viewMatrixName); |
joshualitt | 5559ca2 | 2015-05-21 15:50:36 -0700 | [diff] [blame] | 235 | if (!mat.hasPerspective()) { |
Ethan Nicholas | 8aa4569 | 2017-09-20 11:24:15 -0400 | [diff] [blame] | 236 | gpArgs->fPositionVar.set(kFloat2_GrSLType, "pos2"); |
| 237 | vertBuilder->codeAppendf("float2 %s = (%s * float3(%s, 1)).xy;", |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 238 | gpArgs->fPositionVar.c_str(), viewMatrixName, posName); |
joshualitt | 5559ca2 | 2015-05-21 15:50:36 -0700 | [diff] [blame] | 239 | } else { |
Ethan Nicholas | 8aa4569 | 2017-09-20 11:24:15 -0400 | [diff] [blame] | 240 | gpArgs->fPositionVar.set(kFloat3_GrSLType, "pos3"); |
| 241 | vertBuilder->codeAppendf("float3 %s = %s * float3(%s, 1);", |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 242 | gpArgs->fPositionVar.c_str(), viewMatrixName, posName); |
joshualitt | 5559ca2 | 2015-05-21 15:50:36 -0700 | [diff] [blame] | 243 | } |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 244 | } |
| 245 | } |