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

Side by Side Diff: bench/GLVec4ScalarBench.cpp

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 | « bench/GLInstancedArraysBench.cpp ('k') | bench/GLVertexAttributesBench.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 2015 Google Inc. 2 * Copyright 2015 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 #include "SkMatrix.h" 8 #include "SkMatrix.h"
9 #include "SkPoint.h" 9 #include "SkPoint.h"
10 #include "SkString.h" 10 #include "SkString.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 vshaderTxt.append(";\n"); 117 vshaderTxt.append(";\n");
118 118
119 vshaderTxt.append( 119 vshaderTxt.append(
120 "void main()\n" 120 "void main()\n"
121 "{\n" 121 "{\n"
122 " gl_Position = vec4(a_position, 0.0, 1.0);\n" 122 " gl_Position = vec4(a_position, 0.0, 1.0);\n"
123 " o_position = a_position;\n" 123 " o_position = a_position;\n"
124 " o_color = a_color;\n" 124 " o_color = a_color;\n"
125 "}\n"); 125 "}\n");
126 126
127 const GrGLInterface* gl = ctx->interface();
128
129 // set up fragment shader; this fragment shader will have fNumStages coverag e stages plus an 127 // set up fragment shader; this fragment shader will have fNumStages coverag e stages plus an
130 // XP stage at the end. Each coverage stage computes the pixel's distance f rom some hard- 128 // XP stage at the end. Each coverage stage computes the pixel's distance f rom some hard-
131 // coded center and compare that to some hard-coded circle radius to compute a coverage. 129 // coded center and compare that to some hard-coded circle radius to compute a coverage.
132 // Then, this coverage is mixed with the coverage from the previous stage an d passed to the 130 // Then, this coverage is mixed with the coverage from the previous stage an d passed to the
133 // next stage. 131 // next stage.
134 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut _TypeModifier); 132 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut _TypeModifier);
135 SkString fshaderTxt(version); 133 SkString fshaderTxt(version);
136 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps, &fshaderTxt); 134 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps, &fshaderTxt);
137 oPosition.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); 135 oPosition.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
138 oPosition.appendDecl(glslCaps, &fshaderTxt); 136 oPosition.appendDecl(glslCaps, &fshaderTxt);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 ); 177 );
180 radius *= 0.8f; 178 radius *= 0.8f;
181 } 179 }
182 fshaderTxt.appendf( 180 fshaderTxt.appendf(
183 " {\n" 181 " {\n"
184 " %s = outputColor * outputCoverage;\n" 182 " %s = outputColor * outputCoverage;\n"
185 " }\n" 183 " }\n"
186 "}\n", 184 "}\n",
187 fsOutName); 185 fsOutName);
188 186
189 return CreateProgram(gl, vshaderTxt.c_str(), fshaderTxt.c_str()); 187 return CreateProgram(ctx, vshaderTxt.c_str(), fshaderTxt.c_str());
190 } 188 }
191 189
192 template<typename Func> 190 template<typename Func>
193 static void setup_matrices(int numQuads, Func f) { 191 static void setup_matrices(int numQuads, Func f) {
194 // We draw a really small triangle so we are not fill rate limited 192 // We draw a really small triangle so we are not fill rate limited
195 for (int i = 0 ; i < numQuads; i++) { 193 for (int i = 0 ; i < numQuads; i++) {
196 SkMatrix m = SkMatrix::I(); 194 SkMatrix m = SkMatrix::I();
197 m.setScale(0.01f, 0.01f); 195 m.setScale(0.01f, 0.01f);
198 f(m); 196 f(m);
199 } 197 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe tup, 2) ) 293 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe tup, 2) )
296 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu p, 2) ) 294 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu p, 2) )
297 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe tup, 4) ) 295 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe tup, 4) )
298 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu p, 4) ) 296 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu p, 4) )
299 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe tup, 6) ) 297 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe tup, 6) )
300 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu p, 6) ) 298 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu p, 6) )
301 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe tup, 8) ) 299 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe tup, 8) )
302 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu p, 8) ) 300 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu p, 8) )
303 301
304 #endif 302 #endif
OLDNEW
« no previous file with comments | « bench/GLInstancedArraysBench.cpp ('k') | bench/GLVertexAttributesBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698