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

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

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/GrGLProgramBuilder.cpp ('k') | src/gpu/gl/builders/GrGLShaderBuilder.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 #ifndef GrGLShaderBuilder_DEFINED 8 #ifndef GrGLShaderBuilder_DEFINED
9 #define GrGLShaderBuilder_DEFINED 9 #define GrGLShaderBuilder_DEFINED
10 10
11 #include "gl/GrGLProgramDesc.h" 11 #include "gl/GrGLProgramDesc.h"
12 #include "gl/GrGLProgramEffects.h"
13 #include "gl/GrGLSL.h"
12 #include "gl/GrGLProgramDataManager.h" 14 #include "gl/GrGLProgramDataManager.h"
15 #include "GrBackendProcessorFactory.h"
16 #include "GrColor.h"
17 #include "GrProcessor.h"
18 #include "SkTypes.h"
13 19
14 #include <stdarg.h> 20 #include <stdarg.h>
15 21
16 class GrGLContextInfo; 22 class GrGLContextInfo;
23 class GrProcessorStage;
24 class GrGLProgramDesc;
17 class GrGLProgramBuilder; 25 class GrGLProgramBuilder;
26 class GrGLFullProgramBuilder;
18 27
19 /** 28 /**
20 base class for all shaders builders 29 base class for all shaders builders
21 */ 30 */
22 class GrGLShaderBuilder { 31 class GrGLShaderBuilder {
23 public: 32 public:
24 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; 33 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
25 typedef GrGLProcessor::TextureSampler TextureSampler; 34 typedef GrGLProcessor::TextureSampler TextureSampler;
26
27 GrGLShaderBuilder(GrGLProgramBuilder* program); 35 GrGLShaderBuilder(GrGLProgramBuilder* program);
28 36
29 void addInput(GrGLShaderVar i) { fInputs.push_back(i); } 37 void addInput(GrGLShaderVar i) { fInputs.push_back(i); }
30 void addOutput(GrGLShaderVar i) { fOutputs.push_back(i); } 38 void addOutput(GrGLShaderVar i) { fOutputs.push_back(i); }
31 39
32 /* 40 /*
33 * We put texture lookups in the base class because it is TECHNICALLY possib le to do texture 41 * We put texture lookups in the base class because it is TECHNICALLY possib le to do texture
34 * lookups in any kind of shader. However, for the time being using these c alls on non-fragment 42 * lookups in any kind of shader. However, for the time being using these c alls on non-fragment
35 * shaders will result in a shader compilation error as texture sampler unif orms are only 43 * shaders will result in a shader compilation error as texture sampler unif orms are only
36 * visible to the fragment shader. It would not be hard to change this beha vior, if someone 44 * visible to the fragment shader. It would not be hard to change this beha vior, if someone
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 const GrGLShaderVar* args, 105 const GrGLShaderVar* args,
98 const char* body, 106 const char* body,
99 SkString* outName); 107 SkString* outName);
100 108
101 /* 109 /*
102 * Get parent builder for adding uniforms 110 * Get parent builder for adding uniforms
103 */ 111 */
104 GrGLProgramBuilder* getProgramBuilder() { return fProgramBuilder; } 112 GrGLProgramBuilder* getProgramBuilder() { return fProgramBuilder; }
105 113
106 /** 114 /**
107 * Helper for begining and ending a block in the shader code. 115 * Helper for begining and ending a block in the fragment code.
108 */ 116 */
109 class ShaderBlock { 117 class ShaderBlock {
110 public: 118 public:
111 ShaderBlock(GrGLShaderBuilder* builder) : fBuilder(builder) { 119 ShaderBlock(GrGLShaderBuilder* builder) : fBuilder(builder) {
112 SkASSERT(builder); 120 SkASSERT(builder);
113 fBuilder->codeAppend("{"); 121 fBuilder->codeAppend("{");
114 } 122 }
115 123
116 ~ShaderBlock() { 124 ~ShaderBlock() {
117 fBuilder->codeAppend("}"); 125 fBuilder->codeAppend("}");
118 } 126 }
119 private: 127 private:
120 GrGLShaderBuilder* fBuilder; 128 GrGLShaderBuilder* fBuilder;
121 }; 129 };
122
123 protected: 130 protected:
124 typedef GrTAllocator<GrGLShaderVar> VarArray;
125 void appendDecls(const VarArray& vars, SkString* out) const;
126 131
127 /* 132 /*
128 * this super low level function is just for use internally to builders 133 * this super low level function is just for use internally to builders
129 */ 134 */
130 void appendTextureLookup(const char* samplerName, 135 void appendTextureLookup(const char* samplerName,
131 const char* coordName, 136 const char* coordName,
132 uint32_t configComponentMask, 137 uint32_t configComponentMask,
133 const char* swizzle); 138 const char* swizzle);
134 139
135 /* 140 /*
136 * A general function which enables an extension in a shader if the feature bit is not present 141 * A general function which enables an extension in a shader if the feature bit is not present
137 */ 142 */
138 void addFeature(uint32_t featureBit, const char* extensionName); 143 void addFeature(uint32_t featureBit, const char* extensionName);
139 144
145 typedef GrTAllocator<GrGLShaderVar> VarArray;
146
140 GrGLProgramBuilder* fProgramBuilder; 147 GrGLProgramBuilder* fProgramBuilder;
141 148
142 SkString fCode; 149 SkString fCode;
143 SkString fFunctions; 150 SkString fFunctions;
144 SkString fExtensions; 151 SkString fExtensions;
145 152
146 VarArray fInputs; 153 VarArray fInputs;
147 VarArray fOutputs; 154 VarArray fOutputs;
148 uint32_t fFeaturesAddedMask; 155 uint32_t fFeaturesAddedMask;
149 }; 156 };
157
158
159 /*
160 * Full Shader builder is the base class for shaders which are only accessible t hrough full program
161 * builder, ie vertex, geometry, and later TCU / TES. Using this base class, th ey can access the
162 * full program builder functionality through the full program pointer
163 */
164 class GrGLFullShaderBuilder : public GrGLShaderBuilder {
165 public:
166 GrGLFullShaderBuilder(GrGLFullProgramBuilder* program);
167
168 GrGLFullProgramBuilder* fullProgramBuilder() { return fFullProgramBuilder; }
169 protected:
170 GrGLFullProgramBuilder* fFullProgramBuilder;
171 private:
172 typedef GrGLShaderBuilder INHERITED;
173 };
150 #endif 174 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.cpp ('k') | src/gpu/gl/builders/GrGLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698