OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 8 |
9 #ifndef GrGLProgram_DEFINED | 9 #ifndef GrGLProgram_DEFINED |
10 #define GrGLProgram_DEFINED | 10 #define GrGLProgram_DEFINED |
11 | 11 |
12 #include "builders/GrGLProgramBuilder.h" | |
13 #include "GrGLContext.h" | 12 #include "GrGLContext.h" |
14 #include "GrGLProgramDesc.h" | 13 #include "GrGLProgramDesc.h" |
15 #include "GrGLTexture.h" | 14 #include "GrGLTexture.h" |
16 #include "GrGLProgramDataManager.h" | 15 #include "GrGLProgramDataManager.h" |
17 | 16 |
18 #include "SkString.h" | 17 #include "SkString.h" |
19 #include "SkXfermode.h" | 18 #include "SkXfermode.h" |
20 | 19 |
| 20 #include "builders/GrGLProgramBuilder.h" |
| 21 |
21 class GrGLProcessor; | 22 class GrGLProcessor; |
22 class GrGLInstalledProcessors; | 23 class GrGLInstalledProcessors; |
23 class GrGLProgramBuilder; | 24 class GrGLProgramBuilder; |
24 class GrPipeline; | 25 class GrPipeline; |
25 | 26 |
26 /** | 27 /** |
27 * This class manages a GPU program and records per-program information. | 28 * This class manages a GPU program and records per-program information. |
28 * We can specify the attribute locations so that they are constant | 29 * We can specify the attribute locations so that they are constant |
29 * across our shaders. But the driver determines the uniform locations | 30 * across our shaders. But the driver determines the uniform locations |
30 * at link time. We don't need to remember the sampler uniform location | 31 * at link time. We don't need to remember the sampler uniform location |
31 * because we will bind a texture slot to it and never change it | 32 * because we will bind a texture slot to it and never change it |
32 * Uniforms are program-local so we can't rely on fHWState to hold the | 33 * Uniforms are program-local so we can't rely on fHWState to hold the |
33 * previous uniform state after a program change. | 34 * previous uniform state after a program change. |
34 */ | 35 */ |
35 class GrGLProgram : public SkRefCnt { | 36 class GrGLProgram : public SkRefCnt { |
36 public: | 37 public: |
37 | |
38 | |
39 typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles; | 38 typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles; |
40 | 39 |
41 virtual ~GrGLProgram(); | 40 ~GrGLProgram(); |
42 | 41 |
43 /** | 42 /** |
44 * Call to abandon GL objects owned by this program. | 43 * Call to abandon GL objects owned by this program. |
45 */ | 44 */ |
46 void abandon(); | 45 void abandon(); |
47 | 46 |
48 const GrProgramDesc& getDesc() { return fDesc; } | 47 const GrProgramDesc& getDesc() { return fDesc; } |
49 | 48 |
50 /** | 49 /** |
51 * Gets the GL program ID for this program. | 50 * Gets the GL program ID for this program. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 * textures that need to be bound on each unit. It is the caller's responsib
ility to ensure | 92 * textures that need to be bound on each unit. It is the caller's responsib
ility to ensure |
94 * the program is bound before calling, and to bind the outgoing textures to
their respective | 93 * the program is bound before calling, and to bind the outgoing textures to
their respective |
95 * units upon return. (Each index in the array corresponds to its matching G
L texture unit.) | 94 * units upon return. (Each index in the array corresponds to its matching G
L texture unit.) |
96 */ | 95 */ |
97 void setData(const GrPrimitiveProcessor&, const GrPipeline&, | 96 void setData(const GrPrimitiveProcessor&, const GrPipeline&, |
98 SkTArray<const GrTextureAccess*>* textureBindings); | 97 SkTArray<const GrTextureAccess*>* textureBindings); |
99 | 98 |
100 protected: | 99 protected: |
101 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 100 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
102 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 101 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
| 102 typedef GrGLProgramDataManager::SeparableVaryingInfoArray SeparableVaryingIn
foArray; |
103 | 103 |
104 GrGLProgram(GrGLGpu*, | 104 GrGLProgram(GrGLGpu*, |
105 const GrProgramDesc&, | 105 const GrProgramDesc&, |
106 const BuiltinUniformHandles&, | 106 const BuiltinUniformHandles&, |
107 GrGLuint programID, | 107 GrGLuint programID, |
108 const UniformInfoArray&, | 108 const UniformInfoArray&, |
| 109 const SeparableVaryingInfoArray&, |
109 GrGLInstalledGeoProc* geometryProcessor, | 110 GrGLInstalledGeoProc* geometryProcessor, |
110 GrGLInstalledXferProc* xferProcessor, | 111 GrGLInstalledXferProc* xferProcessor, |
111 GrGLInstalledFragProcs* fragmentProcessors, | 112 GrGLInstalledFragProcs* fragmentProcessors, |
112 SkTArray<UniformHandle>* passSamplerUniforms); | 113 SkTArray<UniformHandle>* passSamplerUniforms); |
113 | 114 |
114 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures | 115 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures |
115 void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&, | 116 void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&, |
116 SkTArray<const GrTextureAccess*>* textureBindings); | 117 SkTArray<const GrTextureAccess*>* textureBindings); |
117 virtual void setTransformData(const GrPrimitiveProcessor&, | 118 void setTransformData(const GrPrimitiveProcessor&, |
118 const GrFragmentProcessor&, | 119 const GrFragmentProcessor&, |
119 int index, | 120 int index, |
120 GrGLInstalledFragProc*); | 121 GrGLInstalledFragProc*); |
121 | |
122 /* | |
123 * Legacy NVPR needs a hook here to flush path tex gen settings. | |
124 * TODO when legacy nvpr is removed, remove this call. | |
125 */ | |
126 virtual void didSetData() {} | |
127 | 122 |
128 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform | 123 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform |
129 void setRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&); | 124 void setRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&); |
130 virtual void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrPip
eline&); | |
131 | 125 |
132 // these reflect the current values of uniforms (GL uniform values travel wi
th program) | 126 // these reflect the current values of uniforms (GL uniform values travel wi
th program) |
133 RenderTargetState fRenderTargetState; | 127 RenderTargetState fRenderTargetState; |
134 GrColor fColor; | 128 GrColor fColor; |
135 uint8_t fCoverage; | 129 uint8_t fCoverage; |
136 int fDstTextureUnit; | 130 int fDstTextureUnit; |
137 BuiltinUniformHandles fBuiltinUniformHandles; | 131 BuiltinUniformHandles fBuiltinUniformHandles; |
138 GrGLuint fProgramID; | 132 GrGLuint fProgramID; |
139 | 133 |
140 // the installed effects | 134 // the installed effects |
141 SkAutoTDelete<GrGLInstalledGeoProc> fGeometryProcessor; | 135 SkAutoTDelete<GrGLInstalledGeoProc> fGeometryProcessor; |
142 SkAutoTDelete<GrGLInstalledXferProc> fXferProcessor; | 136 SkAutoTDelete<GrGLInstalledXferProc> fXferProcessor; |
143 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; | 137 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; |
144 | 138 |
145 GrProgramDesc fDesc; | 139 GrProgramDesc fDesc; |
146 GrGLGpu* fGpu; | 140 GrGLGpu* fGpu; |
147 GrGLProgramDataManager fProgramDataManager; | 141 GrGLProgramDataManager fProgramDataManager; |
148 SkTArray<UniformHandle> fSamplerUniforms; | 142 SkTArray<UniformHandle> fSamplerUniforms; |
149 | 143 |
150 friend class GrGLProgramBuilder; | 144 friend class GrGLProgramBuilder; |
151 | 145 |
152 typedef SkRefCnt INHERITED; | 146 typedef SkRefCnt INHERITED; |
153 }; | 147 }; |
154 | 148 |
155 #endif | 149 #endif |
OLD | NEW |