OLD | NEW |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 aPosition.appendDecl(glslCaps, &vshaderTxt); | 119 aPosition.appendDecl(glslCaps, &vshaderTxt); |
120 vshaderTxt.append(";\n"); | 120 vshaderTxt.append(";\n"); |
121 aColor.appendDecl(glslCaps, &vshaderTxt); | 121 aColor.appendDecl(glslCaps, &vshaderTxt); |
122 vshaderTxt.append(";\n"); | 122 vshaderTxt.append(";\n"); |
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.f, 1.f);\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(); | 133 const GrGLInterface* gl = ctx->interface(); |
134 | 134 |
135 // setup fragment shader | 135 // setup fragment shader |
136 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut
_TypeModifier); | 136 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut
_TypeModifier); |
137 SkString fshaderTxt(version); | 137 SkString fshaderTxt(version); |
138 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa
ps, &fshaderTxt); | 138 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa
ps, &fshaderTxt); |
139 oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); | 139 oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); |
140 oColor.appendDecl(glslCaps, &fshaderTxt); | 140 oColor.appendDecl(glslCaps, &fshaderTxt); |
141 fshaderTxt.append(";\n"); | 141 fshaderTxt.append(";\n"); |
142 | 142 |
143 const char* fsOutName; | 143 const char* fsOutName; |
144 if (glslCaps->mustDeclareFragmentShaderOutput()) { | 144 if (glslCaps->mustDeclareFragmentShaderOutput()) { |
145 oFragColor.appendDecl(glslCaps, &fshaderTxt); | 145 oFragColor.appendDecl(glslCaps, &fshaderTxt); |
146 fshaderTxt.append(";\n"); | 146 fshaderTxt.append(";\n"); |
147 fsOutName = oFragColor.c_str(); | 147 fsOutName = oFragColor.c_str(); |
148 } else { | 148 } else { |
149 fsOutName = "gl_FragColor"; | 149 fsOutName = "gl_FragColor"; |
150 } | 150 } |
151 | 151 |
152 fshaderTxt.appendf( | 152 fshaderTxt.appendf( |
153 "void main()\n" | 153 "void main()\n" |
154 "{\n" | 154 "{\n" |
155 "%s = vec4(o_color, 1.0f);\n" | 155 "%s = vec4(o_color, 1.0);\n" |
156 "}\n", fsOutName); | 156 "}\n", fsOutName); |
157 | 157 |
158 return CreateProgram(gl, vshaderTxt.c_str(), fshaderTxt.c_str()); | 158 return CreateProgram(gl, vshaderTxt.c_str(), fshaderTxt.c_str()); |
159 } | 159 } |
160 | 160 |
161 template<typename Func> | 161 template<typename Func> |
162 static void setup_matrices(int numQuads, Func f) { | 162 static void setup_matrices(int numQuads, Func f) { |
163 // We draw a really small triangle so we are not fill rate limited | 163 // We draw a really small triangle so we are not fill rate limited |
164 for (int i = 0 ; i < numQuads; i++) { | 164 for (int i = 0 ; i < numQuads; i++) { |
165 SkMatrix m = SkMatrix::I(); | 165 SkMatrix m = SkMatrix::I(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseOne_VboSetup, 1) ) | 389 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseOne_VboSetup, 1) ) |
390 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseTwo_VboSetup, 1) ) | 390 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseTwo_VboSetup, 1) ) |
391 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseOne_VboSetup, 2) ) | 391 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseOne_VboSetup, 2) ) |
392 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseTwo_VboSetup, 2) ) | 392 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseTwo_VboSetup, 2) ) |
393 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseOne_VboSetup, 4) ) | 393 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseOne_VboSetup, 4) ) |
394 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseTwo_VboSetup, 4) ) | 394 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseTwo_VboSetup, 4) ) |
395 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseOne_VboSetup, 8) ) | 395 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseOne_VboSetup, 8) ) |
396 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseTwo_VboSetup, 8) ) | 396 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench:
:kUseTwo_VboSetup, 8) ) |
397 | 397 |
398 #endif | 398 #endif |
OLD | NEW |