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

Side by Side Diff: bench/GLInstancedArraysBench.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/GLBench.cpp ('k') | bench/GLVec4ScalarBench.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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 oColor.appendDecl(glslCaps, &vshaderTxt); 123 oColor.appendDecl(glslCaps, &vshaderTxt);
124 vshaderTxt.append(";\n"); 124 vshaderTxt.append(";\n");
125 125
126 vshaderTxt.append( 126 vshaderTxt.append(
127 "void main()\n" 127 "void main()\n"
128 "{\n" 128 "{\n"
129 "gl_Position = vec4(a_position, 0., 1.);\n" 129 "gl_Position = vec4(a_position, 0., 1.);\n"
130 "o_color = a_color;\n" 130 "o_color = a_color;\n"
131 "}\n"); 131 "}\n");
132 132
133 const GrGLInterface* gl = ctx->interface();
134
135 // setup fragment shader 133 // setup fragment shader
136 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut _TypeModifier); 134 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut _TypeModifier);
137 SkString fshaderTxt(version); 135 SkString fshaderTxt(version);
138 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps, &fshaderTxt); 136 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa ps, &fshaderTxt);
139 oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); 137 oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
140 oColor.appendDecl(glslCaps, &fshaderTxt); 138 oColor.appendDecl(glslCaps, &fshaderTxt);
141 fshaderTxt.append(";\n"); 139 fshaderTxt.append(";\n");
142 140
143 const char* fsOutName; 141 const char* fsOutName;
144 if (glslCaps->mustDeclareFragmentShaderOutput()) { 142 if (glslCaps->mustDeclareFragmentShaderOutput()) {
145 oFragColor.appendDecl(glslCaps, &fshaderTxt); 143 oFragColor.appendDecl(glslCaps, &fshaderTxt);
146 fshaderTxt.append(";\n"); 144 fshaderTxt.append(";\n");
147 fsOutName = oFragColor.c_str(); 145 fsOutName = oFragColor.c_str();
148 } else { 146 } else {
149 fsOutName = "gl_FragColor"; 147 fsOutName = "gl_FragColor";
150 } 148 }
151 149
152 fshaderTxt.appendf( 150 fshaderTxt.appendf(
153 "void main()\n" 151 "void main()\n"
154 "{\n" 152 "{\n"
155 "%s = vec4(o_color, 1.0);\n" 153 "%s = vec4(o_color, 1.0);\n"
156 "}\n", fsOutName); 154 "}\n", fsOutName);
157 155
158 return CreateProgram(gl, vshaderTxt.c_str(), fshaderTxt.c_str()); 156 return CreateProgram(ctx, vshaderTxt.c_str(), fshaderTxt.c_str());
159 } 157 }
160 158
161 template<typename Func> 159 template<typename Func>
162 static void setup_matrices(int numQuads, Func f) { 160 static void setup_matrices(int numQuads, Func f) {
163 // We draw a really small triangle so we are not fill rate limited 161 // We draw a really small triangle so we are not fill rate limited
164 for (int i = 0 ; i < numQuads; i++) { 162 for (int i = 0 ; i < numQuads; i++) {
165 SkMatrix m = SkMatrix::I(); 163 SkMatrix m = SkMatrix::I();
166 m.setScale(0.0001f, 0.0001f); 164 m.setScale(0.0001f, 0.0001f);
167 f(m); 165 f(m);
168 } 166 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 1) ) 387 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 1) )
390 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 1) ) 388 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 1) )
391 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 2) ) 389 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 2) )
392 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 2) ) 390 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 2) )
393 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 4) ) 391 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 4) )
394 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 4) ) 392 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 4) )
395 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 8) ) 393 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 8) )
396 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 8) ) 394 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 8) )
397 395
398 #endif 396 #endif
OLDNEW
« no previous file with comments | « bench/GLBench.cpp ('k') | bench/GLVec4ScalarBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698