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

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: Created 5 years, 6 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 /** Creates a fragment shader varying that can be referred to.
160 * Comparable to GrGLUniformBuilder::addUniform().
161 */
162 virtual SeparableVaryingHandle addSeparableVarying(
163 const char* name, GrGLVertToFrag*, GrSLPrecision fsPrecision = kDefault_ GrSLPrecision) = 0;
164
157 // TODO rename getFragmentBuilder 165 // TODO rename getFragmentBuilder
158 virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0; 166 virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0;
159 virtual GrGLVertexBuilder* getVertexShaderBuilder() = 0; 167 virtual GrGLVertexBuilder* getVertexShaderBuilder() = 0;
160 168
161 /* 169 /*
162 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE 170 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
163 */ 171 */
164 }; 172 };
165 173
166 /* a specializations for FPs. Lets the user add uniforms and FS code */ 174 /* a specializations for FPs. Lets the user add uniforms and FS code */
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 GrGLVertexBuilder* getVertexShaderBuilder() override { return &fVS; } 260 GrGLVertexBuilder* getVertexShaderBuilder() override { return &fVS; }
253 261
254 void addVarying( 262 void addVarying(
255 const char* name, 263 const char* name,
256 GrGLVarying*, 264 GrGLVarying*,
257 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) override; 265 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) override;
258 266
259 void addPassThroughAttribute(const GrPrimitiveProcessor::Attribute*, 267 void addPassThroughAttribute(const GrPrimitiveProcessor::Attribute*,
260 const char* output) override; 268 const char* output) override;
261 269
270 SeparableVaryingHandle addSeparableVarying(
271 const char* name,
272 GrGLVertToFrag*,
273 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) override;
262 274
263 // Handles for program uniforms (other than per-effect uniforms) 275 // Handles for program uniforms (other than per-effect uniforms)
264 struct BuiltinUniformHandles { 276 struct BuiltinUniformHandles {
265 UniformHandle fRTAdjustmentUni; 277 UniformHandle fRTAdjustmentUni;
266 278
267 // We use the render target height to provide a y-down frag coord when s pecifying 279 // We use the render target height to provide a y-down frag coord when s pecifying
268 // origin_upper_left is not supported. 280 // origin_upper_left is not supported.
269 UniformHandle fRTHeightUni; 281 UniformHandle fRTHeightUni;
270 }; 282 };
271 283
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 327
316 void verify(const GrPrimitiveProcessor&); 328 void verify(const GrPrimitiveProcessor&);
317 void verify(const GrXferProcessor&); 329 void verify(const GrXferProcessor&);
318 void verify(const GrFragmentProcessor&); 330 void verify(const GrFragmentProcessor&);
319 template <class Proc> 331 template <class Proc>
320 void emitSamplers(const GrProcessor&, 332 void emitSamplers(const GrProcessor&,
321 GrGLProcessor::TextureSamplerArray* outSamplers, 333 GrGLProcessor::TextureSamplerArray* outSamplers,
322 GrGLInstalledProc<Proc>*); 334 GrGLInstalledProc<Proc>*);
323 335
324 GrGLProgram* finalize(); 336 GrGLProgram* finalize();
325 void bindUniformLocations(GrGLuint programID); 337 void bindProgramResourceLocations(GrGLuint programID);
326 bool checkLinkStatus(GrGLuint programID); 338 bool checkLinkStatus(GrGLuint programID);
327 void resolveUniformLocations(GrGLuint programID); 339 virtual void resolveProgramResourceLocations(GrGLuint programID);
328 void cleanupProgram(GrGLuint programID, const SkTDArray<GrGLuint>& shaderIDs ); 340 void cleanupProgram(GrGLuint programID, const SkTDArray<GrGLuint>& shaderIDs );
329 void cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs); 341 void cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs);
330 342
331 // Subclasses create different programs 343 // Subclasses create different programs
332 virtual GrGLProgram* createProgram(GrGLuint programID); 344 virtual GrGLProgram* createProgram(GrGLuint programID);
333 345
334 void appendUniformDecls(ShaderVisibility, SkString*) const; 346 void appendUniformDecls(ShaderVisibility, SkString*) const;
335 347
336 // reset is called by program creator between each processor's emit code. I t increments the 348 // reset is called by program creator between each processor's emit code. I t increments the
337 // stage offset for variable name mangling, and also ensures verfication var iables in the 349 // stage offset for variable name mangling, and also ensures verfication var iables in the
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 UniformInfoArray fUniforms; 402 UniformInfoArray fUniforms;
391 GrGLPrimitiveProcessor::TransformsIn fCoordTransforms; 403 GrGLPrimitiveProcessor::TransformsIn fCoordTransforms;
392 GrGLPrimitiveProcessor::TransformsOut fOutCoords; 404 GrGLPrimitiveProcessor::TransformsOut fOutCoords;
393 405
394 friend class GrGLShaderBuilder; 406 friend class GrGLShaderBuilder;
395 friend class GrGLVertexBuilder; 407 friend class GrGLVertexBuilder;
396 friend class GrGLFragmentShaderBuilder; 408 friend class GrGLFragmentShaderBuilder;
397 friend class GrGLGeometryBuilder; 409 friend class GrGLGeometryBuilder;
398 }; 410 };
399 #endif 411 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698