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

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

Issue 635533005: Revert of Cleanup of shader building system (Closed) Base URL: https://skia.googlesource.com/skia.git@solo_gp
Patch Set: Created 6 years, 2 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/GrGLShaderBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.h » ('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 "GrGLShaderBuilder.h" 8 #include "GrGLShaderBuilder.h"
9 #include "GrGLProgramBuilder.h" 9 #include "GrGLFullProgramBuilder.h"
10 #include "GrGLProgramBuilder.h" 10 #include "GrGLProgramBuilder.h"
11 #include "../GrGpuGL.h" 11 #include "../GrGpuGL.h"
12 #include "../GrGLShaderVar.h" 12 #include "../GrGLShaderVar.h"
13 13
14 namespace { 14 namespace {
15 inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen) { 15 inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen) {
16 if (kVec2f_GrSLType == type) { 16 if (kVec2f_GrSLType == type) {
17 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; 17 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D";
18 } else { 18 } else {
19 SkASSERT(kVec3f_GrSLType == type); 19 SkASSERT(kVec3f_GrSLType == type);
(...skipping 26 matching lines...) Expand all
46 mangledSwizzle[i] = alphaChar; 46 mangledSwizzle[i] = alphaChar;
47 } 47 }
48 mangledSwizzle[i] ='\0'; 48 mangledSwizzle[i] ='\0';
49 swizzle = mangledSwizzle; 49 swizzle = mangledSwizzle;
50 } 50 }
51 // For shader prettiness we omit the swizzle rather than appending ".rgba". 51 // For shader prettiness we omit the swizzle rather than appending ".rgba".
52 if (memcmp(swizzle, "rgba", 4)) { 52 if (memcmp(swizzle, "rgba", 4)) {
53 out->appendf(".%s", swizzle); 53 out->appendf(".%s", swizzle);
54 } 54 }
55 } 55 }
56 static const int kVarsPerBlock = 8;
56 } 57 }
57 58
58 GrGLShaderBuilder::GrGLShaderBuilder(GrGLProgramBuilder* program) 59 GrGLShaderBuilder::GrGLShaderBuilder(GrGLProgramBuilder* program)
59 : fProgramBuilder(program) 60 : fProgramBuilder(program)
60 , fInputs(GrGLProgramBuilder::kVarsPerBlock) 61 , fInputs(kVarsPerBlock)
61 , fOutputs(GrGLProgramBuilder::kVarsPerBlock) 62 , fOutputs(kVarsPerBlock)
62 , fFeaturesAddedMask(0) { 63 , fFeaturesAddedMask(0) {
63 } 64 }
64 65
65 void GrGLShaderBuilder::declAppend(const GrGLShaderVar& var) { 66 void GrGLShaderBuilder::declAppend(const GrGLShaderVar& var) {
66 SkString tempDecl; 67 SkString tempDecl;
67 var.appendDecl(fProgramBuilder->ctxInfo(), &tempDecl); 68 var.appendDecl(fProgramBuilder->ctxInfo(), &tempDecl);
68 this->codeAppendf("%s;", tempDecl.c_str()); 69 this->codeAppendf("%s;", tempDecl.c_str());
69 } 70 }
70 71
71 void GrGLShaderBuilder::emitFunction(GrSLType returnType, 72 void GrGLShaderBuilder::emitFunction(GrSLType returnType,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 136 }
136 } 137 }
137 138
138 void GrGLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionNam e) { 139 void GrGLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionNam e) {
139 if (!(featureBit & fFeaturesAddedMask)) { 140 if (!(featureBit & fFeaturesAddedMask)) {
140 fExtensions.appendf("#extension %s: require\n", extensionName); 141 fExtensions.appendf("#extension %s: require\n", extensionName);
141 fFeaturesAddedMask |= featureBit; 142 fFeaturesAddedMask |= featureBit;
142 } 143 }
143 } 144 }
144 145
145 void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
146 for (int i = 0; i < vars.count(); ++i) {
147 vars[i].appendDecl(fProgramBuilder->ctxInfo(), out);
148 out->append(";\n");
149 }
150 }
151
152 void GrGLShaderBuilder::appendTextureLookup(const char* samplerName, 146 void GrGLShaderBuilder::appendTextureLookup(const char* samplerName,
153 const char* coordName, 147 const char* coordName,
154 uint32_t configComponentMask, 148 uint32_t configComponentMask,
155 const char* swizzle) { 149 const char* swizzle) {
156 append_texture_lookup(&fCode, 150 append_texture_lookup(&fCode,
157 fProgramBuilder->gpu(), 151 fProgramBuilder->gpu(),
158 samplerName, 152 samplerName,
159 coordName, 153 coordName,
160 configComponentMask, 154 configComponentMask,
161 swizzle, 155 swizzle,
162 kVec2f_GrSLType); 156 kVec2f_GrSLType);
163 } 157 }
158
159 //////////////////////////////////////////////////////////////////////////////// ///////////////////
160 GrGLFullShaderBuilder::GrGLFullShaderBuilder(GrGLFullProgramBuilder* program)
161 : INHERITED(program)
162 , fFullProgramBuilder(program) {}
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLShaderBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698