blob: 7690b39a8bb2e48c18a43dc98a0315d880995a3f [file] [log] [blame]
joshualitt30ba4362014-08-21 20:18:45 -07001/*
2 * Copyright 2014 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 GrGLProgramBuilder_DEFINED
9#define GrGLProgramBuilder_DEFINED
10
joshualitt30ba4362014-08-21 20:18:45 -070011#include "GrGLFragmentShaderBuilder.h"
12#include "GrGLGeometryShaderBuilder.h"
13#include "GrGLVertexShaderBuilder.h"
egdaniel018fb622015-10-28 07:26:40 -070014#include "glsl/GrGLSLProgramDataManager.h"
joshualitt8072caa2015-02-12 14:20:52 -080015#include "../GrGLPrimitiveProcessor.h"
egdanielc2304142014-12-11 13:15:13 -080016#include "../GrGLXferProcessor.h"
egdaniel8dd688b2015-01-22 10:16:09 -080017#include "../../GrPipeline.h"
joshualitt89c7a2e2014-10-10 14:11:59 -070018
bsalomonac856c92015-08-27 06:30:17 -070019class GrFragmentProcessor;
egdanielf5294392015-10-21 07:14:17 -070020class GrGLSLCaps;
bsalomonac856c92015-08-27 06:30:17 -070021
joshualitt7375d6b2015-08-07 13:36:44 -070022// Enough precision to represent 1 / 2048 accurately in printf
23#define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11
24
joshualitt47bb3822014-10-07 16:43:25 -070025/*
26 * This is the base class for a series of interfaces. This base class *MUST* remain abstract with
27 * NO data members because it is used in multiple interface inheritance.
28 * Heirarchy:
29 * GrGLUniformBuilder
30 * / \
31 * GrGLFPBuilder GrGLGPBuilder
32 * \ /
33 * GrGLProgramBuilder(internal use only)
34 */
35class GrGLUniformBuilder {
joshualitt30ba4362014-08-21 20:18:45 -070036public:
37 enum ShaderVisibility {
bsalomon17168df2014-12-09 09:00:49 -080038 kVertex_Visibility = 1 << kVertex_GrShaderType,
39 kGeometry_Visibility = 1 << kGeometry_GrShaderType,
40 kFragment_Visibility = 1 << kFragment_GrShaderType,
joshualitt30ba4362014-08-21 20:18:45 -070041 };
42
joshualitt47bb3822014-10-07 16:43:25 -070043 virtual ~GrGLUniformBuilder() {}
44
egdaniel018fb622015-10-28 07:26:40 -070045 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
joshualittd8dd47b2015-09-11 11:45:01 -070046 typedef GrGLProgramDataManager::SeparableVaryingHandle SeparableVaryingHandle;
joshualitt47bb3822014-10-07 16:43:25 -070047
48 /** Add a uniform variable to the current program, that has visibility in one or more shaders.
49 visibility is a bitfield of ShaderVisibility values indicating from which shaders the
50 uniform should be accessible. At least one bit must be set. Geometry shader uniforms are not
halcanary96fcdcc2015-08-27 07:41:13 -070051 supported at this time. The actual uniform name will be mangled. If outName is not nullptr then
joshualitt47bb3822014-10-07 16:43:25 -070052 it will refer to the final uniform name after return. Use the addUniformArray variant to add
53 an array of uniforms. */
bsalomon422f56f2014-12-09 10:18:12 -080054 UniformHandle addUniform(uint32_t visibility,
55 GrSLType type,
56 GrSLPrecision precision,
57 const char* name,
halcanary96fcdcc2015-08-27 07:41:13 -070058 const char** outName = nullptr) {
bsalomon422f56f2014-12-09 10:18:12 -080059 return this->addUniformArray(visibility, type, precision, name, 0, outName);
60 }
61
62 virtual UniformHandle addUniformArray(
63 uint32_t visibility,
64 GrSLType type,
65 GrSLPrecision precision,
66 const char* name,
67 int arrayCount,
halcanary96fcdcc2015-08-27 07:41:13 -070068 const char** outName = nullptr) = 0;
joshualitt47bb3822014-10-07 16:43:25 -070069
egdaniel0d3f0612015-10-21 10:45:48 -070070 virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0;
joshualitt47bb3822014-10-07 16:43:25 -070071
72 /**
73 * Shortcut for getUniformVariable(u).c_str()
74 */
75 virtual const char* getUniformCStr(UniformHandle u) const = 0;
76
77 virtual const GrGLContextInfo& ctxInfo() const = 0;
78
egdanielf5294392015-10-21 07:14:17 -070079 virtual const GrGLSLCaps* glslCaps() const = 0;
80
bsalomon861e1032014-12-16 07:33:49 -080081 virtual GrGLGpu* gpu() const = 0;
joshualitt47bb3822014-10-07 16:43:25 -070082
83 /*
84 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
85 */
86};
87
joshualitt74077b92014-10-24 11:26:03 -070088// TODO move this into GrGLGPBuilder and move them both out of this file
89class GrGLVarying {
90public:
91 bool vsVarying() const { return kVertToFrag_Varying == fVarying ||
92 kVertToGeo_Varying == fVarying; }
93 bool fsVarying() const { return kVertToFrag_Varying == fVarying ||
94 kGeoToFrag_Varying == fVarying; }
95 const char* vsOut() const { return fVsOut; }
96 const char* gsIn() const { return fGsIn; }
97 const char* gsOut() const { return fGsOut; }
98 const char* fsIn() const { return fFsIn; }
joshualittabb52a12015-01-13 15:02:10 -080099 GrSLType type() const { return fType; }
joshualitt74077b92014-10-24 11:26:03 -0700100
101protected:
102 enum Varying {
103 kVertToFrag_Varying,
104 kVertToGeo_Varying,
105 kGeoToFrag_Varying,
106 };
107
108 GrGLVarying(GrSLType type, Varying varying)
halcanary96fcdcc2015-08-27 07:41:13 -0700109 : fVarying(varying), fType(type), fVsOut(nullptr), fGsIn(nullptr), fGsOut(nullptr),
110 fFsIn(nullptr) {}
joshualitt74077b92014-10-24 11:26:03 -0700111
112 Varying fVarying;
113
114private:
115 GrSLType fType;
116 const char* fVsOut;
117 const char* fGsIn;
118 const char* fGsOut;
119 const char* fFsIn;
120
121 friend class GrGLVertexBuilder;
122 friend class GrGLGeometryBuilder;
egdanielc2304142014-12-11 13:15:13 -0800123 friend class GrGLXferBuilder;
joshualitt74077b92014-10-24 11:26:03 -0700124 friend class GrGLFragmentShaderBuilder;
125};
126
127struct GrGLVertToFrag : public GrGLVarying {
128 GrGLVertToFrag(GrSLType type)
129 : GrGLVarying(type, kVertToFrag_Varying) {}
130};
131
132struct GrGLVertToGeo : public GrGLVarying {
133 GrGLVertToGeo(GrSLType type)
134 : GrGLVarying(type, kVertToGeo_Varying) {}
135};
136
137struct GrGLGeoToFrag : public GrGLVarying {
138 GrGLGeoToFrag(GrSLType type)
139 : GrGLVarying(type, kGeoToFrag_Varying) {}
140};
141
joshualitt47bb3822014-10-07 16:43:25 -0700142/* a specialization of the above for GPs. Lets the user add uniforms, varyings, and VS / FS code */
143class GrGLGPBuilder : public virtual GrGLUniformBuilder {
144public:
joshualitt2dd1ae02014-12-03 06:24:10 -0800145 /*
146 * addVarying allows fine grained control for setting up varyings between stages. If you just
147 * need to take an attribute and pass it through to an output value in a fragment shader, use
148 * addPassThroughAttribute.
149 * TODO convert most uses of addVarying to addPassThroughAttribute
150 */
joshualitt74077b92014-10-24 11:26:03 -0700151 virtual void addVarying(const char* name,
152 GrGLVarying*,
joshualitteb00eab2015-09-15 14:12:22 -0700153 GrSLPrecision precision = kDefault_GrSLPrecision) = 0;
joshualitt47bb3822014-10-07 16:43:25 -0700154
joshualitt2dd1ae02014-12-03 06:24:10 -0800155 /*
156 * This call can be used by GP to pass an attribute through all shaders directly to 'output' in
157 * the fragment shader. Though this call effects both the vertex shader and fragment shader,
158 * it expects 'output' to be defined in the fragment shader before this call is made.
159 * TODO it might be nicer behavior to have a flag to declare output inside this call
160 */
joshualitt71c92602015-01-14 08:12:47 -0800161 virtual void addPassThroughAttribute(const GrGeometryProcessor::Attribute*,
joshualitt2dd1ae02014-12-03 06:24:10 -0800162 const char* output) = 0;
163
kkinnunen7aedda52015-06-29 23:01:28 -0700164 /*
165 * Creates a fragment shader varying that can be referred to.
166 * Comparable to GrGLUniformBuilder::addUniform().
167 */
168 virtual SeparableVaryingHandle addSeparableVarying(
169 const char* name, GrGLVertToFrag*, GrSLPrecision fsPrecision = kDefault_GrSLPrecision) = 0;
170
joshualitt47bb3822014-10-07 16:43:25 -0700171 // TODO rename getFragmentBuilder
egdaniel29bee0f2015-04-29 11:54:42 -0700172 virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0;
joshualitt47bb3822014-10-07 16:43:25 -0700173 virtual GrGLVertexBuilder* getVertexShaderBuilder() = 0;
174
175 /*
176 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
177 */
178};
179
180/* a specializations for FPs. Lets the user add uniforms and FS code */
181class GrGLFPBuilder : public virtual GrGLUniformBuilder {
182public:
egdaniel29bee0f2015-04-29 11:54:42 -0700183 virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0;
joshualitt47bb3822014-10-07 16:43:25 -0700184
185 /*
186 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
187 */
188};
189
egdanielc2304142014-12-11 13:15:13 -0800190/* a specializations for XPs. Lets the user add uniforms and FS code */
191class GrGLXPBuilder : public virtual GrGLUniformBuilder {
192public:
egdaniel29bee0f2015-04-29 11:54:42 -0700193 virtual GrGLXPFragmentBuilder* getFragmentShaderBuilder() = 0;
egdanielc2304142014-12-11 13:15:13 -0800194
195 /*
196 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
197 */
198};
joshualittabb52a12015-01-13 15:02:10 -0800199
200/**
201 * The below struct represent processors installed in programs.
202 */
203template <class Proc>
204struct GrGLInstalledProc {
cdalton42717652015-06-18 11:54:30 -0700205 SkDEBUGCODE(int fSamplersIdx;)
206 SkAutoTDelete<Proc> fGLProc;
joshualittabb52a12015-01-13 15:02:10 -0800207};
208
209typedef GrGLInstalledProc<GrGLPrimitiveProcessor> GrGLInstalledGeoProc;
210typedef GrGLInstalledProc<GrGLXferProcessor> GrGLInstalledXferProc;
211typedef GrGLInstalledProc<GrGLFragmentProcessor> GrGLInstalledFragProc;
212
213struct GrGLInstalledFragProcs : public SkRefCnt {
214 virtual ~GrGLInstalledFragProcs();
215 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs;
216};
joshualitta5305a12014-10-10 17:47:00 -0700217
joshualitt47bb3822014-10-07 16:43:25 -0700218/*
219 * Please note - no diamond problems because of virtual inheritance. Also, both base classes
220 * are pure virtual with no data members. This is the base class for program building.
221 * Subclasses are nearly identical but each has their own way of emitting transforms. State for
222 * each of the elements of the shader pipeline, ie vertex, fragment, geometry, etc, lives in those
223 * respective builders
224*/
225class GrGLProgramBuilder : public GrGLGPBuilder,
egdanielc2304142014-12-11 13:15:13 -0800226 public GrGLFPBuilder,
227 public GrGLXPBuilder {
joshualitt47bb3822014-10-07 16:43:25 -0700228public:
joshualitt873ad0e2015-01-20 09:08:51 -0800229 typedef GrGpu::DrawArgs DrawArgs;
joshualitt47bb3822014-10-07 16:43:25 -0700230 /** Generates a shader program.
231 *
232 * The program implements what is specified in the stages given as input.
233 * After successful generation, the builder result objects are available
234 * to be used.
235 * @return true if generation was successful.
236 */
joshualitt873ad0e2015-01-20 09:08:51 -0800237 static GrGLProgram* CreateProgram(const DrawArgs&, GrGLGpu*);
joshualitt47bb3822014-10-07 16:43:25 -0700238
bsalomon422f56f2014-12-09 10:18:12 -0800239 UniformHandle addUniformArray(uint32_t visibility,
240 GrSLType type,
241 GrSLPrecision precision,
242 const char* name,
243 int arrayCount,
mtklein36352bf2015-03-25 18:17:31 -0700244 const char** outName) override;
joshualitt47bb3822014-10-07 16:43:25 -0700245
egdaniel0d3f0612015-10-21 10:45:48 -0700246 const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
joshualitte7afc2d2015-09-11 10:44:13 -0700247 return fUniforms[u.toIndex()].fVariable;
joshualitt47bb3822014-10-07 16:43:25 -0700248 }
249
mtklein36352bf2015-03-25 18:17:31 -0700250 const char* getUniformCStr(UniformHandle u) const override {
joshualitt47bb3822014-10-07 16:43:25 -0700251 return this->getUniformVariable(u).c_str();
252 }
253
mtklein36352bf2015-03-25 18:17:31 -0700254 const GrGLContextInfo& ctxInfo() const override;
joshualitt47bb3822014-10-07 16:43:25 -0700255
egdanielf5294392015-10-21 07:14:17 -0700256 const GrGLSLCaps* glslCaps() const override;
257
mtklein36352bf2015-03-25 18:17:31 -0700258 GrGLGpu* gpu() const override { return fGpu; }
joshualitt47bb3822014-10-07 16:43:25 -0700259
egdaniel29bee0f2015-04-29 11:54:42 -0700260 GrGLXPFragmentBuilder* getFragmentShaderBuilder() override { return &fFS; }
mtklein36352bf2015-03-25 18:17:31 -0700261 GrGLVertexBuilder* getVertexShaderBuilder() override { return &fVS; }
joshualitt47bb3822014-10-07 16:43:25 -0700262
bsalomon422f56f2014-12-09 10:18:12 -0800263 void addVarying(
joshualitta5305a12014-10-10 17:47:00 -0700264 const char* name,
joshualitt74077b92014-10-24 11:26:03 -0700265 GrGLVarying*,
joshualitteb00eab2015-09-15 14:12:22 -0700266 GrSLPrecision precision = kDefault_GrSLPrecision) override;
joshualitt30ba4362014-08-21 20:18:45 -0700267
joshualitt71c92602015-01-14 08:12:47 -0800268 void addPassThroughAttribute(const GrPrimitiveProcessor::Attribute*,
mtklein36352bf2015-03-25 18:17:31 -0700269 const char* output) override;
joshualitt2dd1ae02014-12-03 06:24:10 -0800270
kkinnunen7aedda52015-06-29 23:01:28 -0700271 SeparableVaryingHandle addSeparableVarying(
272 const char* name,
273 GrGLVertToFrag*,
274 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) override;
joshualitt2dd1ae02014-12-03 06:24:10 -0800275
joshualitt30ba4362014-08-21 20:18:45 -0700276 // Handles for program uniforms (other than per-effect uniforms)
277 struct BuiltinUniformHandles {
joshualitt30ba4362014-08-21 20:18:45 -0700278 UniformHandle fRTAdjustmentUni;
joshualitt30ba4362014-08-21 20:18:45 -0700279
280 // We use the render target height to provide a y-down frag coord when specifying
281 // origin_upper_left is not supported.
282 UniformHandle fRTHeightUni;
joshualitt30ba4362014-08-21 20:18:45 -0700283 };
284
joshualittdb0d3ca2014-10-07 12:42:26 -0700285protected:
joshualitta5305a12014-10-10 17:47:00 -0700286 typedef GrGLProgramDataManager::UniformInfo UniformInfo;
287 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
joshualittd8dd47b2015-09-11 11:45:01 -0700288 typedef GrGLProgramDataManager::SeparableVaryingInfo SeparableVaryingInfo;
289 typedef GrGLProgramDataManager::SeparableVaryingInfoArray SeparableVaryingInfoArray;
joshualitt47bb3822014-10-07 16:43:25 -0700290
joshualitt873ad0e2015-01-20 09:08:51 -0800291 GrGLProgramBuilder(GrGLGpu*, const DrawArgs&);
joshualitt30ba4362014-08-21 20:18:45 -0700292
joshualitt873ad0e2015-01-20 09:08:51 -0800293 const GrPrimitiveProcessor& primitiveProcessor() const { return *fArgs.fPrimitiveProcessor; }
egdaniel8dd688b2015-01-22 10:16:09 -0800294 const GrPipeline& pipeline() const { return *fArgs.fPipeline; }
joshualitt873ad0e2015-01-20 09:08:51 -0800295 const GrProgramDesc& desc() const { return *fArgs.fDesc; }
joshualitt873ad0e2015-01-20 09:08:51 -0800296 const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header(); }
joshualitt23e280d2014-09-18 12:26:38 -0700297
joshualitt30ba4362014-08-21 20:18:45 -0700298 // Generates a name for a variable. The generated string will be name prefixed by the prefix
299 // char (unless the prefix is '\0'). It also mangles the name to be stage-specific if we're
300 // generating stage code.
301 void nameVariable(SkString* out, char prefix, const char* name);
joshualitt2dd1ae02014-12-03 06:24:10 -0800302 // Generates a possibly mangled name for a stage variable and writes it to the fragment shader.
303 // If GrGLSLExpr4 has a valid name then it will use that instead
304 void nameExpression(GrGLSLExpr4*, const char* baseName);
joshualitt6c891102015-05-13 08:51:49 -0700305 bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage);
joshualitta5305a12014-10-10 17:47:00 -0700306 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOut);
bsalomonac856c92015-08-27 06:30:17 -0700307 void emitAndInstallProc(const GrFragmentProcessor&,
joshualitta5305a12014-10-10 17:47:00 -0700308 int index,
joshualitta5305a12014-10-10 17:47:00 -0700309 const GrGLSLExpr4& input,
310 GrGLSLExpr4* output);
311
joshualitt9b989322014-12-15 14:16:27 -0800312 void emitAndInstallProc(const GrPrimitiveProcessor&,
joshualitt2dd1ae02014-12-03 06:24:10 -0800313 GrGLSLExpr4* outputColor,
314 GrGLSLExpr4* outputCoverage);
315
joshualitta5305a12014-10-10 17:47:00 -0700316 // these emit functions help to keep the createAndEmitProcessors template general
bsalomonac856c92015-08-27 06:30:17 -0700317 void emitAndInstallProc(const GrFragmentProcessor&,
joshualittabb52a12015-01-13 15:02:10 -0800318 int index,
joshualitta5305a12014-10-10 17:47:00 -0700319 const char* outColor,
320 const char* inColor);
joshualitt9b989322014-12-15 14:16:27 -0800321 void emitAndInstallProc(const GrPrimitiveProcessor&,
joshualitt2dd1ae02014-12-03 06:24:10 -0800322 const char* outColor,
323 const char* outCoverage);
egdanielc2304142014-12-11 13:15:13 -0800324 void emitAndInstallXferProc(const GrXferProcessor&,
325 const GrGLSLExpr4& colorIn,
326 const GrGLSLExpr4& coverageIn);
joshualitt2dd1ae02014-12-03 06:24:10 -0800327
joshualitt9b989322014-12-15 14:16:27 -0800328 void verify(const GrPrimitiveProcessor&);
egdanielc2304142014-12-11 13:15:13 -0800329 void verify(const GrXferProcessor&);
joshualitt47bb3822014-10-07 16:43:25 -0700330 void verify(const GrFragmentProcessor&);
joshualittabb52a12015-01-13 15:02:10 -0800331 template <class Proc>
joshualitt47bb3822014-10-07 16:43:25 -0700332 void emitSamplers(const GrProcessor&,
333 GrGLProcessor::TextureSamplerArray* outSamplers,
joshualittabb52a12015-01-13 15:02:10 -0800334 GrGLInstalledProc<Proc>*);
joshualitt30ba4362014-08-21 20:18:45 -0700335
joshualitt47bb3822014-10-07 16:43:25 -0700336 GrGLProgram* finalize();
kkinnunen6bb6d402015-07-14 10:59:23 -0700337 virtual void bindProgramResourceLocations(GrGLuint programID);
joshualitt47bb3822014-10-07 16:43:25 -0700338 bool checkLinkStatus(GrGLuint programID);
kkinnunen7aedda52015-06-29 23:01:28 -0700339 virtual void resolveProgramResourceLocations(GrGLuint programID);
joshualitt47bb3822014-10-07 16:43:25 -0700340 void cleanupProgram(GrGLuint programID, const SkTDArray<GrGLuint>& shaderIDs);
341 void cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs);
joshualitt30ba4362014-08-21 20:18:45 -0700342
joshualitt47bb3822014-10-07 16:43:25 -0700343 // Subclasses create different programs
344 virtual GrGLProgram* createProgram(GrGLuint programID);
345
joshualitt30ba4362014-08-21 20:18:45 -0700346 void appendUniformDecls(ShaderVisibility, SkString*) const;
347
joshualitt47bb3822014-10-07 16:43:25 -0700348 // reset is called by program creator between each processor's emit code. It increments the
349 // stage offset for variable name mangling, and also ensures verfication variables in the
350 // fragment shader are cleared.
351 void reset() {
352 this->enterStage();
353 this->addStage();
354 fFS.reset();
355 }
356 void addStage() { fStageIndex++; }
357
358 // This simple class exits the stage and then restores the stage when it goes out of scope
359 class AutoStageRestore {
joshualitt30ba4362014-08-21 20:18:45 -0700360 public:
joshualitt47bb3822014-10-07 16:43:25 -0700361 AutoStageRestore(GrGLProgramBuilder* pb)
362 : fPB(pb), fOutOfStage(pb->fOutOfStage) { pb->exitStage(); }
363 ~AutoStageRestore() { fPB->fOutOfStage = fOutOfStage; }
joshualittb0a8a372014-09-23 09:50:21 -0700364 private:
joshualitt47bb3822014-10-07 16:43:25 -0700365 GrGLProgramBuilder* fPB;
366 bool fOutOfStage;
joshualittb0a8a372014-09-23 09:50:21 -0700367 };
joshualitt47bb3822014-10-07 16:43:25 -0700368 class AutoStageAdvance {
joshualittdb0d3ca2014-10-07 12:42:26 -0700369 public:
joshualitt43466a12015-02-13 17:18:27 -0800370 AutoStageAdvance(GrGLProgramBuilder* pb)
371 : fPB(pb) {
372 fPB->reset();
373 // Each output to the fragment processor gets its own code section
374 fPB->fFS.nextStage();
375 }
joshualitt47bb3822014-10-07 16:43:25 -0700376 ~AutoStageAdvance() { fPB->exitStage(); }
joshualittdb0d3ca2014-10-07 12:42:26 -0700377 private:
joshualitt47bb3822014-10-07 16:43:25 -0700378 GrGLProgramBuilder* fPB;
379 };
380 void exitStage() { fOutOfStage = true; }
381 void enterStage() { fOutOfStage = false; }
382 int stageIndex() const { return fStageIndex; }
383
joshualitt4973d9d2014-11-08 09:24:25 -0800384 const char* rtAdjustment() const { return "rtAdjustment"; }
385
joshualitt47bb3822014-10-07 16:43:25 -0700386 // number of each input/output type in a single allocation block, used by many builders
387 static const int kVarsPerBlock;
388
389 BuiltinUniformHandles fUniformHandles;
390 GrGLVertexBuilder fVS;
391 GrGLGeometryBuilder fGS;
392 GrGLFragmentShaderBuilder fFS;
393 bool fOutOfStage;
394 int fStageIndex;
395
joshualitta5305a12014-10-10 17:47:00 -0700396 GrGLInstalledGeoProc* fGeometryProcessor;
egdanielc2304142014-12-11 13:15:13 -0800397 GrGLInstalledXferProc* fXferProcessor;
joshualitta5305a12014-10-10 17:47:00 -0700398 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors;
joshualitt47bb3822014-10-07 16:43:25 -0700399
joshualitt873ad0e2015-01-20 09:08:51 -0800400 const DrawArgs& fArgs;
bsalomon861e1032014-12-16 07:33:49 -0800401 GrGLGpu* fGpu;
joshualitt47bb3822014-10-07 16:43:25 -0700402 UniformInfoArray fUniforms;
joshualittabb52a12015-01-13 15:02:10 -0800403 GrGLPrimitiveProcessor::TransformsIn fCoordTransforms;
404 GrGLPrimitiveProcessor::TransformsOut fOutCoords;
cdalton42717652015-06-18 11:54:30 -0700405 SkTArray<UniformHandle> fSamplerUniforms;
joshualittd8dd47b2015-09-11 11:45:01 -0700406 SeparableVaryingInfoArray fSeparableVaryingInfos;
joshualitt47bb3822014-10-07 16:43:25 -0700407
408 friend class GrGLShaderBuilder;
409 friend class GrGLVertexBuilder;
410 friend class GrGLFragmentShaderBuilder;
411 friend class GrGLGeometryBuilder;
412};
joshualitt30ba4362014-08-21 20:18:45 -0700413#endif