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" |
| 12 | #include "gl/GrGLShaderVar.h" |
| 13 | #include "gl/GrGLSL.h" |
| 14 | |
| 15 | typedef 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 | |
| 23 | class GrGLShaderBuilder { |
| 24 | |
| 25 | public: |
| 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.com | 9c639a4 | 2012-05-14 19:58:06 +0000 | [diff] [blame^] | 55 | int fVaryingDims; |
| 56 | static const int fCoordDims = 2; |
| 57 | |
tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 58 | bool fUsesGS; |
tomhudson@google.com | 9c639a4 | 2012-05-14 19:58:06 +0000 | [diff] [blame^] | 59 | |
tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | #endif |