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

Side by Side Diff: src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp

Issue 929503002: Multi-string shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows warning Created 5 years, 10 months 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/gl/builders/GrGLVertexShaderBuilder.h ('k') | tests/GrGLSLPrettyPrintTest.cpp » ('j') | 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 "GrGLVertexShaderBuilder.h" 8 #include "GrGLVertexShaderBuilder.h"
9 #include "GrGLProgramBuilder.h" 9 #include "GrGLProgramBuilder.h"
10 #include "GrGLShaderStringBuilder.h"
11 #include "../GrGLGpu.h" 10 #include "../GrGLGpu.h"
12 11
13 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) 12 #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) 13 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(), R, X)
15 14
16 GrGLVertexBuilder::GrGLVertexBuilder(GrGLProgramBuilder* program) 15 GrGLVertexBuilder::GrGLVertexBuilder(GrGLProgramBuilder* program)
17 : INHERITED(program) 16 : INHERITED(program)
18 , fRtAdjustName(NULL) { 17 , fRtAdjustName(NULL) {
19 } 18 }
20 19
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 void GrGLVertexBuilder::bindVertexAttributes(GrGLuint programID) { 65 void GrGLVertexBuilder::bindVertexAttributes(GrGLuint programID) {
67 const GrPrimitiveProcessor& primProc = fProgramBuilder->primitiveProcessor() ; 66 const GrPrimitiveProcessor& primProc = fProgramBuilder->primitiveProcessor() ;
68 67
69 int vaCount = primProc.numAttribs(); 68 int vaCount = primProc.numAttribs();
70 for (int i = 0; i < vaCount; i++) { 69 for (int i = 0; i < vaCount; i++) {
71 GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).fName)); 70 GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).fName));
72 } 71 }
73 return; 72 return;
74 } 73 }
75 74
76 bool GrGLVertexBuilder::compileAndAttachShaders(GrGLuint programId, 75 bool
77 SkTDArray<GrGLuint>* shaderIds) const { 76 GrGLVertexBuilder::compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuin t>* shaderIds) {
78 GrGLGpu* gpu = fProgramBuilder->gpu(); 77 this->versionDecl() = GrGetGLSLVersionDecl(fProgramBuilder->ctxInfo());
79 const GrGLContext& glCtx = gpu->glContext(); 78 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility, &this->uniforms());
80 const GrGLContextInfo& ctxInfo = gpu->ctxInfo(); 79 this->appendDecls(fInputs, &this->inputs());
81 SkString vertShaderSrc(GrGetGLSLVersionDecl(ctxInfo)); 80 this->appendDecls(fOutputs, &this->outputs());
82 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility, &vertShaderSrc); 81 return this->finalize(programId, GR_GL_VERTEX_SHADER, shaderIds);
83 this->appendDecls(fInputs, &vertShaderSrc);
84 this->appendDecls(fOutputs, &vertShaderSrc);
85 vertShaderSrc.append("void main() {");
86 vertShaderSrc.append(fCode);
87 vertShaderSrc.append("}\n");
88 GrGLuint vertShaderId = GrGLCompileAndAttachShader(glCtx, programId, GR_GL_V ERTEX_SHADER,
89 vertShaderSrc, gpu->stats ());
90 if (!vertShaderId) {
91 return false;
92 }
93 *shaderIds->append() = vertShaderId;
94 return true;
95 } 82 }
96 83
97 bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) { 84 bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) {
98 SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier()); 85 SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier());
99 for (int i = 0; i < fInputs.count(); ++i) { 86 for (int i = 0; i < fInputs.count(); ++i) {
100 const GrGLShaderVar& attr = fInputs[i]; 87 const GrGLShaderVar& attr = fInputs[i];
101 // if attribute already added, don't add it again 88 // if attribute already added, don't add it again
102 if (attr.getName().equals(var.getName())) { 89 if (attr.getName().equals(var.getName())) {
103 return false; 90 return false;
104 } 91 }
105 } 92 }
106 fInputs.push_back(var); 93 fInputs.push_back(var);
107 return true; 94 return true;
108 } 95 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLVertexShaderBuilder.h ('k') | tests/GrGLSLPrettyPrintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698