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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 * This class manages a GPU program and records per-program information. | 27 * This class manages a GPU program and records per-program information. |
28 * We can specify the attribute locations so that they are constant | 28 * We can specify the attribute locations so that they are constant |
29 * across our shaders. But the driver determines the uniform locations | 29 * across our shaders. But the driver determines the uniform locations |
30 * at link time. We don't need to remember the sampler uniform location | 30 * 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 | 31 * 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 | 32 * Uniforms are program-local so we can't rely on fHWState to hold the |
33 * previous uniform state after a program change. | 33 * previous uniform state after a program change. |
34 */ | 34 */ |
35 class GrGLProgram : public SkRefCnt { | 35 class GrGLProgram : public SkRefCnt { |
36 public: | 36 public: |
37 | |
38 | |
39 typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles; | 37 typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles; |
40 | 38 |
41 virtual ~GrGLProgram(); | 39 virtual ~GrGLProgram(); |
42 | 40 |
43 /** | 41 /** |
44 * Call to abandon GL objects owned by this program. | 42 * Call to abandon GL objects owned by this program. |
45 */ | 43 */ |
46 void abandon(); | 44 void abandon(); |
47 | 45 |
48 const GrProgramDesc& getDesc() { return fDesc; } | 46 const GrProgramDesc& getDesc() { return fDesc; } |
(...skipping 44 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 | 91 * 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 | 92 * 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.) | 93 * units upon return. (Each index in the array corresponds to its matching G
L texture unit.) |
96 */ | 94 */ |
97 void setData(const GrPrimitiveProcessor&, const GrPipeline&, | 95 void setData(const GrPrimitiveProcessor&, const GrPipeline&, |
98 SkTArray<const GrTextureAccess*>* textureBindings); | 96 SkTArray<const GrTextureAccess*>* textureBindings); |
99 | 97 |
100 protected: | 98 protected: |
101 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 99 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
102 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 100 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
| 101 typedef GrGLProgramDataManager::SeparableVaryingInfoArray SeparableVaryingIn
foArray; |
103 | 102 |
104 GrGLProgram(GrGLGpu*, | 103 GrGLProgram(GrGLGpu*, |
105 const GrProgramDesc&, | 104 const GrProgramDesc&, |
106 const BuiltinUniformHandles&, | 105 const BuiltinUniformHandles&, |
107 GrGLuint programID, | 106 GrGLuint programID, |
108 const UniformInfoArray&, | 107 const UniformInfoArray&, |
| 108 const SeparableVaryingInfoArray&, |
109 GrGLInstalledGeoProc* geometryProcessor, | 109 GrGLInstalledGeoProc* geometryProcessor, |
110 GrGLInstalledXferProc* xferProcessor, | 110 GrGLInstalledXferProc* xferProcessor, |
111 GrGLInstalledFragProcs* fragmentProcessors, | 111 GrGLInstalledFragProcs* fragmentProcessors, |
112 SkTArray<UniformHandle>* passSamplerUniforms); | 112 SkTArray<UniformHandle>* passSamplerUniforms); |
113 | 113 |
114 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures | 114 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures |
115 void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&, | 115 void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&, |
116 SkTArray<const GrTextureAccess*>* textureBindings); | 116 SkTArray<const GrTextureAccess*>* textureBindings); |
117 virtual void setTransformData(const GrPrimitiveProcessor&, | 117 virtual void setTransformData(const GrPrimitiveProcessor&, |
118 const GrFragmentProcessor&, | 118 const GrFragmentProcessor&, |
119 int index, | 119 int index, |
120 GrGLInstalledFragProc*); | 120 GrGLInstalledFragProc*); |
121 | 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 | |
128 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform | 122 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform |
129 void setRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&); | 123 void setRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&); |
130 virtual void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrPip
eline&); | 124 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 |