GrGLShaderBuilder.h revision dbe49f735484f8862e378b63d0a074a301093dd0
1f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com/*
2f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com * Copyright 2012 Google Inc.
3f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com *
4f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com * Use of this source code is governed by a BSD-style license that can be
5f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com * found in the LICENSE file.
6f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com */
7f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com
8f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com#ifndef GrGLShaderBuilder_DEFINED
9f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com#define GrGLShaderBuilder_DEFINED
10f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com
11f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com#include "GrAllocator.h"
122eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com#include "GrBackendEffectFactory.h"
13a469c28c3c16214733a25201a286970f57b3d944bsalomon@google.com#include "GrEffect.h"
14f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com#include "gl/GrGLShaderVar.h"
15f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com#include "gl/GrGLSL.h"
16dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com#include "gl/GrGLUniformManager.h"
17f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com
18ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.comclass GrGLContextInfo;
19dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com
20f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com/**
21eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com  Contains all the incremental state of a shader as it is being built,as well as helpers to
22eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com  manipulate that state.
23f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com*/
24f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.comclass GrGLShaderBuilder {
25f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.compublic:
26f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    /**
27422e81aeb1f4078367c85efe591c7df8c33874ecbsalomon@google.com     * Used by GrGLEffects to add texture reads to their shader code.
28f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com     */
29f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    class TextureSampler {
30f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    public:
31f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        TextureSampler()
32f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            : fTextureAccess(NULL)
33f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            , fSamplerUniform(GrGLUniformManager::kInvalidUniformHandle) {}
34f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
35f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        TextureSampler(const TextureSampler& other) { *this = other; }
36f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
37f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        TextureSampler& operator= (const TextureSampler& other) {
38f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(NULL == fTextureAccess);
39f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(GrGLUniformManager::kInvalidUniformHandle == fSamplerUniform);
40f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
41f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            fTextureAccess = other.fTextureAccess;
42f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            fSamplerUniform = other.fSamplerUniform;
43f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            return *this;
44f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        }
45f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
46f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        const GrTextureAccess* textureAccess() const { return fTextureAccess; }
47f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
48f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    private:
49f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        void init(GrGLShaderBuilder* builder, const GrTextureAccess* access) {
50f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(NULL == fTextureAccess);
51f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(GrGLUniformManager::kInvalidUniformHandle == fSamplerUniform);
52f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
53f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(NULL != builder);
54f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(NULL != access);
55f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            fSamplerUniform = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
56f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com                                                  kSampler2D_GrSLType,
57f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com                                                  "Sampler");
58f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(GrGLUniformManager::kInvalidUniformHandle != fSamplerUniform);
59f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
60f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            fTextureAccess = access;
61f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        }
62f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
63f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        const GrTextureAccess*            fTextureAccess;
64f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        GrGLUniformManager::UniformHandle fSamplerUniform;
65f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
66f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        friend class GrGLShaderBuilder; // to access fSamplerUniform
67f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        friend class GrGLProgram;       // to construct these and access fSamplerUniform.
68f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    };
69f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
70f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    typedef SkTArray<TextureSampler> TextureSamplerArray;
71f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
72eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com    enum ShaderType {
73eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        kVertex_ShaderType   = 0x1,
74eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        kGeometry_ShaderType = 0x2,
75eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        kFragment_ShaderType = 0x4,
76eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com    };
77eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com
78dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&);
79f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com
80dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com    /** Appends a 2D texture sample with projection if necessary. coordType must either be Vec2f or
81dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com        Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle
82dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com        order of the result depends on the GrTextureAccess associated with the TextureSampler. */
83868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com    void appendTextureLookup(SkString* out,
84f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com                             const TextureSampler&,
85dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com                             const char* coordName,
86868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com                             GrSLType coordType = kVec2f_GrSLType) const;
87868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com
882d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com    /** Does the work of appendTextureLookup and modulates the result by modulation. The result is
892d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com        always a vec4. modulation and the swizzle specified by TextureSampler must both be vec4 or
902d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com        float. If modulation is "" or NULL it this function acts as though appendTextureLookup were
912d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com        called. */
92868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com    void appendTextureLookupAndModulate(SkString* out,
93868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com                                        const char* modulation,
94f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com                                        const TextureSampler&,
95dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com                                        const char* coordName,
962d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com                                        GrSLType coordType = kVec2f_GrSLType) const;
9734bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com
98a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com    /** Emits a helper function outside of main(). Currently ShaderType must be
99a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com        kFragment_ShaderType. */
100a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com    void emitFunction(ShaderType shader,
101a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      GrSLType returnType,
102a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      const char* name,
103a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      int argCnt,
104a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      const GrGLShaderVar* args,
105a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      const char* body,
106a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      SkString* outName);
107a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com
10846fba0d79335f17429bb71d87a04d93fb2ee992bbsalomon@google.com    /** Generates a EffectKey for the shader code based on the texture access parameters and the
109a5e65ec434fed44dc616e4f64950b835b541181btwiz@google.com        capabilities of the GL context.  This is useful for keying the shader programs that may
110a5e65ec434fed44dc616e4f64950b835b541181btwiz@google.com        have multiple representations, based on the type/format of textures used. */
1112eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com    static GrBackendEffectFactory::EffectKey KeyForTextureAccess(const GrTextureAccess&,
1122eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com                                                                 const GrGLCaps&);
113a5e65ec434fed44dc616e4f64950b835b541181btwiz@google.com
1146d003d1ddced3e71684b8b3785d1e5a16255688dbsalomon@google.com    /** If texture swizzling is available using tex parameters then it is preferred over mangling
1156d003d1ddced3e71684b8b3785d1e5a16255688dbsalomon@google.com        the generated shader code. This potentially allows greater reuse of cached shaders. */
1166d003d1ddced3e71684b8b3785d1e5a16255688dbsalomon@google.com    static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps);
1176d003d1ddced3e71684b8b3785d1e5a16255688dbsalomon@google.com
118706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    /** Add a uniform variable to the current program, that has visibility in one or more shaders.
119777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        visibility is a bitfield of ShaderType values indicating from which shaders the uniform
120777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        should be accessible. At least one bit must be set. Geometry shader uniforms are not
121777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        supported at this time. The actual uniform name will be mangled. If outName is not NULL then
122777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        it will refer to the final uniform name after return. Use the addUniformArray variant to add
123777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        an array of uniforms.
124242ed6fb6c3c0dff780ed3bef47d36a3b34a352ctomhudson@google.com    */
125dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    GrGLUniformManager::UniformHandle addUniform(uint32_t visibility,
126dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com                                                 GrSLType type,
127dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com                                                 const char* name,
128777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                 const char** outName = NULL) {
129777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        return this->addUniformArray(visibility, type, name, GrGLShaderVar::kNonArray, outName);
130777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    }
131777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    GrGLUniformManager::UniformHandle addUniformArray(uint32_t visibility,
132777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                      GrSLType type,
133777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                      const char* name,
134777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                      int arrayCount,
135777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                      const char** outName = NULL);
136032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
137dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    const GrGLShaderVar& getUniformVariable(GrGLUniformManager::UniformHandle) const;
138032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
139032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com    /**
140706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com     * Shortcut for getUniformVariable(u).c_str()
141032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com     */
142dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    const char* getUniformCStr(GrGLUniformManager::UniformHandle u) const {
143032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com        return this->getUniformVariable(u).c_str();
144032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com    }
145eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com
146eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com    /** Add a varying variable to the current program to pass values between vertex and fragment
147eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        shaders. If the last two parameters are non-NULL, they are filled in with the name
148eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        generated. */
14923cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com    void addVarying(GrSLType type,
15023cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com                    const char* name,
15123cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com                    const char** vsOutName = NULL,
15223cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com                    const char** fsInName = NULL);
15323cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com
154706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    /** Returns a variable name that represents the position of the fragment in the FS. The position
155706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com        is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */
156706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    const char* fragmentPosition();
157706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com
15817504f5d5ea2550d29d2118193627129beb7f8b2bsalomon@google.com    /** Returns a vertex attribute that represents the vertex position in the VS. This is the
15917504f5d5ea2550d29d2118193627129beb7f8b2bsalomon@google.com        pre-matrix position and is commonly used by effects to compute texture coords via a matrix.
16017504f5d5ea2550d29d2118193627129beb7f8b2bsalomon@google.com      */
16117504f5d5ea2550d29d2118193627129beb7f8b2bsalomon@google.com    const GrGLShaderVar& positionAttribute() const { return *fPositionVar; }
16217504f5d5ea2550d29d2118193627129beb7f8b2bsalomon@google.com
163ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.com    /** Called after building is complete to get the final shader string. */
164ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.com    void getShader(ShaderType, SkString*) const;
165ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.com
166dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    /**
167f271cc7183fe48ac64d2d9a454eb013c91b42d53bsalomon@google.com     * TODO: Make this do all the compiling, linking, etc. Hide from the GrEffects
168dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com     */
169dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    void finished(GrGLuint programID);
170dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com
171777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    /**
172777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com     * Sets the current stage (used to make variable names unique).
173f271cc7183fe48ac64d2d9a454eb013c91b42d53bsalomon@google.com     * TODO: Hide from the GrEffects
174777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com     */
17508283afc265f1153834256fc1012519813ba6b73bsalomon@google.com    void setCurrentStage(int stageIdx) { fCurrentStageIdx = stageIdx; }
17608283afc265f1153834256fc1012519813ba6b73bsalomon@google.com    void setNonStage() { fCurrentStageIdx = kNonStageIdx; }
177777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com
178706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHeightUniform; }
179706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com
180032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.comprivate:
181032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
182dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    typedef GrTAllocator<GrGLShaderVar> VarArray;
183032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
184032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com    void appendDecls(const VarArray&, SkString*) const;
185032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com    void appendUniformDecls(ShaderType, SkString*) const;
186032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
187dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    typedef GrGLUniformManager::BuilderUniform BuilderUniform;
188dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    GrGLUniformManager::BuilderUniformArray fUniforms;
189032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
190eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com    // TODO: Everything below here private.
191032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.compublic:
192eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com
193f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fHeader; // VS+FS, GLSL version, etc
194f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fVSAttrs;
195f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fVSOutputs;
196f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fGSInputs;
197f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fGSOutputs;
198f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fFSInputs;
199f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fGSHeader; // layout qualifiers specific to GS
200f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fFSOutputs;
201f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fVSCode;
202f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fGSCode;
203f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fFSCode;
204f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    bool        fUsesGS;
205040c41a97c58b069015be3f5062eeb6ffe5adbfdtomhudson@google.com
206ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.comprivate:
207777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    enum {
208777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        kNonStageIdx = -1,
209777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    };
210777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com
211706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    const GrGLContextInfo&              fContext;
212706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    GrGLUniformManager&                 fUniformManager;
21308283afc265f1153834256fc1012519813ba6b73bsalomon@google.com    int                                 fCurrentStageIdx;
214706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    SkString                            fFSFunctions;
215706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    SkString                            fFSHeader;
216706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com
217706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    bool                                fSetupFragPosition;
218706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    GrGLUniformManager::UniformHandle   fRTHeightUniform;
21934bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com
22017504f5d5ea2550d29d2118193627129beb7f8b2bsalomon@google.com    GrGLShaderVar*                      fPositionVar;
221f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com};
222f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com
223f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com#endif
224