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 "GrGLProgramBuilder.h" | 8 #include "GrGLProgramBuilder.h" |
9 | 9 |
10 #include "GrAutoLocaleSetter.h" | 10 #include "GrAutoLocaleSetter.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 GrGLProgram* GrGLProgramBuilder::finalize() { | 128 GrGLProgram* GrGLProgramBuilder::finalize() { |
129 // verify we can get a program id | 129 // verify we can get a program id |
130 GrGLuint programID; | 130 GrGLuint programID; |
131 GL_CALL_RET(programID, CreateProgram()); | 131 GL_CALL_RET(programID, CreateProgram()); |
132 if (0 == programID) { | 132 if (0 == programID) { |
133 this->cleanupFragmentProcessors(); | 133 this->cleanupFragmentProcessors(); |
134 return nullptr; | 134 return nullptr; |
135 } | 135 } |
136 | 136 |
| 137 this->finalizeShaders(); |
| 138 |
137 // compile shaders and bind attributes / uniforms | 139 // compile shaders and bind attributes / uniforms |
138 SkTDArray<GrGLuint> shadersToDelete; | 140 SkTDArray<GrGLuint> shadersToDelete; |
139 fVS.finalize(GrGLSLUniformHandler::kVertex_Visibility); | |
140 if (!this->compileAndAttachShaders(fVS, programID, GR_GL_VERTEX_SHADER, &sha
dersToDelete)) { | 141 if (!this->compileAndAttachShaders(fVS, programID, GR_GL_VERTEX_SHADER, &sha
dersToDelete)) { |
141 this->cleanupProgram(programID, shadersToDelete); | 142 this->cleanupProgram(programID, shadersToDelete); |
142 return nullptr; | 143 return nullptr; |
143 } | 144 } |
144 | 145 |
145 // NVPR actually requires a vertex shader to compile | 146 // NVPR actually requires a vertex shader to compile |
146 bool useNvpr = primitiveProcessor().isPathRendering(); | 147 bool useNvpr = primitiveProcessor().isPathRendering(); |
147 if (!useNvpr) { | 148 if (!useNvpr) { |
148 const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); | 149 const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); |
149 | 150 |
150 int vaCount = primProc.numAttribs(); | 151 int vaCount = primProc.numAttribs(); |
151 for (int i = 0; i < vaCount; i++) { | 152 for (int i = 0; i < vaCount; i++) { |
152 GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).fName
)); | 153 GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).fName
)); |
153 } | 154 } |
154 } | 155 } |
155 | 156 |
156 fFS.finalize(GrGLSLUniformHandler::kFragment_Visibility); | |
157 if (!this->compileAndAttachShaders(fFS, programID, GR_GL_FRAGMENT_SHADER, &s
hadersToDelete)) { | 157 if (!this->compileAndAttachShaders(fFS, programID, GR_GL_FRAGMENT_SHADER, &s
hadersToDelete)) { |
158 this->cleanupProgram(programID, shadersToDelete); | 158 this->cleanupProgram(programID, shadersToDelete); |
159 return nullptr; | 159 return nullptr; |
160 } | 160 } |
161 | 161 |
162 this->bindProgramResourceLocations(programID); | 162 this->bindProgramResourceLocations(programID); |
163 | 163 |
164 GL_CALL(LinkProgram(programID)); | 164 GL_CALL(LinkProgram(programID)); |
165 | 165 |
166 // Calling GetProgramiv is expensive in Chromium. Assume success in release
builds. | 166 // Calling GetProgramiv is expensive in Chromium. Assume success in release
builds. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 fUniformHandles, | 264 fUniformHandles, |
265 programID, | 265 programID, |
266 fUniformHandler.fUniforms, | 266 fUniformHandler.fUniforms, |
267 fVaryingHandler.fPathProcVaryingInfos, | 267 fVaryingHandler.fPathProcVaryingInfos, |
268 fGeometryProcessor, | 268 fGeometryProcessor, |
269 fXferProcessor, | 269 fXferProcessor, |
270 fFragmentProcessors, | 270 fFragmentProcessors, |
271 &fSamplerUniforms); | 271 &fSamplerUniforms); |
272 } | 272 } |
273 | 273 |
OLD | NEW |