epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 10 | #ifndef GrGLProgram_DEFINED |
| 11 | #define GrGLProgram_DEFINED |
| 12 | |
| 13 | #include "GrGLInterface.h" |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 14 | #include "GrStringBuilder.h" |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 15 | #include "GrGpu.h" |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 16 | |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 17 | #include "SkXfermode.h" |
| 18 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 19 | class GrBinHashKeyBuilder; |
junov@google.com | d31cbc4 | 2011-05-17 17:01:17 +0000 | [diff] [blame] | 20 | |
bsalomon@google.com | 1fac5ca | 2011-09-20 17:57:44 +0000 | [diff] [blame^] | 21 | struct ShaderCodeSegments { |
| 22 | GrStringBuilder fHeader; // VS+FS, GLSL version, etc |
| 23 | GrStringBuilder fVSUnis; |
| 24 | GrStringBuilder fVSAttrs; |
| 25 | GrStringBuilder fVaryings; |
| 26 | GrStringBuilder fFSUnis; |
| 27 | GrStringBuilder fFSOutputs; |
| 28 | GrStringBuilder fFSFunctions; |
| 29 | GrStringBuilder fVSCode; |
| 30 | GrStringBuilder fFSCode; |
| 31 | }; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * This class manages a GPU program and records per-program information. |
| 35 | * We can specify the attribute locations so that they are constant |
| 36 | * across our shaders. But the driver determines the uniform locations |
| 37 | * at link time. We don't need to remember the sampler uniform location |
| 38 | * because we will bind a texture slot to it and never change it |
| 39 | * Uniforms are program-local so we can't rely on fHWState to hold the |
| 40 | * previous uniform state after a program change. |
| 41 | */ |
| 42 | class GrGLProgram { |
| 43 | public: |
| 44 | class CachedData; |
| 45 | |
| 46 | GrGLProgram(); |
| 47 | ~GrGLProgram(); |
| 48 | |
| 49 | /** |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 50 | * This is the heavy initilization routine for building a GLProgram. |
| 51 | * The result of heavy init is not stored in datamembers of GrGLProgam, |
| 52 | * but in a separate cacheable container. |
| 53 | */ |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 54 | bool genProgram(const GrGLInterface* gl, |
| 55 | CachedData* programData) const; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 56 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 57 | /** |
| 58 | * The shader may modify the blend coeffecients. Params are in/out |
| 59 | */ |
| 60 | void overrideBlend(GrBlendCoeff* srcCoeff, GrBlendCoeff* dstCoeff) const; |
| 61 | |
| 62 | /** |
| 63 | * Attribute indices |
| 64 | */ |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 65 | static int PositionAttributeIdx() { return 0; } |
| 66 | static int TexCoordAttributeIdx(int tcIdx) { return 1 + tcIdx; } |
| 67 | static int ColorAttributeIdx() { return 1 + GrDrawTarget::kMaxTexCoords; } |
bsalomon@google.com | aeb2160 | 2011-08-30 18:13:44 +0000 | [diff] [blame] | 68 | static int EdgeAttributeIdx() { return 2 + GrDrawTarget::kMaxTexCoords; } |
| 69 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 70 | static int ViewMatrixAttributeIdx() { |
| 71 | return 2 + GrDrawTarget::kMaxTexCoords; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 72 | } |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 73 | static int TextureMatrixAttributeIdx(int stage) { |
| 74 | return 5 + GrDrawTarget::kMaxTexCoords + 3 * stage; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 75 | } |
| 76 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 77 | private: |
| 78 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 79 | // Parameters that affect code generation |
| 80 | // These structs should be kept compact; they are the input to an |
| 81 | // expensive hash key generator. |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 82 | struct ProgramDesc { |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 83 | ProgramDesc() { |
| 84 | // since we use this as part of a key we can't have any unitialized |
| 85 | // padding |
| 86 | memset(this, 0, sizeof(ProgramDesc)); |
| 87 | } |
| 88 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 89 | struct StageDesc { |
| 90 | enum OptFlagBits { |
| 91 | kNoPerspective_OptFlagBit = 1 << 0, |
| 92 | kIdentityMatrix_OptFlagBit = 1 << 1, |
| 93 | kCustomTextureDomain_OptFlagBit = 1 << 2, |
| 94 | kIsEnabled_OptFlagBit = 1 << 7 |
| 95 | }; |
| 96 | enum Modulation { |
| 97 | kColor_Modulation, |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame] | 98 | kAlpha_Modulation, |
| 99 | |
| 100 | kModulationCnt |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 101 | }; |
| 102 | enum FetchMode { |
| 103 | kSingle_FetchMode, |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame] | 104 | k2x2_FetchMode, |
senorblanco@chromium.org | 027de5f | 2011-07-08 18:03:33 +0000 | [diff] [blame] | 105 | kConvolution_FetchMode, |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame] | 106 | |
| 107 | kFetchModeCnt, |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 108 | }; |
| 109 | enum CoordMapping { |
| 110 | kIdentity_CoordMapping, |
| 111 | kRadialGradient_CoordMapping, |
| 112 | kSweepGradient_CoordMapping, |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame] | 113 | kRadial2Gradient_CoordMapping, |
bsalomon@google.com | 22c5dea | 2011-07-07 14:38:03 +0000 | [diff] [blame] | 114 | // need different shader computation when quadratic |
| 115 | // eq describing the gradient degenerates to a linear eq. |
| 116 | kRadial2GradientDegenerate_CoordMapping, |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame] | 117 | kCoordMappingCnt |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 118 | }; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 119 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 120 | uint8_t fOptFlags; |
| 121 | uint8_t fModulation; // casts to enum Modulation |
| 122 | uint8_t fFetchMode; // casts to enum FetchMode |
| 123 | uint8_t fCoordMapping; // casts to enum CoordMapping |
senorblanco@chromium.org | 027de5f | 2011-07-08 18:03:33 +0000 | [diff] [blame] | 124 | uint8_t fKernelWidth; |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 125 | |
| 126 | inline bool isEnabled() const { |
| 127 | return fOptFlags & kIsEnabled_OptFlagBit; |
| 128 | } |
| 129 | inline void setEnabled(bool newValue) { |
| 130 | if (newValue) { |
| 131 | fOptFlags |= kIsEnabled_OptFlagBit; |
| 132 | } else { |
| 133 | fOptFlags &= ~kIsEnabled_OptFlagBit; |
| 134 | } |
| 135 | } |
| 136 | }; |
| 137 | |
| 138 | enum ColorType { |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 139 | kNone_ColorType = 0, |
| 140 | kAttribute_ColorType = 1, |
| 141 | kUniform_ColorType = 2, |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 142 | }; |
| 143 | // Dual-src blending makes use of a secondary output color that can be |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 144 | // used as a per-pixel blend coeffecient. This controls whether a |
| 145 | // secondary source is output and what value it holds. |
| 146 | enum DualSrcOutput { |
| 147 | kNone_DualSrcOutput, |
| 148 | kCoverage_DualSrcOutput, |
| 149 | kCoverageISA_DualSrcOutput, |
| 150 | kCoverageISC_DualSrcOutput, |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame] | 151 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 152 | kDualSrcOutputCnt |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 153 | }; |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 154 | |
bsalomon@google.com | aeb2160 | 2011-08-30 18:13:44 +0000 | [diff] [blame] | 155 | GrDrawTarget::VertexEdgeType fVertexEdgeType; |
| 156 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 157 | // stripped of bits that don't affect prog generation |
| 158 | GrVertexLayout fVertexLayout; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 159 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 160 | StageDesc fStages[GrDrawTarget::kNumStages]; |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 161 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 162 | uint8_t fColorType; // casts to enum ColorType |
| 163 | uint8_t fDualSrcOutput; // casts to enum DualSrcOutput |
| 164 | int8_t fFirstCoverageStage; |
| 165 | SkBool8 fEmitsPointSize; |
senorblanco@chromium.org | 129b8e3 | 2011-06-15 17:52:09 +0000 | [diff] [blame] | 166 | SkBool8 fEdgeAAConcave; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 167 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 168 | int8_t fEdgeAANumEdges; |
| 169 | uint8_t fColorFilterXfermode; // casts to enum SkXfermode::Mode |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 170 | |
senorblanco@chromium.org | 129b8e3 | 2011-06-15 17:52:09 +0000 | [diff] [blame] | 171 | uint8_t fPadTo32bLengthMultiple [1]; |
bsalomon@google.com | 6aef1fb | 2011-05-05 12:33:22 +0000 | [diff] [blame] | 172 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 173 | } fProgramDesc; |
| 174 | |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 175 | const ProgramDesc& getDesc() { return fProgramDesc; } |
| 176 | |
bsalomon@google.com | 22c5dea | 2011-07-07 14:38:03 +0000 | [diff] [blame] | 177 | // for code readability |
| 178 | typedef ProgramDesc::StageDesc StageDesc; |
| 179 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 180 | public: |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 181 | enum { |
| 182 | kUnusedUniform = -1, |
| 183 | kSetAsAttribute = 1000, |
| 184 | }; |
| 185 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 186 | struct StageUniLocations { |
| 187 | GrGLint fTextureMatrixUni; |
bsalomon@google.com | 6aef1fb | 2011-05-05 12:33:22 +0000 | [diff] [blame] | 188 | GrGLint fNormalizedTexelSizeUni; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 189 | GrGLint fSamplerUni; |
| 190 | GrGLint fRadial2Uni; |
junov@google.com | 6acc9b3 | 2011-05-16 18:32:07 +0000 | [diff] [blame] | 191 | GrGLint fTexDomUni; |
senorblanco@chromium.org | 027de5f | 2011-07-08 18:03:33 +0000 | [diff] [blame] | 192 | GrGLint fKernelUni; |
| 193 | GrGLint fImageIncrementUni; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 194 | void reset() { |
| 195 | fTextureMatrixUni = kUnusedUniform; |
| 196 | fNormalizedTexelSizeUni = kUnusedUniform; |
| 197 | fSamplerUni = kUnusedUniform; |
| 198 | fRadial2Uni = kUnusedUniform; |
junov@google.com | 6acc9b3 | 2011-05-16 18:32:07 +0000 | [diff] [blame] | 199 | fTexDomUni = kUnusedUniform; |
senorblanco@chromium.org | 027de5f | 2011-07-08 18:03:33 +0000 | [diff] [blame] | 200 | fKernelUni = kUnusedUniform; |
| 201 | fImageIncrementUni = kUnusedUniform; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 202 | } |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | struct UniLocations { |
| 206 | GrGLint fViewMatrixUni; |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 207 | GrGLint fColorUni; |
senorblanco@chromium.org | 92e0f22 | 2011-05-12 15:49:15 +0000 | [diff] [blame] | 208 | GrGLint fEdgesUni; |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 209 | GrGLint fColorFilterUni; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 210 | StageUniLocations fStages[GrDrawTarget::kNumStages]; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 211 | void reset() { |
| 212 | fViewMatrixUni = kUnusedUniform; |
| 213 | fColorUni = kUnusedUniform; |
senorblanco@chromium.org | 92e0f22 | 2011-05-12 15:49:15 +0000 | [diff] [blame] | 214 | fEdgesUni = kUnusedUniform; |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 215 | fColorFilterUni = kUnusedUniform; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 216 | for (int s = 0; s < GrDrawTarget::kNumStages; ++s) { |
| 217 | fStages[s].reset(); |
| 218 | } |
| 219 | } |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | class CachedData : public ::GrNoncopyable { |
| 223 | public: |
| 224 | CachedData() { |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | ~CachedData() { |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | void copyAndTakeOwnership(CachedData& other) { |
bsalomon@google.com | 2d9ddf9 | 2011-05-11 16:52:59 +0000 | [diff] [blame] | 231 | memcpy(this, &other, sizeof(*this)); |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 232 | } |
| 233 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 234 | public: |
| 235 | |
| 236 | // IDs |
| 237 | GrGLuint fVShaderID; |
| 238 | GrGLuint fFShaderID; |
| 239 | GrGLuint fProgramID; |
| 240 | // shader uniform locations (-1 if shader doesn't use them) |
| 241 | UniLocations fUniLocations; |
| 242 | |
| 243 | GrMatrix fViewMatrix; |
| 244 | |
| 245 | // these reflect the current values of uniforms |
| 246 | // (GL uniform values travel with program) |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 247 | GrColor fColor; |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 248 | GrColor fColorFilterColor; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 249 | GrMatrix fTextureMatrices[GrDrawTarget::kNumStages]; |
bsalomon@google.com | 6aef1fb | 2011-05-05 12:33:22 +0000 | [diff] [blame] | 250 | // width and height used for normalized texel size |
| 251 | int fTextureWidth[GrDrawTarget::kNumStages]; |
| 252 | int fTextureHeight[GrDrawTarget::kNumStages]; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 253 | GrScalar fRadial2CenterX1[GrDrawTarget::kNumStages]; |
| 254 | GrScalar fRadial2Radius0[GrDrawTarget::kNumStages]; |
| 255 | bool fRadial2PosRoot[GrDrawTarget::kNumStages]; |
junov@google.com | 2f83940 | 2011-05-24 15:13:01 +0000 | [diff] [blame] | 256 | GrRect fTextureDomain[GrDrawTarget::kNumStages]; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 257 | |
| 258 | private: |
| 259 | enum Constants { |
| 260 | kUniLocationPreAllocSize = 8 |
| 261 | }; |
| 262 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 263 | }; // CachedData |
| 264 | |
junov@google.com | f7c00f6 | 2011-08-18 18:15:16 +0000 | [diff] [blame] | 265 | enum Constants { |
| 266 | kProgramKeySize = sizeof(ProgramDesc) |
| 267 | }; |
| 268 | |
| 269 | // Provide an opaque ProgramDesc |
| 270 | const uint32_t* keyData() const{ |
| 271 | return reinterpret_cast<const uint32_t*>(&fProgramDesc); |
| 272 | } |
| 273 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 274 | private: |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 275 | enum { |
| 276 | kUseUniform = 2000 |
| 277 | }; |
| 278 | |
| 279 | // should set all fields in locations var to kUseUniform if the |
| 280 | // corresponding uniform is required for the program. |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 281 | void genStageCode(const GrGLInterface* gl, |
| 282 | int stageNum, |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 283 | const ProgramDesc::StageDesc& desc, |
| 284 | const char* fsInColor, // NULL means no incoming color |
| 285 | const char* fsOutColor, |
| 286 | const char* vsInCoord, |
| 287 | ShaderCodeSegments* segments, |
| 288 | StageUniLocations* locations) const; |
bsalomon@google.com | 1fac5ca | 2011-09-20 17:57:44 +0000 | [diff] [blame^] | 289 | |
bsalomon@google.com | 6610567 | 2011-09-15 15:12:00 +0000 | [diff] [blame] | 290 | // generates code to compute coverage based on edge AA. |
| 291 | void genEdgeCoverage(const GrGLInterface* gl, |
| 292 | GrVertexLayout layout, |
| 293 | CachedData* programData, |
| 294 | GrStringBuilder* coverageVar, |
| 295 | ShaderCodeSegments* segments) const; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 296 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 297 | static bool CompileFSAndVS(const GrGLInterface* gl, |
| 298 | const ShaderCodeSegments& segments, |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 299 | CachedData* programData); |
| 300 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 301 | // Compiles a GL shader, returns shader ID or 0 if failed |
| 302 | // params have same meaning as glShaderSource |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 303 | static GrGLuint CompileShader(const GrGLInterface* gl, |
| 304 | GrGLenum type, int stringCnt, |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 305 | const char** strings, |
| 306 | int* stringLengths); |
| 307 | |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 308 | // Creates a GL program ID, binds shader attributes to GL vertex attrs, and |
| 309 | // links the program |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 310 | bool bindOutputsAttribsAndLinkProgram( |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 311 | const GrGLInterface* gl, |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 312 | GrStringBuilder texCoordAttrNames[GrDrawTarget::kMaxTexCoords], |
| 313 | bool bindColorOut, |
| 314 | bool bindDualSrcOut, |
| 315 | CachedData* programData) const; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 316 | |
| 317 | // Gets locations for all uniforms set to kUseUniform and initializes cache |
| 318 | // to invalid values. |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 319 | void getUniformLocationsAndInitCache(const GrGLInterface* gl, |
| 320 | CachedData* programData) const; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 321 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 322 | friend class GrGpuGLShaders; |
| 323 | }; |
| 324 | |
| 325 | #endif |