Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: src/gpu/glsl/GrGLSLShaderBuilder.h

Issue 1885863004: Refactor how we store and use samplers in Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unneeded assert Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLSampler.h ('k') | src/gpu/glsl/GrGLSLShaderBuilder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "GrAllocator.h" 11 #include "GrAllocator.h"
12 #include "glsl/GrGLSLUniformHandler.h"
12 #include "glsl/GrGLSLShaderVar.h" 13 #include "glsl/GrGLSLShaderVar.h"
13 #include "SkTDArray.h" 14 #include "SkTDArray.h"
14 15
15 #include <stdarg.h> 16 #include <stdarg.h>
16 17
17 class GrGLSLProgramBuilder;
18 class GrGLSLSampler;
19
20 /** 18 /**
21 base class for all shaders builders 19 base class for all shaders builders
22 */ 20 */
23 class GrGLSLShaderBuilder { 21 class GrGLSLShaderBuilder {
24 public: 22 public:
25 GrGLSLShaderBuilder(GrGLSLProgramBuilder* program); 23 GrGLSLShaderBuilder(GrGLSLProgramBuilder* program);
26 virtual ~GrGLSLShaderBuilder() {} 24 virtual ~GrGLSLShaderBuilder() {}
27 25
26 typedef GrGLSLUniformHandler::SamplerHandle SamplerHandle;
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 SamplerHandle,
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 shader code instead.*/ 37 /** Version of above that appends the result to the shader code instead.*/
38 void appendTextureLookup(const GrGLSLSampler&, 38 void appendTextureLookup(SamplerHandle,
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 SamplerHandle,
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 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 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. */ 54 exactly once, so expressions like "idx++" are acceptable. */
55 void appendTexelFetch(SkString* out, const GrGLSLSampler&, const char* coord Expr) const; 55 void appendTexelFetch(SkString* out, SamplerHandle, const char* coordExpr) c onst;
56 56
57 /** Version of above that appends the result to the shader code instead.*/ 57 /** Version of above that appends the result to the shader code instead.*/
58 void appendTexelFetch(const GrGLSLSampler&, const char* coordExpr); 58 void appendTexelFetch(SamplerHandle, const char* coordExpr);
59 59
60 /** 60 /**
61 * Adds a #define directive to the top of the shader. 61 * Adds a #define directive to the top of the shader.
62 */ 62 */
63 void define(const char* macro, const char* replacement) { 63 void define(const char* macro, const char* replacement) {
64 this->definitions().appendf("#define %s %s\n", macro, replacement); 64 this->definitions().appendf("#define %s %s\n", macro, replacement);
65 } 65 }
66 66
67 void define(const char* macro, int replacement) { 67 void define(const char* macro, int replacement) {
68 this->definitions().appendf("#define %s %i\n", macro, replacement); 68 this->definitions().appendf("#define %s %i\n", macro, replacement);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 int fCodeIndex; 240 int fCodeIndex;
241 bool fFinalized; 241 bool fFinalized;
242 242
243 friend class GrGLSLProgramBuilder; 243 friend class GrGLSLProgramBuilder;
244 friend class GrGLProgramBuilder; 244 friend class GrGLProgramBuilder;
245 friend class GrGLSLVaryingHandler; // to access noperspective interpolation feature. 245 friend class GrGLSLVaryingHandler; // to access noperspective interpolation feature.
246 friend class GrGLPathProgramBuilder; // to access fInputs. 246 friend class GrGLPathProgramBuilder; // to access fInputs.
247 friend class GrVkPipelineStateBuilder; 247 friend class GrVkPipelineStateBuilder;
248 }; 248 };
249 #endif 249 #endif
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLSampler.h ('k') | src/gpu/glsl/GrGLSLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698