OLD | NEW |
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 "gl/GrGLProgramDataManager.h" |
14 #include "glsl/GrGLSLProgramDataManager.h" | 15 #include "glsl/GrGLSLProgramDataManager.h" |
15 #include "glsl/GrGLSLTextureSampler.h" | 16 #include "glsl/GrGLSLTextureSampler.h" |
16 #include "../GrGLPrimitiveProcessor.h" | 17 #include "../GrGLPrimitiveProcessor.h" |
17 #include "../GrGLXferProcessor.h" | 18 #include "../GrGLXferProcessor.h" |
18 #include "../../GrPipeline.h" | 19 #include "../../GrPipeline.h" |
19 | 20 |
20 class GrFragmentProcessor; | 21 class GrFragmentProcessor; |
| 22 class GrGLContextInfo; |
21 class GrGLSLCaps; | 23 class GrGLSLCaps; |
22 | 24 |
23 // Enough precision to represent 1 / 2048 accurately in printf | 25 // Enough precision to represent 1 / 2048 accurately in printf |
24 #define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11 | 26 #define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11 |
25 | 27 |
26 /* | 28 /* |
27 * This is the base class for a series of interfaces. This base class *MUST* re
main abstract with | 29 * This is the base class for a series of interfaces. This base class *MUST* re
main abstract with |
28 * NO data members because it is used in multiple interface inheritance. | 30 * NO data members because it is used in multiple interface inheritance. |
29 * Heirarchy: | 31 * Heirarchy: |
30 * GrGLUniformBuilder | 32 * GrGLUniformBuilder |
31 * / \ | 33 * / \ |
32 * GrGLFPBuilder GrGLGPBuilder | 34 * GrGLFPBuilder GrGLGPBuilder |
33 * \ / | 35 * \ / |
34 * GrGLProgramBuilder(internal use only) | 36 * GrGLProgramBuilder(internal use only) |
35 */ | 37 */ |
36 class GrGLUniformBuilder { | 38 class GrGLUniformBuilder { |
37 public: | 39 public: |
38 enum ShaderVisibility { | 40 enum ShaderVisibility { |
39 kVertex_Visibility = 1 << kVertex_GrShaderType, | 41 kVertex_Visibility = 1 << kVertex_GrShaderType, |
40 kGeometry_Visibility = 1 << kGeometry_GrShaderType, | 42 kGeometry_Visibility = 1 << kGeometry_GrShaderType, |
41 kFragment_Visibility = 1 << kFragment_GrShaderType, | 43 kFragment_Visibility = 1 << kFragment_GrShaderType, |
42 }; | 44 }; |
43 | 45 |
44 virtual ~GrGLUniformBuilder() {} | 46 virtual ~GrGLUniformBuilder() {} |
45 | 47 |
46 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 48 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
47 typedef GrGLProgramDataManager::SeparableVaryingHandle SeparableVaryingHandl
e; | 49 typedef GrGLSLProgramDataManager::SeparableVaryingHandle SeparableVaryingHan
dle; |
48 | 50 |
49 /** Add a uniform variable to the current program, that has visibility in on
e or more shaders. | 51 /** Add a uniform variable to the current program, that has visibility in on
e or more shaders. |
50 visibility is a bitfield of ShaderVisibility values indicating from whic
h shaders the | 52 visibility is a bitfield of ShaderVisibility values indicating from whic
h shaders the |
51 uniform should be accessible. At least one bit must be set. Geometry sha
der uniforms are not | 53 uniform should be accessible. At least one bit must be set. Geometry sha
der uniforms are not |
52 supported at this time. The actual uniform name will be mangled. If outN
ame is not nullptr then | 54 supported at this time. The actual uniform name will be mangled. If outN
ame is not nullptr then |
53 it will refer to the final uniform name after return. Use the addUniform
Array variant to add | 55 it will refer to the final uniform name after return. Use the addUniform
Array variant to add |
54 an array of uniforms. */ | 56 an array of uniforms. */ |
55 UniformHandle addUniform(uint32_t visibility, | 57 UniformHandle addUniform(uint32_t visibility, |
56 GrSLType type, | 58 GrSLType type, |
57 GrSLPrecision precision, | 59 GrSLPrecision precision, |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 const GrGLSLExpr4& coverageIn); | 329 const GrGLSLExpr4& coverageIn); |
328 | 330 |
329 void verify(const GrPrimitiveProcessor&); | 331 void verify(const GrPrimitiveProcessor&); |
330 void verify(const GrXferProcessor&); | 332 void verify(const GrXferProcessor&); |
331 void verify(const GrFragmentProcessor&); | 333 void verify(const GrFragmentProcessor&); |
332 template <class Proc> | 334 template <class Proc> |
333 void emitSamplers(const GrProcessor&, | 335 void emitSamplers(const GrProcessor&, |
334 GrGLSLTextureSampler::TextureSamplerArray* outSamplers, | 336 GrGLSLTextureSampler::TextureSamplerArray* outSamplers, |
335 GrGLInstalledProc<Proc>*); | 337 GrGLInstalledProc<Proc>*); |
336 | 338 |
| 339 bool compileAndAttachShaders(GrGLShaderBuilder& shader, |
| 340 GrGLuint programId, |
| 341 GrGLenum type, |
| 342 SkTDArray<GrGLuint>* shaderIds); |
337 GrGLProgram* finalize(); | 343 GrGLProgram* finalize(); |
338 virtual void bindProgramResourceLocations(GrGLuint programID); | 344 virtual void bindProgramResourceLocations(GrGLuint programID); |
339 bool checkLinkStatus(GrGLuint programID); | 345 bool checkLinkStatus(GrGLuint programID); |
340 virtual void resolveProgramResourceLocations(GrGLuint programID); | 346 virtual void resolveProgramResourceLocations(GrGLuint programID); |
341 void cleanupProgram(GrGLuint programID, const SkTDArray<GrGLuint>& shaderIDs
); | 347 void cleanupProgram(GrGLuint programID, const SkTDArray<GrGLuint>& shaderIDs
); |
342 void cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs); | 348 void cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs); |
343 | 349 |
344 // Subclasses create different programs | 350 // Subclasses create different programs |
345 virtual GrGLProgram* createProgram(GrGLuint programID); | 351 virtual GrGLProgram* createProgram(GrGLuint programID); |
346 | 352 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 GrGLPrimitiveProcessor::TransformsOut fOutCoords; | 411 GrGLPrimitiveProcessor::TransformsOut fOutCoords; |
406 SkTArray<UniformHandle> fSamplerUniforms; | 412 SkTArray<UniformHandle> fSamplerUniforms; |
407 SeparableVaryingInfoArray fSeparableVaryingInfos; | 413 SeparableVaryingInfoArray fSeparableVaryingInfos; |
408 | 414 |
409 friend class GrGLShaderBuilder; | 415 friend class GrGLShaderBuilder; |
410 friend class GrGLVertexBuilder; | 416 friend class GrGLVertexBuilder; |
411 friend class GrGLFragmentShaderBuilder; | 417 friend class GrGLFragmentShaderBuilder; |
412 friend class GrGLGeometryBuilder; | 418 friend class GrGLGeometryBuilder; |
413 }; | 419 }; |
414 #endif | 420 #endif |
OLD | NEW |