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

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

Issue 1186113007: Refactor separable varying location info to be stored in GrGLProgram subclass (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address review comments Created 5 years, 5 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 #ifndef GrGLProgramBuilder_DEFINED 8 #ifndef GrGLProgramBuilder_DEFINED
9 #define GrGLProgramBuilder_DEFINED 9 #define GrGLProgramBuilder_DEFINED
10 10
11 #include "GrGLFragmentShaderBuilder.h" 11 #include "GrGLFragmentShaderBuilder.h"
12 #include "GrGLGeometryShaderBuilder.h" 12 #include "GrGLGeometryShaderBuilder.h"
13 #include "GrGLVertexShaderBuilder.h" 13 #include "GrGLVertexShaderBuilder.h"
14 #include "../GrGLProgramDataManager.h" 14 #include "../GrGLProgramDataManager.h"
15 #include "../GrGLPathProgramDataManager.h"
15 #include "../GrGLUniformHandle.h" 16 #include "../GrGLUniformHandle.h"
16 #include "../GrGLPrimitiveProcessor.h" 17 #include "../GrGLPrimitiveProcessor.h"
17 #include "../GrGLXferProcessor.h" 18 #include "../GrGLXferProcessor.h"
18 #include "../../GrPendingFragmentStage.h" 19 #include "../../GrPendingFragmentStage.h"
19 #include "../../GrPipeline.h" 20 #include "../../GrPipeline.h"
20 21
21 /* 22 /*
22 * This is the base class for a series of interfaces. This base class *MUST* re main abstract with 23 * This is the base class for a series of interfaces. This base class *MUST* re main abstract with
23 * NO data members because it is used in multiple interface inheritance. 24 * NO data members because it is used in multiple interface inheritance.
24 * Heirarchy: 25 * Heirarchy:
25 * GrGLUniformBuilder 26 * GrGLUniformBuilder
26 * / \ 27 * / \
27 * GrGLFPBuilder GrGLGPBuilder 28 * GrGLFPBuilder GrGLGPBuilder
28 * \ / 29 * \ /
29 * GrGLProgramBuilder(internal use only) 30 * GrGLProgramBuilder(internal use only)
30 */ 31 */
31 class GrGLUniformBuilder { 32 class GrGLUniformBuilder {
32 public: 33 public:
33 enum ShaderVisibility { 34 enum ShaderVisibility {
34 kVertex_Visibility = 1 << kVertex_GrShaderType, 35 kVertex_Visibility = 1 << kVertex_GrShaderType,
35 kGeometry_Visibility = 1 << kGeometry_GrShaderType, 36 kGeometry_Visibility = 1 << kGeometry_GrShaderType,
36 kFragment_Visibility = 1 << kFragment_GrShaderType, 37 kFragment_Visibility = 1 << kFragment_GrShaderType,
37 }; 38 };
38 39
39 virtual ~GrGLUniformBuilder() {} 40 virtual ~GrGLUniformBuilder() {}
40 41
41 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 42 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
43 typedef GrGLPathProgramDataManager::SeparableVaryingHandle SeparableVaryingH andle;
42 44
43 /** Add a uniform variable to the current program, that has visibility in on e or more shaders. 45 /** Add a uniform variable to the current program, that has visibility in on e or more shaders.
44 visibility is a bitfield of ShaderVisibility values indicating from whic h shaders the 46 visibility is a bitfield of ShaderVisibility values indicating from whic h shaders the
45 uniform should be accessible. At least one bit must be set. Geometry sha der uniforms are not 47 uniform should be accessible. At least one bit must be set. Geometry sha der uniforms are not
46 supported at this time. The actual uniform name will be mangled. If outN ame is not NULL then 48 supported at this time. The actual uniform name will be mangled. If outN ame is not NULL then
47 it will refer to the final uniform name after return. Use the addUniform Array variant to add 49 it will refer to the final uniform name after return. Use the addUniform Array variant to add
48 an array of uniforms. */ 50 an array of uniforms. */
49 UniformHandle addUniform(uint32_t visibility, 51 UniformHandle addUniform(uint32_t visibility,
50 GrSLType type, 52 GrSLType type,
51 GrSLPrecision precision, 53 GrSLPrecision precision,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 149
148 /* 150 /*
149 * This call can be used by GP to pass an attribute through all shaders dire ctly to 'output' in 151 * This call can be used by GP to pass an attribute through all shaders dire ctly to 'output' in
150 * the fragment shader. Though this call effects both the vertex shader and fragment shader, 152 * the fragment shader. Though this call effects both the vertex shader and fragment shader,
151 * it expects 'output' to be defined in the fragment shader before this call is made. 153 * it expects 'output' to be defined in the fragment shader before this call is made.
152 * TODO it might be nicer behavior to have a flag to declare output inside t his call 154 * TODO it might be nicer behavior to have a flag to declare output inside t his call
153 */ 155 */
154 virtual void addPassThroughAttribute(const GrGeometryProcessor::Attribute*, 156 virtual void addPassThroughAttribute(const GrGeometryProcessor::Attribute*,
155 const char* output) = 0; 157 const char* output) = 0;
156 158
159 /*
160 * Creates a fragment shader varying that can be referred to.
161 * Comparable to GrGLUniformBuilder::addUniform().
162 */
163 virtual SeparableVaryingHandle addSeparableVarying(
164 const char* name, GrGLVertToFrag*, GrSLPrecision fsPrecision = kDefault_ GrSLPrecision) = 0;
165
157 // TODO rename getFragmentBuilder 166 // TODO rename getFragmentBuilder
158 virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0; 167 virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0;
159 virtual GrGLVertexBuilder* getVertexShaderBuilder() = 0; 168 virtual GrGLVertexBuilder* getVertexShaderBuilder() = 0;
160 169
161 /* 170 /*
162 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE 171 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
163 */ 172 */
164 }; 173 };
165 174
166 /* a specializations for FPs. Lets the user add uniforms and FS code */ 175 /* a specializations for FPs. Lets the user add uniforms and FS code */
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 GrGLVertexBuilder* getVertexShaderBuilder() override { return &fVS; } 254 GrGLVertexBuilder* getVertexShaderBuilder() override { return &fVS; }
246 255
247 void addVarying( 256 void addVarying(
248 const char* name, 257 const char* name,
249 GrGLVarying*, 258 GrGLVarying*,
250 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) override; 259 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) override;
251 260
252 void addPassThroughAttribute(const GrPrimitiveProcessor::Attribute*, 261 void addPassThroughAttribute(const GrPrimitiveProcessor::Attribute*,
253 const char* output) override; 262 const char* output) override;
254 263
264 SeparableVaryingHandle addSeparableVarying(
265 const char* name,
266 GrGLVertToFrag*,
267 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) override;
255 268
256 // Handles for program uniforms (other than per-effect uniforms) 269 // Handles for program uniforms (other than per-effect uniforms)
257 struct BuiltinUniformHandles { 270 struct BuiltinUniformHandles {
258 UniformHandle fRTAdjustmentUni; 271 UniformHandle fRTAdjustmentUni;
259 272
260 // We use the render target height to provide a y-down frag coord when s pecifying 273 // We use the render target height to provide a y-down frag coord when s pecifying
261 // origin_upper_left is not supported. 274 // origin_upper_left is not supported.
262 UniformHandle fRTHeightUni; 275 UniformHandle fRTHeightUni;
263 }; 276 };
264 277
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 321
309 void verify(const GrPrimitiveProcessor&); 322 void verify(const GrPrimitiveProcessor&);
310 void verify(const GrXferProcessor&); 323 void verify(const GrXferProcessor&);
311 void verify(const GrFragmentProcessor&); 324 void verify(const GrFragmentProcessor&);
312 template <class Proc> 325 template <class Proc>
313 void emitSamplers(const GrProcessor&, 326 void emitSamplers(const GrProcessor&,
314 GrGLProcessor::TextureSamplerArray* outSamplers, 327 GrGLProcessor::TextureSamplerArray* outSamplers,
315 GrGLInstalledProc<Proc>*); 328 GrGLInstalledProc<Proc>*);
316 329
317 GrGLProgram* finalize(); 330 GrGLProgram* finalize();
318 void bindUniformLocations(GrGLuint programID); 331 void bindProgramResourceLocations(GrGLuint programID);
319 bool checkLinkStatus(GrGLuint programID); 332 bool checkLinkStatus(GrGLuint programID);
320 void resolveUniformLocations(GrGLuint programID); 333 virtual void resolveProgramResourceLocations(GrGLuint programID);
321 void cleanupProgram(GrGLuint programID, const SkTDArray<GrGLuint>& shaderIDs ); 334 void cleanupProgram(GrGLuint programID, const SkTDArray<GrGLuint>& shaderIDs );
322 void cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs); 335 void cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs);
323 336
324 // Subclasses create different programs 337 // Subclasses create different programs
325 virtual GrGLProgram* createProgram(GrGLuint programID); 338 virtual GrGLProgram* createProgram(GrGLuint programID);
326 339
327 void appendUniformDecls(ShaderVisibility, SkString*) const; 340 void appendUniformDecls(ShaderVisibility, SkString*) const;
328 341
329 // reset is called by program creator between each processor's emit code. I t increments the 342 // reset is called by program creator between each processor's emit code. I t increments the
330 // stage offset for variable name mangling, and also ensures verfication var iables in the 343 // stage offset for variable name mangling, and also ensures verfication var iables in the
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 GrGLPrimitiveProcessor::TransformsIn fCoordTransforms; 397 GrGLPrimitiveProcessor::TransformsIn fCoordTransforms;
385 GrGLPrimitiveProcessor::TransformsOut fOutCoords; 398 GrGLPrimitiveProcessor::TransformsOut fOutCoords;
386 SkTArray<UniformHandle> fSamplerUniforms; 399 SkTArray<UniformHandle> fSamplerUniforms;
387 400
388 friend class GrGLShaderBuilder; 401 friend class GrGLShaderBuilder;
389 friend class GrGLVertexBuilder; 402 friend class GrGLVertexBuilder;
390 friend class GrGLFragmentShaderBuilder; 403 friend class GrGLFragmentShaderBuilder;
391 friend class GrGLGeometryBuilder; 404 friend class GrGLGeometryBuilder;
392 }; 405 };
393 #endif 406 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLPathProgramBuilder.cpp ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698