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

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

Issue 2288033003: Turned on SkSL->GLSL compiler (Closed)
Patch Set: changed <iostream> to <ostream> Created 4 years, 2 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/GrGLSLFragmentShaderBuilder.cpp ('k') | src/gpu/glsl/GrGLSLShaderVar.h » ('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
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 /** Fetches an unfiltered texel from a sampler at integer coordinates. coord Expr must match the 66 /** Fetches an unfiltered texel from a sampler at integer coordinates. coord Expr must match the
67 dimensionality of the sampler and must be within the sampler's range. co ordExpr is emitted 67 dimensionality of the sampler and must be within the sampler's range. co ordExpr is emitted
68 exactly once, so expressions like "idx++" are acceptable. */ 68 exactly once, so expressions like "idx++" are acceptable. */
69 void appendTexelFetch(SkString* out, SamplerHandle, const char* coordExpr) c onst; 69 void appendTexelFetch(SkString* out, SamplerHandle, const char* coordExpr) c onst;
70 70
71 /** Version of above that appends the result to the shader code instead.*/ 71 /** Version of above that appends the result to the shader code instead.*/
72 void appendTexelFetch(SamplerHandle, const char* coordExpr); 72 void appendTexelFetch(SamplerHandle, const char* coordExpr);
73 73
74 /** 74 /**
75 * Adds a #define directive to the top of the shader. 75 * Adds a constant declaration to the top of the shader.
76 */ 76 */
77 void define(const char* macro, const char* replacement) { 77 void defineConstant(const char* type, const char* name, const char* value) {
78 this->definitions().appendf("#define %s %s\n", macro, replacement); 78 this->definitions().appendf("const %s %s = %s;\n", type, name, value);
79 } 79 }
80 80
81 void define(const char* macro, int replacement) { 81 void defineConstant(const char* name, int value) {
82 this->definitions().appendf("#define %s %i\n", macro, replacement); 82 this->definitions().appendf("const int %s = %i;\n", name, value);
83 } 83 }
84 84
85 void definef(const char* macro, const char* replacement, ...) { 85 void defineConstant(const char* name, float value) {
86 this->definitions().appendf("#define %s ", macro); 86 this->definitions().appendf("const float %s = %f;\n", name, value);
87 }
88
89 void defineConstantf(const char* type, const char* name, const char* fmt, .. .) {
90 this->definitions().appendf("const %s %s = ", type, name);
87 va_list args; 91 va_list args;
88 va_start(args, replacement); 92 va_start(args, fmt);
89 this->definitions().appendVAList(replacement, args); 93 this->definitions().appendVAList(fmt, args);
90 va_end(args); 94 va_end(args);
91 this->definitions().append("\n"); 95 this->definitions().append(";\n");
92 } 96 }
93 97
94 /** 98 /**
95 * Called by GrGLSLProcessors to add code to one of the shaders. 99 * Called by GrGLSLProcessors to add code to one of the shaders.
96 */ 100 */
97 void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { 101 void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
98 va_list args; 102 va_list args;
99 va_start(args, format); 103 va_start(args, format);
100 this->code().appendVAList(format, args); 104 this->code().appendVAList(format, args);
101 va_end(args); 105 va_end(args);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 int fCodeIndex; 258 int fCodeIndex;
255 bool fFinalized; 259 bool fFinalized;
256 260
257 friend class GrGLSLProgramBuilder; 261 friend class GrGLSLProgramBuilder;
258 friend class GrGLProgramBuilder; 262 friend class GrGLProgramBuilder;
259 friend class GrGLSLVaryingHandler; // to access noperspective interpolation feature. 263 friend class GrGLSLVaryingHandler; // to access noperspective interpolation feature.
260 friend class GrGLPathProgramBuilder; // to access fInputs. 264 friend class GrGLPathProgramBuilder; // to access fInputs.
261 friend class GrVkPipelineStateBuilder; 265 friend class GrVkPipelineStateBuilder;
262 }; 266 };
263 #endif 267 #endif
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp ('k') | src/gpu/glsl/GrGLSLShaderVar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698