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" |
11 | 11 |
12 #if SK_SUPPORT_GPU | 12 #if SK_SUPPORT_GPU |
13 #include "GLBench.h" | 13 #include "GLBench.h" |
14 #include "gl/GrGLContext.h" | 14 #include "gl/GrGLContext.h" |
15 #include "gl/GrGLGLSL.h" | 15 #include "gl/GrGLGLSL.h" |
16 #include "gl/GrGLInterface.h" | 16 #include "gl/GrGLInterface.h" |
17 #include "gl/GrGLShaderVar.h" | |
18 #include "gl/GrGLUtil.h" | 17 #include "gl/GrGLUtil.h" |
19 #include "glsl/GrGLSLCaps.h" | 18 #include "glsl/GrGLSLCaps.h" |
| 19 #include "glsl/GrGLSLShaderVar.h" |
20 | 20 |
21 /* | 21 /* |
22 * This is a native GL benchmark for instanced arrays vs vertex buffer objects.
To benchmark this | 22 * This is a native GL benchmark for instanced arrays vs vertex buffer objects.
To benchmark this |
23 * functionality, we draw n * kDrawMultipier triangles per run. If this number
is less than | 23 * functionality, we draw n * kDrawMultipier triangles per run. If this number
is less than |
24 * kNumTri then we do a single draw, either with instances, or drawArrays. Othe
rwise we do | 24 * kNumTri then we do a single draw, either with instances, or drawArrays. Othe
rwise we do |
25 * multiple draws. | 25 * multiple draws. |
26 * | 26 * |
27 * Additionally, there is a divisor, which if > 0 will act as a multiplier for t
he number of draws | 27 * Additionally, there is a divisor, which if > 0 will act as a multiplier for t
he number of draws |
28 * issued. | 28 * issued. |
29 */ | 29 */ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 GrGLuint fVAO; | 103 GrGLuint fVAO; |
104 GrGLuint fTexture; | 104 GrGLuint fTexture; |
105 }; | 105 }; |
106 | 106 |
107 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 107 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
108 | 108 |
109 GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) { | 109 GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) { |
110 const char* version = GrGLGetGLSLVersionDecl(*ctx); | 110 const char* version = GrGLGetGLSLVersionDecl(*ctx); |
111 | 111 |
112 // setup vertex shader | 112 // setup vertex shader |
113 GrGLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kAttribu
te_TypeModifier); | 113 GrGLSLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kAttri
bute_TypeModifier); |
114 GrGLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kAttribute_Typ
eModifier); | 114 GrGLSLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kAttribute_T
ypeModifier); |
115 GrGLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_Ty
peModifier); | 115 GrGLSLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_
TypeModifier); |
116 | 116 |
117 SkString vshaderTxt(version); | 117 SkString vshaderTxt(version); |
118 aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt); | 118 aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt); |
119 vshaderTxt.append(";\n"); | 119 vshaderTxt.append(";\n"); |
120 aColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt); | 120 aColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt); |
121 vshaderTxt.append(";\n"); | 121 vshaderTxt.append(";\n"); |
122 oColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt); | 122 oColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt); |
123 vshaderTxt.append(";\n"); | 123 vshaderTxt.append(";\n"); |
124 | 124 |
125 vshaderTxt.append( | 125 vshaderTxt.append( |
126 "void main()\n" | 126 "void main()\n" |
127 "{\n" | 127 "{\n" |
128 "gl_Position = vec4(a_position, 0.f, 1.f);\n" | 128 "gl_Position = vec4(a_position, 0.f, 1.f);\n" |
129 "o_color = a_color;\n" | 129 "o_color = a_color;\n" |
130 "}\n"); | 130 "}\n"); |
131 | 131 |
132 const GrGLInterface* gl = ctx->interface(); | 132 const GrGLInterface* gl = ctx->interface(); |
133 | 133 |
134 // setup fragment shader | 134 // setup fragment shader |
135 GrGLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_T
ypeModifier); | 135 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut
_TypeModifier); |
136 SkString fshaderTxt(version); | 136 SkString fshaderTxt(version); |
137 GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->f
Standard, | 137 GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->f
Standard, |
138 &fshaderTxt); | 138 &fshaderTxt); |
139 oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); | 139 oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); |
140 oColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt); | 140 oColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt); |
141 fshaderTxt.append(";\n"); | 141 fshaderTxt.append(";\n"); |
142 | 142 |
143 const char* fsOutName; | 143 const char* fsOutName; |
144 if (ctx->caps()->glslCaps()->mustDeclareFragmentShaderOutput()) { | 144 if (ctx->caps()->glslCaps()->mustDeclareFragmentShaderOutput()) { |
145 oFragColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt); | 145 oFragColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt); |
(...skipping 243 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 |