GrGLShaderBuilder.h revision 422e81aeb1f4078367c85efe591c7df8c33874ec
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"
12a469c28c3c16214733a25201a286970f57b3d944bsalomon@google.com#include "GrEffect.h"
13f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com#include "gl/GrGLShaderVar.h"
14f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com#include "gl/GrGLSL.h"
15dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com#include "gl/GrGLUniformManager.h"
16f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com
17ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.comclass GrGLContextInfo;
18dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com
19f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com/**
20eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com  Contains all the incremental state of a shader as it is being built,as well as helpers to
21eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com  manipulate that state.
22f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com*/
23f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.comclass GrGLShaderBuilder {
24f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.compublic:
25f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    /**
26422e81aeb1f4078367c85efe591c7df8c33874ecbsalomon@google.com     * Used by GrGLEffects to add texture reads to their shader code.
27f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com     */
28f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    class TextureSampler {
29f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    public:
30f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        TextureSampler()
31f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            : fTextureAccess(NULL)
32f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            , fSamplerUniform(GrGLUniformManager::kInvalidUniformHandle) {}
33f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
34f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        TextureSampler(const TextureSampler& other) { *this = other; }
35f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
36f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        TextureSampler& operator= (const TextureSampler& other) {
37f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(NULL == fTextureAccess);
38f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(GrGLUniformManager::kInvalidUniformHandle == fSamplerUniform);
39f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
40f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            fTextureAccess = other.fTextureAccess;
41f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            fSamplerUniform = other.fSamplerUniform;
42f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            return *this;
43f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        }
44f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
45f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        const GrTextureAccess* textureAccess() const { return fTextureAccess; }
46f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
47f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    private:
48f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        void init(GrGLShaderBuilder* builder, const GrTextureAccess* access) {
49f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(NULL == fTextureAccess);
50f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(GrGLUniformManager::kInvalidUniformHandle == fSamplerUniform);
51f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
52f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(NULL != builder);
53f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(NULL != access);
54f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            fSamplerUniform = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
55f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com                                                  kSampler2D_GrSLType,
56f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com                                                  "Sampler");
57f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            GrAssert(GrGLUniformManager::kInvalidUniformHandle != fSamplerUniform);
58f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
59f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com            fTextureAccess = access;
60f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        }
61f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
62f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        const GrTextureAccess*            fTextureAccess;
63f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        GrGLUniformManager::UniformHandle fSamplerUniform;
64f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
65f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        friend class GrGLShaderBuilder; // to access fSamplerUniform
66f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com        friend class GrGLProgram;       // to construct these and access fSamplerUniform.
67f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    };
68f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
69f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    typedef SkTArray<TextureSampler> TextureSamplerArray;
70f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
71eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com    enum ShaderType {
72eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        kVertex_ShaderType   = 0x1,
73eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        kGeometry_ShaderType = 0x2,
74eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        kFragment_ShaderType = 0x4,
75eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com    };
76eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com
77dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&);
78f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com
79eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com    /** Determines whether we should use texture2D() or texture2Dproj(), and if an explicit divide
80eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        is required for the sample coordinates, creates the new variable and emits the code to
8134bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com        initialize it. This should only be called by GrGLProgram.*/
8234bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    void setupTextureAccess(const char* varyingFSName, GrSLType varyingType);
835259814305e3290dea3b197301f7824a14c5fa6ftomhudson@google.com
842d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com    /** Appends a texture sample with projection if necessary; if coordName is not
8534bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com        specified, uses fSampleCoords. coordType must either be Vec2f or Vec3f. The latter is
862d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com        interpreted as projective texture coords. The vec length and swizzle order of the result
872d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com        depends on the GrTextureAccess associated with the TextureSampler. */
88868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com    void appendTextureLookup(SkString* out,
89f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com                             const TextureSampler&,
90868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com                             const char* coordName = NULL,
91868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com                             GrSLType coordType = kVec2f_GrSLType) const;
92868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com
932d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com    /** Does the work of appendTextureLookup and modulates the result by modulation. The result is
942d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com        always a vec4. modulation and the swizzle specified by TextureSampler must both be vec4 or
952d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com        float. If modulation is "" or NULL it this function acts as though appendTextureLookup were
962d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com        called. */
97868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com    void appendTextureLookupAndModulate(SkString* out,
98868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com                                        const char* modulation,
99f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com                                        const TextureSampler&,
100868a8e7fc83e9ac6ee1418e75b84a0595605626cbsalomon@google.com                                        const char* coordName = NULL,
1012d8edaf17510e50261b8a4e2a0daf7e617674999bsalomon@google.com                                        GrSLType coordType = kVec2f_GrSLType) const;
10234bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com
10334bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    /** Gets the name of the default texture coords which are always kVec2f */
10434bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    const char* defaultTexCoordsName() const { return fDefaultTexCoordsName.c_str(); }
10534bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com
10634bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    /* Returns true if the texture matrix from which the default texture coords are computed has
10734bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com       perspective. */
10834bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    bool defaultTextureMatrixIsPerspective() const {
10934bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com        return fTexCoordVaryingType == kVec3f_GrSLType;
11034bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    }
1115259814305e3290dea3b197301f7824a14c5fa6ftomhudson@google.com
112a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com    /** Emits a helper function outside of main(). Currently ShaderType must be
113a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com        kFragment_ShaderType. */
114a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com    void emitFunction(ShaderType shader,
115a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      GrSLType returnType,
116a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      const char* name,
117a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      int argCnt,
118a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      const GrGLShaderVar* args,
119a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      const char* body,
120a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com                      SkString* outName);
121a1bf0fffff821d9c11809c89bd98d4ced480421absalomon@google.com
122a5e65ec434fed44dc616e4f64950b835b541181btwiz@google.com    /** Generates a StageKey for the shader code based on the texture access parameters and the
123a5e65ec434fed44dc616e4f64950b835b541181btwiz@google.com        capabilities of the GL context.  This is useful for keying the shader programs that may
124a5e65ec434fed44dc616e4f64950b835b541181btwiz@google.com        have multiple representations, based on the type/format of textures used. */
125a469c28c3c16214733a25201a286970f57b3d944bsalomon@google.com    static GrEffect::StageKey KeyForTextureAccess(const GrTextureAccess& access,
126a5e65ec434fed44dc616e4f64950b835b541181btwiz@google.com                                                       const GrGLCaps& caps);
127a5e65ec434fed44dc616e4f64950b835b541181btwiz@google.com
1286d003d1ddced3e71684b8b3785d1e5a16255688dbsalomon@google.com    /** If texture swizzling is available using tex parameters then it is preferred over mangling
1296d003d1ddced3e71684b8b3785d1e5a16255688dbsalomon@google.com        the generated shader code. This potentially allows greater reuse of cached shaders. */
1306d003d1ddced3e71684b8b3785d1e5a16255688dbsalomon@google.com    static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps);
1316d003d1ddced3e71684b8b3785d1e5a16255688dbsalomon@google.com
132706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    /** Add a uniform variable to the current program, that has visibility in one or more shaders.
133777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        visibility is a bitfield of ShaderType values indicating from which shaders the uniform
134777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        should be accessible. At least one bit must be set. Geometry shader uniforms are not
135777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        supported at this time. The actual uniform name will be mangled. If outName is not NULL then
136777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        it will refer to the final uniform name after return. Use the addUniformArray variant to add
137777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        an array of uniforms.
138242ed6fb6c3c0dff780ed3bef47d36a3b34a352ctomhudson@google.com    */
139dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    GrGLUniformManager::UniformHandle addUniform(uint32_t visibility,
140dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com                                                 GrSLType type,
141dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com                                                 const char* name,
142777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                 const char** outName = NULL) {
143777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        return this->addUniformArray(visibility, type, name, GrGLShaderVar::kNonArray, outName);
144777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    }
145777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    GrGLUniformManager::UniformHandle addUniformArray(uint32_t visibility,
146777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                      GrSLType type,
147777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                      const char* name,
148777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                      int arrayCount,
149777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com                                                      const char** outName = NULL);
150032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
151dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    const GrGLShaderVar& getUniformVariable(GrGLUniformManager::UniformHandle) const;
152032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
153032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com    /**
154706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com     * Shortcut for getUniformVariable(u).c_str()
155032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com     */
156dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    const char* getUniformCStr(GrGLUniformManager::UniformHandle u) const {
157032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com        return this->getUniformVariable(u).c_str();
158032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com    }
159eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com
160eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com    /** Add a varying variable to the current program to pass values between vertex and fragment
161eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        shaders. If the last two parameters are non-NULL, they are filled in with the name
162eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com        generated. */
16323cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com    void addVarying(GrSLType type,
16423cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com                    const char* name,
16523cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com                    const char** vsOutName = NULL,
16623cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com                    const char** fsInName = NULL);
16723cb2299ddf8fc87df0d3f9bda78934382cf714dtomhudson@google.com
168706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    /** Returns a variable name that represents the position of the fragment in the FS. The position
169706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com        is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */
170706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    const char* fragmentPosition();
171706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com
172ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.com    /** Called after building is complete to get the final shader string. */
173ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.com    void getShader(ShaderType, SkString*) const;
174ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.com
175dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    /**
176f271cc7183fe48ac64d2d9a454eb013c91b42d53bsalomon@google.com     * TODO: Make this do all the compiling, linking, etc. Hide from the GrEffects
177dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com     */
178dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    void finished(GrGLuint programID);
179dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com
180777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    /**
181777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com     * Sets the current stage (used to make variable names unique).
182f271cc7183fe48ac64d2d9a454eb013c91b42d53bsalomon@google.com     * TODO: Hide from the GrEffects
183777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com     */
184777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    void setCurrentStage(int stage) { fCurrentStage = stage; }
185777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    void setNonStage() { fCurrentStage = kNonStageIdx; }
186777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com
187706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHeightUniform; }
188706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com
189032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.comprivate:
190032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
191dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    typedef GrTAllocator<GrGLShaderVar> VarArray;
192032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
193032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com    void appendDecls(const VarArray&, SkString*) const;
194032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com    void appendUniformDecls(ShaderType, SkString*) const;
195032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
196dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    typedef GrGLUniformManager::BuilderUniform BuilderUniform;
197dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    GrGLUniformManager::BuilderUniformArray fUniforms;
198032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.com
199eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com    // TODO: Everything below here private.
200032b221dadb6eb8283ac2d1bc8913ee7bb5cfe7absalomon@google.compublic:
201eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02bsalomon@google.com
202f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fHeader; // VS+FS, GLSL version, etc
203f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fVSAttrs;
204f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fVSOutputs;
205f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fGSInputs;
206f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fGSOutputs;
207f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fFSInputs;
208f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fGSHeader; // layout qualifiers specific to GS
209f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    VarArray    fFSOutputs;
210f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fVSCode;
211f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fGSCode;
212f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    SkString    fFSCode;
213f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com    bool        fUsesGS;
214040c41a97c58b069015be3f5062eeb6ffe5adbfdtomhudson@google.com
215ad5e937c110efaf9630159d2859fabc4f38f7ab2bsalomon@google.comprivate:
216777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    enum {
217777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com        kNonStageIdx = -1,
218777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com    };
219777c3aab0a902b0917871080d99b0a249ec06298bsalomon@google.com
220706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    const GrGLContextInfo&              fContext;
221706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    GrGLUniformManager&                 fUniformManager;
222706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    int                                 fCurrentStage;
223706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    SkString                            fFSFunctions;
224706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    SkString                            fFSHeader;
225706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com
226706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    bool                                fSetupFragPosition;
227706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    GrGLUniformManager::UniformHandle   fRTHeightUniform;
22834bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com
22934bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    /// Per-stage settings - only valid while we're inside GrGLProgram::genStageCode().
23034bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    //@{
23134bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    GrSLType         fTexCoordVaryingType;  // the type, either Vec2f or Vec3f, of the coords passed
23234bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com                                            // as a varying from the VS to the FS.
23334bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    SkString         fDefaultTexCoordsName; // the name of the default 2D coords value.
23434bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com    //@}
23534bcb9f80336fe0dc56ad5f67aeb0859bf84d92ebsalomon@google.com
236f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com};
237f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com
238f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.com#endif
239