blob: 19ec6e17a3cdac47cfe9ac9a21abdf20f1cc2c46 [file] [log] [blame]
tomhudson@google.comf9ad8862012-05-11 20:38:48 +00001/*
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"
12#include "gl/GrGLShaderVar.h"
13#include "gl/GrGLSL.h"
14
15typedef GrTAllocator<GrGLShaderVar> VarArray;
16
17/**
18 Containts all the incremental state of a shader as it is being built,
19 as well as helpers to manipulate that state.
20 TODO: migrate CompileShaders() here?
21*/
22
23class GrGLShaderBuilder {
24
25public:
26
27 GrGLShaderBuilder();
28
29 void appendVarying(GrSLType type,
30 const char* name,
31 const char** vsOutName = NULL,
32 const char** fsInName = NULL);
33
34 void appendVarying(GrSLType type,
35 const char* name,
36 int stageNum,
37 const char** vsOutName = NULL,
38 const char** fsInName = NULL);
39
40 GrStringBuilder fHeader; // VS+FS, GLSL version, etc
41 VarArray fVSUnis;
42 VarArray fVSAttrs;
43 VarArray fVSOutputs;
44 VarArray fGSInputs;
45 VarArray fGSOutputs;
46 VarArray fFSInputs;
47 GrStringBuilder fGSHeader; // layout qualifiers specific to GS
48 VarArray fFSUnis;
49 VarArray fFSOutputs;
50 GrStringBuilder fFSFunctions;
51 GrStringBuilder fVSCode;
52 GrStringBuilder fGSCode;
53 GrStringBuilder fFSCode;
54
tomhudson@google.com9c639a42012-05-14 19:58:06 +000055 int fVaryingDims;
56 static const int fCoordDims = 2;
57
tomhudson@google.comf9ad8862012-05-11 20:38:48 +000058 bool fUsesGS;
tomhudson@google.com9c639a42012-05-14 19:58:06 +000059
tomhudson@google.comf9ad8862012-05-11 20:38:48 +000060};
61
62#endif