OLD | NEW |
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 "GrGLVertexShaderBuilder.h" | 8 #include "GrGLVertexShaderBuilder.h" |
9 #include "GrGLProgramBuilder.h" | 9 #include "GrGLProgramBuilder.h" |
10 #include "../GrGLGLSL.h" | 10 #include "../GrGLGLSL.h" |
11 #include "../GrGLGpu.h" | 11 #include "../GrGLGpu.h" |
12 | 12 |
13 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) | 13 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) |
14 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(),
R, X) | 14 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(),
R, X) |
15 | 15 |
16 GrGLVertexBuilder::GrGLVertexBuilder(GrGLProgramBuilder* program) | 16 GrGLVertexBuilder::GrGLVertexBuilder(GrGLProgramBuilder* program) |
17 : INHERITED(program) | 17 : INHERITED(program) |
18 , fRtAdjustName(nullptr) { | 18 , fRtAdjustName(nullptr) { |
19 } | 19 } |
20 | 20 |
21 void GrGLVertexBuilder::addVarying(const char* name, GrSLPrecision precision, Gr
GLVarying* v) { | 21 void GrGLVertexBuilder::addVarying(const char* name, GrSLPrecision precision, Gr
GLVarying* v) { |
22 fOutputs.push_back(); | 22 fOutputs.push_back(); |
23 fOutputs.back().setType(v->fType); | 23 fOutputs.back().setType(v->fType); |
24 fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier); | 24 fOutputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingOut_TypeModifier); |
25 fOutputs.back().setPrecision(precision); | 25 fOutputs.back().setPrecision(precision); |
26 fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'v', name); | 26 fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'v', name); |
27 v->fVsOut = fOutputs.back().getName().c_str(); | 27 v->fVsOut = fOutputs.back().getName().c_str(); |
28 } | 28 } |
29 | 29 |
30 void GrGLVertexBuilder::emitAttributes(const GrGeometryProcessor& gp) { | 30 void GrGLVertexBuilder::emitAttributes(const GrGeometryProcessor& gp) { |
31 int vaCount = gp.numAttribs(); | 31 int vaCount = gp.numAttribs(); |
32 for (int i = 0; i < vaCount; i++) { | 32 for (int i = 0; i < vaCount; i++) { |
33 this->addAttribute(&gp.getAttrib(i)); | 33 this->addAttribute(&gp.getAttrib(i)); |
34 } | 34 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 this->compileAndAppendLayoutQualifiers(); | 93 this->compileAndAppendLayoutQualifiers(); |
94 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility,
&this->uniforms()); | 94 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility,
&this->uniforms()); |
95 this->appendDecls(fInputs, &this->inputs()); | 95 this->appendDecls(fInputs, &this->inputs()); |
96 this->appendDecls(fOutputs, &this->outputs()); | 96 this->appendDecls(fOutputs, &this->outputs()); |
97 return this->finalize(programId, GR_GL_VERTEX_SHADER, shaderIds); | 97 return this->finalize(programId, GR_GL_VERTEX_SHADER, shaderIds); |
98 } | 98 } |
99 | 99 |
100 bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) { | 100 bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) { |
101 SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier()); | 101 SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier()); |
102 for (int i = 0; i < fInputs.count(); ++i) { | 102 for (int i = 0; i < fInputs.count(); ++i) { |
103 const GrGLShaderVar& attr = fInputs[i]; | 103 const GrGLSLShaderVar& attr = fInputs[i]; |
104 // if attribute already added, don't add it again | 104 // if attribute already added, don't add it again |
105 if (attr.getName().equals(var.getName())) { | 105 if (attr.getName().equals(var.getName())) { |
106 return false; | 106 return false; |
107 } | 107 } |
108 } | 108 } |
109 fInputs.push_back(var); | 109 fInputs.push_back(var); |
110 return true; | 110 return true; |
111 } | 111 } |
OLD | NEW |