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

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

Issue 1114813002: Add layout qualifiers to GrGLShaderBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_zzz2_texbar
Patch Set: rebase Created 5 years, 7 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
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 "GrGLShaderBuilder.h" 8 #include "GrGLShaderBuilder.h"
9 #include "GrGLProgramBuilder.h" 9 #include "GrGLProgramBuilder.h"
10 #include "GrGLShaderStringBuilder.h" 10 #include "GrGLShaderStringBuilder.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 const char* swizzle) { 165 const char* swizzle) {
166 append_texture_lookup(&this->code(), 166 append_texture_lookup(&this->code(),
167 fProgramBuilder->gpu(), 167 fProgramBuilder->gpu(),
168 samplerName, 168 samplerName,
169 coordName, 169 coordName,
170 configComponentMask, 170 configComponentMask,
171 swizzle, 171 swizzle,
172 kVec2f_GrSLType); 172 kVec2f_GrSLType);
173 } 173 }
174 174
175 void GrGLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifier interface) {
176 SkASSERT(fProgramBuilder->gpu()->glslGeneration() >= k330_GrGLSLGeneration);
177 fLayoutParams[interface].push_back() = param;
178 }
179
180 void GrGLShaderBuilder::compileAndAppendLayoutQualifiers() {
181 static const char* interfaceQualifierNames[] = {
182 "out"
183 };
184
185 for (int interface = 0; interface <= kLastInterfaceQualifier; ++interface) {
186 const SkTArray<SkString>& params = fLayoutParams[interface];
187 if (params.empty()) {
188 continue;
189 }
190 this->layoutQualifiers().appendf("layout(%s", params[0].c_str());
191 for (int i = 1; i < params.count(); ++i) {
192 this->layoutQualifiers().appendf(", %s", params[i].c_str());
193 }
194 this->layoutQualifiers().appendf(") %s;\n", interfaceQualifierNames[inte rface]);
195 }
196
197 GR_STATIC_ASSERT(0 == GrGLShaderBuilder::kOut_InterfaceQualifier);
198 GR_STATIC_ASSERT(SK_ARRAY_COUNT(interfaceQualifierNames) == kLastInterfaceQu alifier + 1);
199 }
200
175 bool 201 bool
176 GrGLShaderBuilder::finalize(GrGLuint programId, GrGLenum type, SkTDArray<GrGLuin t>* shaderIds) { 202 GrGLShaderBuilder::finalize(GrGLuint programId, GrGLenum type, SkTDArray<GrGLuin t>* shaderIds) {
177 SkASSERT(!fFinalized); 203 SkASSERT(!fFinalized);
178 // append the 'footer' to code 204 // append the 'footer' to code
179 this->code().append("}"); 205 this->code().append("}");
180 206
181 for (int i = 0; i <= fCodeIndex; i++) { 207 for (int i = 0; i <= fCodeIndex; i++) {
182 fCompilerStrings[i] = fShaderStrings[i].c_str(); 208 fCompilerStrings[i] = fShaderStrings[i].c_str();
183 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); 209 fCompilerStringLengths[i] = (int)fShaderStrings[i].size();
184 } 210 }
(...skipping 10 matching lines...) Expand all
195 fFinalized = true; 221 fFinalized = true;
196 222
197 if (!shaderId) { 223 if (!shaderId) {
198 return false; 224 return false;
199 } 225 }
200 226
201 *shaderIds->append() = shaderId; 227 *shaderIds->append() = shaderId;
202 228
203 return true; 229 return true;
204 } 230 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLShaderBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698