| tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrGLShaderBuilder_DEFINED |
| 9 | #define GrGLShaderBuilder_DEFINED |
| 10 | |
| 11 | #include "GrAllocator.h" |
| bsalomon@google.com | 2eaaefd | 2012-10-29 19:51:22 +0000 | [diff] [blame] | 12 | #include "GrBackendEffectFactory.h" |
| bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame^] | 13 | #include "GrColor.h" |
| bsalomon@google.com | a469c28 | 2012-10-24 18:28:34 +0000 | [diff] [blame] | 14 | #include "GrEffect.h" |
| tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 15 | #include "gl/GrGLSL.h" |
| bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 16 | #include "gl/GrGLUniformManager.h" |
| tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 17 | |
| bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 18 | #include <stdarg.h> |
| 19 | |
| bsalomon@google.com | ad5e937 | 2012-07-11 18:11:27 +0000 | [diff] [blame] | 20 | class GrGLContextInfo; |
| bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame] | 21 | class GrEffectStage; |
| bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 22 | |
| tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 23 | /** |
| bsalomon@google.com | eb715c8 | 2012-07-11 15:03:31 +0000 | [diff] [blame] | 24 | Contains all the incremental state of a shader as it is being built,as well as helpers to |
| 25 | manipulate that state. |
| tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 26 | */ |
| tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 27 | class GrGLShaderBuilder { |
| tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 28 | public: |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 29 | /** |
| bsalomon@google.com | 34cccde | 2013-01-04 18:34:30 +0000 | [diff] [blame] | 30 | * Passed to GrGLEffects to add texture reads to their shader code. |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 31 | */ |
| 32 | class TextureSampler { |
| 33 | public: |
| 34 | TextureSampler() |
| bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame^] | 35 | : fConfigComponentMask(0) |
| 36 | , fSamplerUniform(GrGLUniformManager::kInvalidUniformHandle) { |
| 37 | // we will memcpy the first 4 bytes from passed in swizzle. This ensures the string is |
| 38 | // terminated. |
| 39 | fSwizzle[4] = '\0'; |
| 40 | } |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 41 | |
| 42 | TextureSampler(const TextureSampler& other) { *this = other; } |
| 43 | |
| 44 | TextureSampler& operator= (const TextureSampler& other) { |
| bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame^] | 45 | GrAssert(0 == fConfigComponentMask); |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 46 | GrAssert(GrGLUniformManager::kInvalidUniformHandle == fSamplerUniform); |
| 47 | |
| bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame^] | 48 | fConfigComponentMask = other.fConfigComponentMask; |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 49 | fSamplerUniform = other.fSamplerUniform; |
| 50 | return *this; |
| 51 | } |
| 52 | |
| bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame^] | 53 | // bitfield of GrColorComponentFlags present in the texture's config. |
| 54 | uint32_t configComponentMask() const { return fConfigComponentMask; } |
| 55 | |
| 56 | const char* swizzle() const { return fSwizzle; } |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 57 | |
| 58 | private: |
| bsalomon@google.com | 34cccde | 2013-01-04 18:34:30 +0000 | [diff] [blame] | 59 | // The idx param is used to ensure multiple samplers within a single effect have unique |
| bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame^] | 60 | // uniform names. swizzle is a four char max string made up of chars 'r', 'g', 'b', and 'a'. |
| 61 | void init(GrGLShaderBuilder* builder, |
| 62 | uint32_t configComponentMask, |
| 63 | const char* swizzle, |
| 64 | int idx) { |
| 65 | GrAssert(0 == fConfigComponentMask); |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 66 | GrAssert(GrGLUniformManager::kInvalidUniformHandle == fSamplerUniform); |
| 67 | |
| 68 | GrAssert(NULL != builder); |
| bsalomon@google.com | 34cccde | 2013-01-04 18:34:30 +0000 | [diff] [blame] | 69 | SkString name; |
| 70 | name.printf("Sampler%d_", idx); |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 71 | fSamplerUniform = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, |
| 72 | kSampler2D_GrSLType, |
| bsalomon@google.com | 34cccde | 2013-01-04 18:34:30 +0000 | [diff] [blame] | 73 | name.c_str()); |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 74 | GrAssert(GrGLUniformManager::kInvalidUniformHandle != fSamplerUniform); |
| 75 | |
| bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame^] | 76 | fConfigComponentMask = configComponentMask; |
| 77 | memcpy(fSwizzle, swizzle, 4); |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame^] | 80 | void init(GrGLShaderBuilder* builder, const GrTextureAccess* access, int idx) { |
| 81 | GrAssert(NULL != access); |
| 82 | this->init(builder, |
| 83 | GrPixelConfigComponentMask(access->getTexture()->config()), |
| 84 | access->getSwizzle(), |
| 85 | idx); |
| 86 | } |
| 87 | |
| 88 | uint32_t fConfigComponentMask; |
| 89 | char fSwizzle[5]; |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 90 | GrGLUniformManager::UniformHandle fSamplerUniform; |
| 91 | |
| bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame^] | 92 | friend class GrGLShaderBuilder; // to call init(). |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | typedef SkTArray<TextureSampler> TextureSamplerArray; |
| 96 | |
| bsalomon@google.com | eb715c8 | 2012-07-11 15:03:31 +0000 | [diff] [blame] | 97 | enum ShaderType { |
| 98 | kVertex_ShaderType = 0x1, |
| 99 | kGeometry_ShaderType = 0x2, |
| 100 | kFragment_ShaderType = 0x4, |
| 101 | }; |
| 102 | |
| bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame] | 103 | GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&, bool explicitLocalCoords); |
| tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 104 | |
| bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 105 | /** |
| 106 | * Called by GrGLEffects to add code to one of the shaders. |
| 107 | */ |
| 108 | void vsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { |
| 109 | va_list args; |
| 110 | va_start(args, format); |
| 111 | this->codeAppendf(kVertex_ShaderType, format, args); |
| 112 | va_end(args); |
| 113 | } |
| 114 | |
| 115 | void gsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { |
| 116 | va_list args; |
| 117 | va_start(args, format); |
| 118 | this->codeAppendf(kGeometry_ShaderType, format, args); |
| 119 | va_end(args); |
| 120 | } |
| 121 | |
| 122 | void fsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { |
| 123 | va_list args; |
| 124 | va_start(args, format); |
| 125 | this->codeAppendf(kFragment_ShaderType, format, args); |
| 126 | va_end(args); |
| 127 | } |
| 128 | |
| 129 | void vsCodeAppend(const char* str) { this->codeAppend(kVertex_ShaderType, str); } |
| 130 | void gsCodeAppend(const char* str) { this->codeAppend(kGeometry_ShaderType, str); } |
| 131 | void fsCodeAppend(const char* str) { this->codeAppend(kFragment_ShaderType, str); } |
| 132 | |
| bsalomon@google.com | dbe49f7 | 2012-11-05 16:36:02 +0000 | [diff] [blame] | 133 | /** Appends a 2D texture sample with projection if necessary. coordType must either be Vec2f or |
| 134 | Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle |
| 135 | order of the result depends on the GrTextureAccess associated with the TextureSampler. */ |
| bsalomon@google.com | 868a8e7 | 2012-08-30 19:11:34 +0000 | [diff] [blame] | 136 | void appendTextureLookup(SkString* out, |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 137 | const TextureSampler&, |
| bsalomon@google.com | dbe49f7 | 2012-11-05 16:36:02 +0000 | [diff] [blame] | 138 | const char* coordName, |
| bsalomon@google.com | 868a8e7 | 2012-08-30 19:11:34 +0000 | [diff] [blame] | 139 | GrSLType coordType = kVec2f_GrSLType) const; |
| tomhudson@google.com | 5259814 | 2012-05-24 17:44:30 +0000 | [diff] [blame] | 140 | |
| bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 141 | /** Version of above that appends the result to the shader code rather than an SkString. |
| 142 | Currently the shader type must be kFragment */ |
| 143 | void appendTextureLookup(ShaderType, |
| 144 | const TextureSampler&, |
| 145 | const char* coordName, |
| 146 | GrSLType coordType = kVec2f_GrSLType); |
| 147 | |
| 148 | |
| bsalomon@google.com | 2d8edaf | 2012-09-07 14:47:31 +0000 | [diff] [blame] | 149 | /** Does the work of appendTextureLookup and modulates the result by modulation. The result is |
| 150 | always a vec4. modulation and the swizzle specified by TextureSampler must both be vec4 or |
| 151 | float. If modulation is "" or NULL it this function acts as though appendTextureLookup were |
| 152 | called. */ |
| bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 153 | void appendTextureLookupAndModulate(ShaderType, |
| bsalomon@google.com | 868a8e7 | 2012-08-30 19:11:34 +0000 | [diff] [blame] | 154 | const char* modulation, |
| bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 155 | const TextureSampler&, |
| bsalomon@google.com | dbe49f7 | 2012-11-05 16:36:02 +0000 | [diff] [blame] | 156 | const char* coordName, |
| bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 157 | GrSLType coordType = kVec2f_GrSLType); |
| bsalomon@google.com | 34bcb9f | 2012-08-28 18:20:18 +0000 | [diff] [blame] | 158 | |
| bsalomon@google.com | a1bf0ff | 2012-08-07 17:36:29 +0000 | [diff] [blame] | 159 | /** Emits a helper function outside of main(). Currently ShaderType must be |
| 160 | kFragment_ShaderType. */ |
| 161 | void emitFunction(ShaderType shader, |
| 162 | GrSLType returnType, |
| 163 | const char* name, |
| 164 | int argCnt, |
| 165 | const GrGLShaderVar* args, |
| 166 | const char* body, |
| 167 | SkString* outName); |
| 168 | |
| bsalomon@google.com | 46fba0d | 2012-10-25 21:42:05 +0000 | [diff] [blame] | 169 | /** Generates a EffectKey for the shader code based on the texture access parameters and the |
| twiz@google.com | a5e65ec | 2012-08-02 15:15:16 +0000 | [diff] [blame] | 170 | capabilities of the GL context. This is useful for keying the shader programs that may |
| 171 | have multiple representations, based on the type/format of textures used. */ |
| bsalomon@google.com | 2eaaefd | 2012-10-29 19:51:22 +0000 | [diff] [blame] | 172 | static GrBackendEffectFactory::EffectKey KeyForTextureAccess(const GrTextureAccess&, |
| 173 | const GrGLCaps&); |
| twiz@google.com | a5e65ec | 2012-08-02 15:15:16 +0000 | [diff] [blame] | 174 | |
| bsalomon@google.com | 6d003d1 | 2012-09-11 15:45:20 +0000 | [diff] [blame] | 175 | /** If texture swizzling is available using tex parameters then it is preferred over mangling |
| 176 | the generated shader code. This potentially allows greater reuse of cached shaders. */ |
| 177 | static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps); |
| 178 | |
| bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 179 | /** Add a uniform variable to the current program, that has visibility in one or more shaders. |
| bsalomon@google.com | 777c3aa | 2012-07-25 20:58:20 +0000 | [diff] [blame] | 180 | visibility is a bitfield of ShaderType values indicating from which shaders the uniform |
| 181 | should be accessible. At least one bit must be set. Geometry shader uniforms are not |
| 182 | supported at this time. The actual uniform name will be mangled. If outName is not NULL then |
| 183 | it will refer to the final uniform name after return. Use the addUniformArray variant to add |
| 184 | an array of uniforms. |
| tomhudson@google.com | 242ed6f | 2012-05-30 17:38:57 +0000 | [diff] [blame] | 185 | */ |
| bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 186 | GrGLUniformManager::UniformHandle addUniform(uint32_t visibility, |
| 187 | GrSLType type, |
| 188 | const char* name, |
| bsalomon@google.com | 777c3aa | 2012-07-25 20:58:20 +0000 | [diff] [blame] | 189 | const char** outName = NULL) { |
| 190 | return this->addUniformArray(visibility, type, name, GrGLShaderVar::kNonArray, outName); |
| 191 | } |
| 192 | GrGLUniformManager::UniformHandle addUniformArray(uint32_t visibility, |
| 193 | GrSLType type, |
| 194 | const char* name, |
| 195 | int arrayCount, |
| 196 | const char** outName = NULL); |
| bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 197 | |
| bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 198 | const GrGLShaderVar& getUniformVariable(GrGLUniformManager::UniformHandle) const; |
| bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 199 | |
| 200 | /** |
| bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 201 | * Shortcut for getUniformVariable(u).c_str() |
| bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 202 | */ |
| bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 203 | const char* getUniformCStr(GrGLUniformManager::UniformHandle u) const { |
| bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 204 | return this->getUniformVariable(u).c_str(); |
| 205 | } |
| tomhudson@google.com | 242ed6f | 2012-05-30 17:38:57 +0000 | [diff] [blame] | 206 | |
| commit-bot@chromium.org | ff6ea26 | 2013-03-12 12:26:08 +0000 | [diff] [blame] | 207 | /** Add a vertex attribute to the current program that is passed in from the vertex data. |
| 208 | Returns false if the attribute was already there, true otherwise. */ |
| 209 | bool addAttribute(GrSLType type, const char* name); |
| 210 | |
| 211 | /** Add a varying variable to the current program to pass values between vertex and fragment |
| bsalomon@google.com | eb715c8 | 2012-07-11 15:03:31 +0000 | [diff] [blame] | 212 | shaders. If the last two parameters are non-NULL, they are filled in with the name |
| 213 | generated. */ |
| tomhudson@google.com | 23cb229 | 2012-05-30 18:26:03 +0000 | [diff] [blame] | 214 | void addVarying(GrSLType type, |
| 215 | const char* name, |
| 216 | const char** vsOutName = NULL, |
| 217 | const char** fsInName = NULL); |
| 218 | |
| bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 219 | /** Returns a variable name that represents the position of the fragment in the FS. The position |
| 220 | is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */ |
| 221 | const char* fragmentPosition(); |
| 222 | |
| bsalomon@google.com | 17504f5 | 2012-10-30 12:34:25 +0000 | [diff] [blame] | 223 | /** Returns a vertex attribute that represents the vertex position in the VS. This is the |
| 224 | pre-matrix position and is commonly used by effects to compute texture coords via a matrix. |
| 225 | */ |
| 226 | const GrGLShaderVar& positionAttribute() const { return *fPositionVar; } |
| 227 | |
| bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame] | 228 | /** Returns a vertex attribute that represents the local coords in the VS. This may be the same |
| 229 | as positionAttribute() or it may not be. It depends upon whether the rendering code |
| 230 | specified explicit local coords or not in the GrDrawState. */ |
| 231 | const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar; } |
| 232 | |
| 233 | /** |
| 234 | * Are explicit local coordinates provided as input to the vertex shader. |
| 235 | */ |
| 236 | bool hasExplicitLocalCoords() const { return (fLocalCoordsVar != fPositionVar); } |
| 237 | |
| bsalomon@google.com | 34cccde | 2013-01-04 18:34:30 +0000 | [diff] [blame] | 238 | /** |
| 239 | * Interfaces used by GrGLProgram. |
| 240 | * TODO: Hide these from the GrEffects using friend or splitting this into two related classes. |
| 241 | * Also, GrGLProgram's shader string construction should be moved to this class. |
| 242 | */ |
| 243 | |
| bsalomon@google.com | ad5e937 | 2012-07-11 18:11:27 +0000 | [diff] [blame] | 244 | /** Called after building is complete to get the final shader string. */ |
| 245 | void getShader(ShaderType, SkString*) const; |
| 246 | |
| bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 247 | void setCurrentStage(int stageIdx) { fCurrentStageIdx = stageIdx; } |
| 248 | void setNonStage() { fCurrentStageIdx = kNonStageIdx; } |
| bsalomon@google.com | 34cccde | 2013-01-04 18:34:30 +0000 | [diff] [blame] | 249 | // TODO: move remainder of shader code generation to this class and call this privately |
| 250 | // Handles of sampler uniforms generated for the effect are appended to samplerHandles. |
| 251 | GrGLEffect* createAndEmitGLEffect( |
| 252 | const GrEffectStage& stage, |
| 253 | GrBackendEffectFactory::EffectKey key, |
| 254 | const char* fsInColor, // NULL means no incoming color |
| 255 | const char* fsOutColor, |
| bsalomon@google.com | 34cccde | 2013-01-04 18:34:30 +0000 | [diff] [blame] | 256 | SkTArray<GrGLUniformManager::UniformHandle, true>* samplerHandles); |
| bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 257 | GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHeightUniform; } |
| commit-bot@chromium.org | ff6ea26 | 2013-03-12 12:26:08 +0000 | [diff] [blame] | 258 | |
| 259 | struct AttributePair { |
| 260 | void set(int index, const SkString& name) { |
| 261 | fIndex = index; fName = name; |
| 262 | } |
| 263 | int fIndex; |
| 264 | SkString fName; |
| 265 | }; |
| 266 | const SkSTArray<10, AttributePair, true>& getEffectAttributes() const { |
| 267 | return fEffectAttributes; |
| 268 | } |
| 269 | const SkString* getEffectAttributeName(int attributeIndex) const; |
| 270 | |
| bsalomon@google.com | 34cccde | 2013-01-04 18:34:30 +0000 | [diff] [blame] | 271 | // TODO: Make this do all the compiling, linking, etc. |
| 272 | void finished(GrGLuint programID); |
| bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 273 | |
| robertphillips@google.com | 13f181f | 2013-03-02 12:02:08 +0000 | [diff] [blame] | 274 | const GrGLContextInfo& ctxInfo() const { return fCtxInfo; } |
| 275 | |
| bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 276 | private: |
| bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 277 | void codeAppendf(ShaderType type, const char format[], va_list args); |
| 278 | void codeAppend(ShaderType type, const char* str); |
| 279 | |
| bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 280 | typedef GrTAllocator<GrGLShaderVar> VarArray; |
| 281 | |
| bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 282 | void appendDecls(const VarArray&, SkString*) const; |
| 283 | void appendUniformDecls(ShaderType, SkString*) const; |
| 284 | |
| bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 285 | typedef GrGLUniformManager::BuilderUniform BuilderUniform; |
| 286 | GrGLUniformManager::BuilderUniformArray fUniforms; |
| bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 287 | |
| bsalomon@google.com | eb715c8 | 2012-07-11 15:03:31 +0000 | [diff] [blame] | 288 | // TODO: Everything below here private. |
| bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 289 | public: |
| bsalomon@google.com | eb715c8 | 2012-07-11 15:03:31 +0000 | [diff] [blame] | 290 | |
| bsalomon@google.com | f0a104e | 2012-07-10 17:51:07 +0000 | [diff] [blame] | 291 | SkString fHeader; // VS+FS, GLSL version, etc |
| bsalomon@google.com | f0a104e | 2012-07-10 17:51:07 +0000 | [diff] [blame] | 292 | VarArray fVSAttrs; |
| 293 | VarArray fVSOutputs; |
| 294 | VarArray fGSInputs; |
| 295 | VarArray fGSOutputs; |
| 296 | VarArray fFSInputs; |
| 297 | SkString fGSHeader; // layout qualifiers specific to GS |
| bsalomon@google.com | f0a104e | 2012-07-10 17:51:07 +0000 | [diff] [blame] | 298 | VarArray fFSOutputs; |
| bsalomon@google.com | f0a104e | 2012-07-10 17:51:07 +0000 | [diff] [blame] | 299 | bool fUsesGS; |
| tomhudson@google.com | 040c41a | 2012-05-18 14:57:40 +0000 | [diff] [blame] | 300 | |
| bsalomon@google.com | ad5e937 | 2012-07-11 18:11:27 +0000 | [diff] [blame] | 301 | private: |
| bsalomon@google.com | 777c3aa | 2012-07-25 20:58:20 +0000 | [diff] [blame] | 302 | enum { |
| 303 | kNonStageIdx = -1, |
| 304 | }; |
| 305 | |
| robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 306 | const GrGLContextInfo& fCtxInfo; |
| bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 307 | GrGLUniformManager& fUniformManager; |
| bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 308 | int fCurrentStageIdx; |
| bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 309 | SkString fFSFunctions; |
| 310 | SkString fFSHeader; |
| 311 | |
| bsalomon@google.com | f910d3b | 2013-03-07 17:06:57 +0000 | [diff] [blame] | 312 | SkString fFSCode; |
| 313 | SkString fVSCode; |
| 314 | SkString fGSCode; |
| 315 | |
| bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 316 | bool fSetupFragPosition; |
| 317 | GrGLUniformManager::UniformHandle fRTHeightUniform; |
| bsalomon@google.com | 34bcb9f | 2012-08-28 18:20:18 +0000 | [diff] [blame] | 318 | |
| commit-bot@chromium.org | ff6ea26 | 2013-03-12 12:26:08 +0000 | [diff] [blame] | 319 | SkSTArray<10, AttributePair, true> fEffectAttributes; |
| 320 | |
| bsalomon@google.com | 17504f5 | 2012-10-30 12:34:25 +0000 | [diff] [blame] | 321 | GrGLShaderVar* fPositionVar; |
| bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame] | 322 | GrGLShaderVar* fLocalCoordsVar; |
| 323 | |
| tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 324 | }; |
| 325 | |
| 326 | #endif |