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

Side by Side Diff: bench/GLInstancedArraysBench.cpp

Issue 1217843002: Fix for valgrind use of uninitialized variable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | no next file » | 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"
11 #if SK_SUPPORT_GPU 11 #if SK_SUPPORT_GPU
12 #include "GrTest.h" 12 #include "GrTest.h"
13 #include "gl/GrGLGLSL.h" 13 #include "gl/GrGLGLSL.h"
14 #include "gl/GrGLInterface.h" 14 #include "gl/GrGLInterface.h"
15 #include "gl/GrGLShaderVar.h" 15 #include "gl/GrGLShaderVar.h"
16 #include "gl/GrGLUtil.h" 16 #include "gl/GrGLUtil.h"
17 #include "glsl/GrGLSLCaps.h" 17 #include "glsl/GrGLSLCaps.h"
18 #include <stdio.h> 18 #include <stdio.h>
19 19
20 /* 20 /*
21 * This is a native GL benchmark for instanced arrays vs vertex buffer objects. To benchmark this 21 * This is a native GL benchmark for instanced arrays vs vertex buffer objects. To benchmark this
22 * functionality, we draw n * kDrawMultipier triangles per run. If this number is less than 22 * functionality, we draw n * kDrawMultipier triangles per run. If this number is less than
23 * kNumTri then we do a single draw, either with instances, or drawArrays. Othe rwise we do 23 * kNumTri then we do a single draw, either with instances, or drawArrays. Othe rwise we do
24 * multiple draws. 24 * multiple draws.
25 * 25 *
26 * Additionally, there is a divisor, which if > 0 will act as a multiplier for t he number of draws 26 * Additionally, there is a divisor, which if > 0 will act as a multiplier for t he number of draws
27 * issued. 27 * issued.
28 */ 28 */
29 class GLInstancedArraysBench : public Benchmark { 29 class GLInstancedArraysBench : public Benchmark {
30 public:
31 GLInstancedArraysBench() : fTexture(0) {}
32
30 protected: 33 protected:
31 void onPerCanvasPreDraw(SkCanvas* canvas) override; 34 void onPerCanvasPreDraw(SkCanvas* canvas) override;
32 virtual void setup(const GrGLContext*)=0; 35 virtual void setup(const GrGLContext*)=0;
33 void onPerCanvasPostDraw(SkCanvas* canvas) override; 36 void onPerCanvasPostDraw(SkCanvas* canvas) override;
34 virtual void teardown(const GrGLInterface*)=0; 37 virtual void teardown(const GrGLInterface*)=0;
35 38
36 static const GrGLuint kScreenWidth = 800; 39 static const GrGLuint kScreenWidth = 800;
37 static const GrGLuint kScreenHeight = 600; 40 static const GrGLuint kScreenHeight = 600;
38 static const uint32_t kNumTri = 10000; 41 static const uint32_t kNumTri = 10000;
39 static const uint32_t kVerticesPerTri = 3; 42 static const uint32_t kVerticesPerTri = 3;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 kUseInstance_VboSetup, 74 kUseInstance_VboSetup,
72 }; 75 };
73 76
74 /* 77 /*
75 * drawDiv will act as a multiplier for the number of draws we issue if > 0. ie, 2 will issue 78 * drawDiv will act as a multiplier for the number of draws we issue if > 0. ie, 2 will issue
76 * 2x as many draws, 4 will issue 4x as many draws etc. There is a limit ho wever, which is 79 * 2x as many draws, 4 will issue 4x as many draws etc. There is a limit ho wever, which is
77 * kDrawMultipier. 80 * kDrawMultipier.
78 */ 81 */
79 GLCpuPosInstancedArraysBench(VboSetup vboSetup, int32_t drawDiv) 82 GLCpuPosInstancedArraysBench(VboSetup vboSetup, int32_t drawDiv)
80 : fVboSetup(vboSetup) 83 : fVboSetup(vboSetup)
81 , fDrawDiv(drawDiv) { 84 , fDrawDiv(drawDiv)
85 , fProgram(0)
86 , fVAO(0) {
82 fName = VboSetupToStr(vboSetup, fDrawDiv); 87 fName = VboSetupToStr(vboSetup, fDrawDiv);
83 } 88 }
84 89
85 protected: 90 protected:
86 const char* onGetName() override { 91 const char* onGetName() override {
87 return fName.c_str(); 92 return fName.c_str();
88 } 93 }
89 94
90 void setup(const GrGLContext*) override; 95 void setup(const GrGLContext*) override;
91 void onDraw(const int loops, SkCanvas* canvas) override; 96 void onDraw(const int loops, SkCanvas* canvas) override;
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 1) ) 707 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 1) )
703 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 1) ) 708 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 1) )
704 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 2) ) 709 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 2) )
705 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 2) ) 710 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 2) )
706 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 4) ) 711 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 4) )
707 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 4) ) 712 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 4) )
708 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 8) ) 713 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseOne_VboSetup, 8) )
709 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 8) ) 714 DEF_BENCH( return new GLCpuPosInstancedArraysBench(GLCpuPosInstancedArraysBench: :kUseTwo_VboSetup, 8) )
710 715
711 #endif 716 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698