OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGLSLShaderBuilder_DEFINED | 8 #ifndef GrGLSLShaderBuilder_DEFINED |
9 #define GrGLSLShaderBuilder_DEFINED | 9 #define GrGLSLShaderBuilder_DEFINED |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 /** Appends a 2D texture sample with projection if necessary. coordType must
either be Vec2f or | 28 /** Appends a 2D texture sample with projection if necessary. coordType must
either be Vec2f or |
29 Vec3f. The latter is interpreted as projective texture coords. The vec l
ength and swizzle | 29 Vec3f. The latter is interpreted as projective texture coords. The vec l
ength and swizzle |
30 order of the result depends on the GrTextureAccess associated with the G
rGLSLSampler. | 30 order of the result depends on the GrTextureAccess associated with the G
rGLSLSampler. |
31 */ | 31 */ |
32 void appendTextureLookup(SkString* out, | 32 void appendTextureLookup(SkString* out, |
33 const GrGLSLSampler&, | 33 const GrGLSLSampler&, |
34 const char* coordName, | 34 const char* coordName, |
35 GrSLType coordType = kVec2f_GrSLType) const; | 35 GrSLType coordType = kVec2f_GrSLType) const; |
36 | 36 |
37 /** Version of above that appends the result to the fragment shader code ins
tead.*/ | 37 /** Version of above that appends the result to the shader code instead.*/ |
38 void appendTextureLookup(const GrGLSLSampler&, | 38 void appendTextureLookup(const GrGLSLSampler&, |
39 const char* coordName, | 39 const char* coordName, |
40 GrSLType coordType = kVec2f_GrSLType); | 40 GrSLType coordType = kVec2f_GrSLType); |
41 | 41 |
42 | 42 |
43 /** Does the work of appendTextureLookup and modulates the result by modulat
ion. The result is | 43 /** Does the work of appendTextureLookup and modulates the result by modulat
ion. The result is |
44 always a vec4. modulation and the swizzle specified by GrGLSLSampler mus
t both be | 44 always a vec4. modulation and the swizzle specified by GrGLSLSampler mus
t both be |
45 vec4 or float. If modulation is "" or nullptr it this function acts as t
hough | 45 vec4 or float. If modulation is "" or nullptr it this function acts as t
hough |
46 appendTextureLookup were called. */ | 46 appendTextureLookup were called. */ |
47 void appendTextureLookupAndModulate(const char* modulation, | 47 void appendTextureLookupAndModulate(const char* modulation, |
48 const GrGLSLSampler&, | 48 const GrGLSLSampler&, |
49 const char* coordName, | 49 const char* coordName, |
50 GrSLType coordType = kVec2f_GrSLType); | 50 GrSLType coordType = kVec2f_GrSLType); |
51 | 51 |
| 52 /** Fetches an unfiltered texel from a sampler at integer coordinates. coord
Expr must match the |
| 53 dimensionality of the sampler and must be within the sampler's range. co
ordExpr is emitted |
| 54 exactly once, so expressions like "idx++" are acceptable. */ |
| 55 void appendTexelFetch(SkString* out, const GrGLSLSampler&, const char* coord
Expr) const; |
| 56 |
| 57 /** Version of above that appends the result to the shader code instead.*/ |
| 58 void appendTexelFetch(const GrGLSLSampler&, const char* coordExpr); |
| 59 |
52 /** | 60 /** |
53 * Adds a #define directive to the top of the shader. | 61 * Adds a #define directive to the top of the shader. |
54 */ | 62 */ |
55 void define(const char* macro, const char* replacement) { | 63 void define(const char* macro, const char* replacement) { |
56 this->definitions().appendf("#define %s %s\n", macro, replacement); | 64 this->definitions().appendf("#define %s %s\n", macro, replacement); |
57 } | 65 } |
58 | 66 |
59 void define(const char* macro, int replacement) { | 67 void define(const char* macro, int replacement) { |
60 this->definitions().appendf("#define %s %i\n", macro, replacement); | 68 this->definitions().appendf("#define %s %i\n", macro, replacement); |
61 } | 69 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 * A low level function to build default layout qualifiers. | 176 * A low level function to build default layout qualifiers. |
169 * | 177 * |
170 * e.g. layout(param1, param2, ...) out; | 178 * e.g. layout(param1, param2, ...) out; |
171 * | 179 * |
172 * GLSL allows default layout qualifiers for in, out, and uniform. | 180 * GLSL allows default layout qualifiers for in, out, and uniform. |
173 */ | 181 */ |
174 void addLayoutQualifier(const char* param, InterfaceQualifier); | 182 void addLayoutQualifier(const char* param, InterfaceQualifier); |
175 | 183 |
176 void compileAndAppendLayoutQualifiers(); | 184 void compileAndAppendLayoutQualifiers(); |
177 | 185 |
| 186 /* Appends any swizzling we may need to get from some backend internal forma
t to the format used |
| 187 * in GrPixelConfig. If this is implemented by the GrGpu object, then swizzl
e will be rgba. For |
| 188 * shader prettiness we omit the swizzle rather than appending ".rgba". |
| 189 */ |
| 190 void appendTextureSwizzle(SkString* out, GrPixelConfig) const; |
| 191 |
178 void nextStage() { | 192 void nextStage() { |
179 fShaderStrings.push_back(); | 193 fShaderStrings.push_back(); |
180 fCompilerStrings.push_back(this->code().c_str()); | 194 fCompilerStrings.push_back(this->code().c_str()); |
181 fCompilerStringLengths.push_back((int)this->code().size()); | 195 fCompilerStringLengths.push_back((int)this->code().size()); |
182 fCodeIndex++; | 196 fCodeIndex++; |
183 } | 197 } |
184 | 198 |
185 SkString& versionDecl() { return fShaderStrings[kVersionDecl]; } | 199 SkString& versionDecl() { return fShaderStrings[kVersionDecl]; } |
186 SkString& extensions() { return fShaderStrings[kExtensions]; } | 200 SkString& extensions() { return fShaderStrings[kExtensions]; } |
187 SkString& definitions() { return fShaderStrings[kDefinitions]; } | 201 SkString& definitions() { return fShaderStrings[kDefinitions]; } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 int fCodeIndex; | 239 int fCodeIndex; |
226 bool fFinalized; | 240 bool fFinalized; |
227 | 241 |
228 friend class GrGLSLProgramBuilder; | 242 friend class GrGLSLProgramBuilder; |
229 friend class GrGLProgramBuilder; | 243 friend class GrGLProgramBuilder; |
230 friend class GrGLSLVaryingHandler; // to access noperspective interpolation
feature. | 244 friend class GrGLSLVaryingHandler; // to access noperspective interpolation
feature. |
231 friend class GrGLPathProgramBuilder; // to access fInputs. | 245 friend class GrGLPathProgramBuilder; // to access fInputs. |
232 friend class GrVkPipelineStateBuilder; | 246 friend class GrVkPipelineStateBuilder; |
233 }; | 247 }; |
234 #endif | 248 #endif |
OLD | NEW |