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

Side by Side Diff: src/gpu/glsl/GrGLSLProgramBuilder.h

Issue 1438003003: Move all ShaderBuilder files to GLSL (Closed) Base URL: https://skia.googlesource.com/skia.git@glslProgBuild
Patch Set: nits Created 5 years, 1 month 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/glsl/GrGLSLGeometryShaderBuilder.cpp ('k') | src/gpu/glsl/GrGLSLShaderBuilder.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 2015 Google Inc. 2 * Copyright 2015 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 GrGLSLProgramBuilder_DEFINED 8 #ifndef GrGLSLProgramBuilder_DEFINED
9 #define GrGLSLProgramBuilder_DEFINED 9 #define GrGLSLProgramBuilder_DEFINED
10 10
11 #include "GrGeometryProcessor.h" 11 #include "GrGeometryProcessor.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 #include "gl/builders/GrGLFragmentShaderBuilder.h" 13 #include "glsl/GrGLSLFragmentShaderBuilder.h"
14 #include "gl/builders/GrGLGeometryShaderBuilder.h" 14 #include "glsl/GrGLSLGeometryShaderBuilder.h"
15 #include "gl/builders/GrGLVertexShaderBuilder.h"
16 #include "glsl/GrGLSLProgramDataManager.h" 15 #include "glsl/GrGLSLProgramDataManager.h"
16 #include "glsl/GrGLSLVertexShaderBuilder.h"
17 17
18 class GrGLSLCaps; 18 class GrGLSLCaps;
19 class GrGLSLShaderVar; 19 class GrGLSLShaderVar;
20 20
21 // Enough precision to represent 1 / 2048 accurately in printf
22 #define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11
23
21 class GrGLSLUniformBuilder { 24 class GrGLSLUniformBuilder {
22 public: 25 public:
23 enum ShaderVisibility { 26 enum ShaderVisibility {
24 kVertex_Visibility = 1 << kVertex_GrShaderType, 27 kVertex_Visibility = 1 << kVertex_GrShaderType,
25 kGeometry_Visibility = 1 << kGeometry_GrShaderType, 28 kGeometry_Visibility = 1 << kGeometry_GrShaderType,
26 kFragment_Visibility = 1 << kFragment_GrShaderType, 29 kFragment_Visibility = 1 << kFragment_GrShaderType,
27 }; 30 };
28 31
29 virtual ~GrGLSLUniformBuilder() {} 32 virtual ~GrGLSLUniformBuilder() {}
30 33
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 107
105 Varying fVarying; 108 Varying fVarying;
106 109
107 private: 110 private:
108 GrSLType fType; 111 GrSLType fType;
109 const char* fVsOut; 112 const char* fVsOut;
110 const char* fGsIn; 113 const char* fGsIn;
111 const char* fGsOut; 114 const char* fGsOut;
112 const char* fFsIn; 115 const char* fFsIn;
113 116
114 friend class GrGLVertexBuilder; 117 friend class GrGLSLVertexBuilder;
115 friend class GrGLGeometryBuilder; 118 friend class GrGLSLGeometryBuilder;
116 friend class GrGLXferBuilder; 119 friend class GrGLSLXferBuilder;
117 friend class GrGLFragmentShaderBuilder; 120 friend class GrGLSLFragmentShaderBuilder;
118 }; 121 };
119 122
120 struct GrGLSLVertToFrag : public GrGLSLVarying { 123 struct GrGLSLVertToFrag : public GrGLSLVarying {
121 GrGLSLVertToFrag(GrSLType type) 124 GrGLSLVertToFrag(GrSLType type)
122 : GrGLSLVarying(type, kVertToFrag_Varying) {} 125 : GrGLSLVarying(type, kVertToFrag_Varying) {}
123 }; 126 };
124 127
125 struct GrGLSLVertToGeo : public GrGLSLVarying { 128 struct GrGLSLVertToGeo : public GrGLSLVarying {
126 GrGLSLVertToGeo(GrSLType type) 129 GrGLSLVertToGeo(GrSLType type)
127 : GrGLSLVarying(type, kVertToGeo_Varying) {} 130 : GrGLSLVarying(type, kVertToGeo_Varying) {}
(...skipping 28 matching lines...) Expand all
156 159
157 /* 160 /*
158 * Creates a fragment shader varying that can be referred to. 161 * Creates a fragment shader varying that can be referred to.
159 * Comparable to GrGLSLUniformBuilder::addUniform(). 162 * Comparable to GrGLSLUniformBuilder::addUniform().
160 */ 163 */
161 virtual SeparableVaryingHandle addSeparableVarying( 164 virtual SeparableVaryingHandle addSeparableVarying(
162 const char* name, GrGLSLVertToFrag*, 165 const char* name, GrGLSLVertToFrag*,
163 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) = 0; 166 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) = 0;
164 167
165 // TODO rename getFragmentBuilder 168 // TODO rename getFragmentBuilder
166 virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0; 169 virtual GrGLSLFragmentBuilder* getFragmentShaderBuilder() = 0;
167 virtual GrGLVertexBuilder* getVertexShaderBuilder() = 0; 170 virtual GrGLSLVertexBuilder* getVertexShaderBuilder() = 0;
168 171
169 /* 172 /*
170 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE 173 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
171 */ 174 */
172 }; 175 };
173 176
174 177
175 /* a specializations for FPs. Lets the user add uniforms and FS code */ 178 /* a specializations for FPs. Lets the user add uniforms and FS code */
176 class GrGLSLFPBuilder : public virtual GrGLSLUniformBuilder { 179 class GrGLSLFPBuilder : public virtual GrGLSLUniformBuilder {
177 public: 180 public:
178 virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0; 181 virtual GrGLSLFragmentBuilder* getFragmentShaderBuilder() = 0;
179 182
180 /* 183 /*
181 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE 184 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
182 */ 185 */
183 }; 186 };
184 187
185 /* a specializations for XPs. Lets the user add uniforms and FS code */ 188 /* a specializations for XPs. Lets the user add uniforms and FS code */
186 class GrGLSLXPBuilder : public virtual GrGLSLUniformBuilder { 189 class GrGLSLXPBuilder : public virtual GrGLSLUniformBuilder {
187 public: 190 public:
188 virtual GrGLXPFragmentBuilder* getFragmentShaderBuilder() = 0; 191 virtual GrGLSLXPFragmentBuilder* getFragmentShaderBuilder() = 0;
189 192
190 /* 193 /*
191 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE 194 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
192 */ 195 */
193 }; 196 };
194 197
195 class GrGLSLProgramBuilder : public GrGLSLGPBuilder, 198 class GrGLSLProgramBuilder : public GrGLSLGPBuilder,
196 public GrGLSLFPBuilder, 199 public GrGLSLFPBuilder,
197 public GrGLSLXPBuilder { 200 public GrGLSLXPBuilder {
198 public: 201 public:
199 typedef GrGpu::DrawArgs DrawArgs; 202 typedef GrGpu::DrawArgs DrawArgs;
200 203
201 GrGLXPFragmentBuilder* getFragmentShaderBuilder() override { return &fFS; } 204 GrGLSLXPFragmentBuilder* getFragmentShaderBuilder() override { return &fFS; }
202 GrGLVertexBuilder* getVertexShaderBuilder() override { return &fVS; } 205 GrGLSLVertexBuilder* getVertexShaderBuilder() override { return &fVS; }
203 206
204 // Handles for program uniforms (other than per-effect uniforms) 207 // Handles for program uniforms (other than per-effect uniforms)
205 struct BuiltinUniformHandles { 208 struct BuiltinUniformHandles {
206 UniformHandle fRTAdjustmentUni; 209 UniformHandle fRTAdjustmentUni;
207 210
208 // We use the render target height to provide a y-down frag coord when s pecifying 211 // We use the render target height to provide a y-down frag coord when s pecifying
209 // origin_upper_left is not supported. 212 // origin_upper_left is not supported.
210 UniformHandle fRTHeightUni; 213 UniformHandle fRTHeightUni;
211 }; 214 };
212 215
(...skipping 20 matching lines...) Expand all
233 const char* rtAdjustment() const { return "rtAdjustment"; } 236 const char* rtAdjustment() const { return "rtAdjustment"; }
234 237
235 // Generates a name for a variable. The generated string will be name prefix ed by the prefix 238 // Generates a name for a variable. The generated string will be name prefix ed by the prefix
236 // char (unless the prefix is '\0'). It also will mangle the name to be stag e-specific unless 239 // char (unless the prefix is '\0'). It also will mangle the name to be stag e-specific unless
237 // explicitly asked not to. 240 // explicitly asked not to.
238 void nameVariable(SkString* out, char prefix, const char* name, bool mangle = true); 241 void nameVariable(SkString* out, char prefix, const char* name, bool mangle = true);
239 242
240 // number of each input/output type in a single allocation block, used by ma ny builders 243 // number of each input/output type in a single allocation block, used by ma ny builders
241 static const int kVarsPerBlock; 244 static const int kVarsPerBlock;
242 245
243 GrGLVertexBuilder fVS; 246 GrGLSLVertexBuilder fVS;
244 GrGLGeometryBuilder fGS; 247 GrGLSLGeometryBuilder fGS;
245 GrGLFragmentShaderBuilder fFS; 248 GrGLSLFragmentShaderBuilder fFS;
246 int fStageIndex; 249 int fStageIndex;
247 250
248 BuiltinUniformHandles fUniformHandles; 251 BuiltinUniformHandles fUniformHandles;
249 252
250 const DrawArgs& fArgs; 253 const DrawArgs& fArgs;
251 254
252 private: 255 private:
253 virtual void onAppendUniformDecls(ShaderVisibility visibility, SkString* out ) const = 0; 256 virtual void onAppendUniformDecls(ShaderVisibility visibility, SkString* out ) const = 0;
254 257
255 friend class GrGLShaderBuilder; 258 friend class GrGLSLShaderBuilder;
256 friend class GrGLVertexBuilder; 259 friend class GrGLSLVertexBuilder;
257 friend class GrGLFragmentShaderBuilder; 260 friend class GrGLSLFragmentShaderBuilder;
258 friend class GrGLGeometryBuilder; 261 friend class GrGLSLGeometryBuilder;
259 }; 262 };
260 263
261 #endif 264 #endif
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLGeometryShaderBuilder.cpp ('k') | src/gpu/glsl/GrGLSLShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698