Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp

Issue 1462123003: Create GrGLSLVaryingHandler class for program building (Closed) Base URL: https://skia.googlesource.com/skia.git@putCapsOnArgs
Patch Set: fix release builder Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLVertexShaderBuilder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLSLVertexShaderBuilder.h" 8 #include "GrGLSLVertexShaderBuilder.h"
9 #include "glsl/GrGLSLProgramBuilder.h" 9 #include "glsl/GrGLSLProgramBuilder.h"
10 #include "glsl/GrGLSLVarying.h"
10 11
11 GrGLSLVertexBuilder::GrGLSLVertexBuilder(GrGLSLProgramBuilder* program) 12 GrGLSLVertexBuilder::GrGLSLVertexBuilder(GrGLSLProgramBuilder* program)
12 : INHERITED(program) 13 : INHERITED(program)
13 , fRtAdjustName(nullptr) { 14 , fRtAdjustName(nullptr) {
14 } 15 }
15 16
16 void GrGLSLVertexBuilder::addVarying(const char* name, GrSLPrecision precision, GrGLSLVarying* v) {
17 fOutputs.push_back();
18 fOutputs.back().setType(v->fType);
19 fOutputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingOut_TypeModifier);
20 fOutputs.back().setPrecision(precision);
21 fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'v', name);
22 v->fVsOut = fOutputs.back().getName().c_str();
23 }
24
25 void GrGLSLVertexBuilder::emitAttributes(const GrGeometryProcessor& gp) {
26 int vaCount = gp.numAttribs();
27 for (int i = 0; i < vaCount; i++) {
28 this->addAttribute(&gp.getAttrib(i));
29 }
30 return;
31 }
32
33 void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po sVar) { 17 void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po sVar) {
34 SkASSERT(!fRtAdjustName); 18 SkASSERT(!fRtAdjustName);
35 19
36 GrSLPrecision precision = kDefault_GrSLPrecision; 20 GrSLPrecision precision = kDefault_GrSLPrecision;
37 if (fProgramBuilder->glslCaps()->forceHighPrecisionNDSTransform()) { 21 if (fProgramBuilder->glslCaps()->forceHighPrecisionNDSTransform()) {
38 precision = kHigh_GrSLPrecision; 22 precision = kHigh_GrSLPrecision;
39 } 23 }
40 24
41 // setup RT Uniform 25 // setup RT Uniform
42 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = 26 fProgramBuilder->fUniformHandles.fRTAdjustmentUni =
(...skipping 22 matching lines...) Expand all
65 SkASSERT(kVec2f_GrSLType == posVar.getType()); 49 SkASSERT(kVec2f_GrSLType == posVar.getType());
66 this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);", 50 this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
67 posVar.c_str(), fRtAdjustName, fRtAdjustName, 51 posVar.c_str(), fRtAdjustName, fRtAdjustName,
68 posVar.c_str(), fRtAdjustName, fRtAdjustName); 52 posVar.c_str(), fRtAdjustName, fRtAdjustName);
69 } 53 }
70 // We could have the GrGeometryProcessor do this, but its just easier to hav e it performed 54 // We could have the GrGeometryProcessor do this, but its just easier to hav e it performed
71 // here. If we ever need to set variable pointsize, then we can reinvestigat e 55 // here. If we ever need to set variable pointsize, then we can reinvestigat e
72 this->codeAppend("gl_PointSize = 1.0;"); 56 this->codeAppend("gl_PointSize = 1.0;");
73 } 57 }
74 58
75 bool GrGLSLVertexBuilder::addAttribute(const GrShaderVar& var) { 59 void GrGLSLVertexBuilder::onFinalize() {
76 SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier()); 60 fProgramBuilder->varyingHandler()->getVertexDecls(&this->inputs(), &this->ou tputs());
77 for (int i = 0; i < fInputs.count(); ++i) {
78 const GrGLSLShaderVar& attr = fInputs[i];
79 // if attribute already added, don't add it again
80 if (attr.getName().equals(var.getName())) {
81 return false;
82 }
83 }
84 fInputs.push_back(var);
85 return true;
86 } 61 }
87 62
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLVertexShaderBuilder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698