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