Merge lp:~glcompbench-dev/glcompbench/scale into lp:glcompbench

Proposed by Jesse Barker
Status: Merged
Merged at revision: 87
Proposed branch: lp:~glcompbench-dev/glcompbench/scale
Merge into: lp:glcompbench
Diff against target: 196 lines (+166/-0)
3 files modified
src/composite-test-simple-scale.cc (+150/-0)
src/composite-test.h (+14/-0)
src/glcompbench.cc (+2/-0)
To merge this branch: bzr merge lp:~glcompbench-dev/glcompbench/scale
Reviewer Review Type Date Requested Status
Alexandros Frantzis Approve
Jesse Barker Needs Resubmitting
Review via email: mp+113989@code.launchpad.net

Description of the change

Adds a "scale" test to the list of default GL-based benchmarks. Simulates the effect of de-iconifying a window by applying a scaling transform.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Making the scaler object static in CompositeTestSimpleScale::draw() breaks multiple invocations of the scale test, because the scaler object is initialized only once with the duration value of the first invocation.

Try, for example, "-b :iterations=1 -b scale:duration=10 -b scale:duration=5"

review: Needs Fixing
Revision history for this message
Jesse Barker (jesse-barker) wrote :

So, do you think we need a new scaler object for each scene creation, or do you think we just need to reinitilize the object during setup?

On a separate but related topic, the fader object in the fade test has a similar set up. Perhaps that should be revisited as well?

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> So, do you think we need a new scaler object for each scene creation, or do
> you think we just need to reinitilize the object during setup?

I think it's fine either way.

> On a separate but related topic, the fader object in the fade test has a
> similar set up. Perhaps that should be revisited as well?

If it has the same issue, which I guess it does, then we should fix that, too (preferably not in this branch).

88. By Jesse Barker

CompositeTestSimpleScale: Revise the Scaler object so that it can be reinitialized
at prepare_for_run() time. This allows for multiple invocations of the scale
test with different parameters. Scaler gets a new "init()" method that handles
the duration option, and the declaration of its instance gets moved to module
scope so that both prepare_for_run() and draw() get access to it.

Revision history for this message
Jesse Barker (jesse-barker) wrote :

Let's try again. The last change should address the issues you've called out. I'll fix the fade test separately.

review: Needs Resubmitting
Revision history for this message
Alexandros Frantzis (afrantzis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'src/composite-test-simple-scale.cc'
--- src/composite-test-simple-scale.cc 1970-01-01 00:00:00 +0000
+++ src/composite-test-simple-scale.cc 2012-07-13 15:30:25 +0000
@@ -0,0 +1,150 @@
1/*
2 * Copyright © 2012 Linaro Limited
3 *
4 * This file is part of glcompbench.
5 *
6 * glcompbench is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * glcompbench is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with glcompbench. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authors:
20 * Alexandros Frantzis <alexandros.frantzis@linaro.org>
21 * Jesse Barker <jesse.barker@linaro.org>
22 */
23
24#include "gl-headers.h"
25#include "composite-test.h"
26#include "options.h"
27#include "log.h"
28#include <sstream>
29
30using std::string;
31using std::list;
32
33bool
34CompositeTestSimpleScale::init_shaders(ShaderSource& vtx, ShaderSource& frg)
35{
36 static const string precisionString("default,default,default,default");
37 static const ShaderSource::Precision precision(precisionString);
38 vtx.precision(precision);
39 frg.precision(precision);
40 static const float alpha_bias(0.5);
41 frg.add_const("alpha_bias", alpha_bias);
42
43 return true;
44}
45
46// We want to scale smoothly across the test duration, so take a timestamp
47// at the beginning of the test (beginning of the first draw), and take one
48// each time we update the scale bias.
49class Scaler
50{
51 uint64_t start_time_;
52 uint64_t last_eof_;
53 float bias_;
54 float duration_;
55public:
56 Scaler() :
57 start_time_(0),
58 last_eof_(0),
59 bias_(0.0),
60 duration_(0.0) {}
61 ~Scaler() {}
62 void init(const string& duration)
63 {
64 // Convert the string representation of the duration in seconds
65 // to microseconds as that's what we'll need to track the time.
66 std::stringstream ss(duration);
67 ss >> duration_;
68 duration_ *= 1000000;
69 start_time_ = Profiler::get_timestamp_us();
70 }
71 void update()
72 {
73 last_eof_ = Profiler::get_timestamp_us();
74 uint64_t howLong(last_eof_ - start_time_);
75 if (howLong < duration_)
76 {
77 // Still inside of the test duration. Compute the bias.
78 bias_ = howLong / duration_;
79 return;
80 }
81 // Reset back to the beginning.
82 start_time_ = last_eof_;
83 bias_ = 0.0;
84 }
85 float bias() const { return bias_; }
86};
87
88static Scaler scaler;
89
90void
91CompositeTestSimpleScale::prepare_for_run(list<CompositeWindow*>& window_list)
92{
93 CompositeTestSimpleBase::prepare_for_run(window_list);
94 scaler.init(options_["duration"].value);
95}
96
97void
98CompositeTestSimpleScale::draw(list<CompositeWindow *> &window_list)
99{
100 vboData_.bind();
101 glActiveTexture(GL_TEXTURE0);
102 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
103
104 /* Set up the position of the attributes in the vertex array */
105 glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0, vboData_.vertexOffset());
106 glVertexAttribPointer(texcoordIndex_, 2, GL_FLOAT, GL_FALSE, 0, vboData_.texcoordOffset());
107
108 /* Enable the attributes */
109 glEnableVertexAttribArray(vertexIndex_);
110 glEnableVertexAttribArray(texcoordIndex_);
111
112 program_[projection_matrix_name_] = projection_matrix.getCurrent();
113
114 /* Find out how many windows are visible and calculate the angular step */
115 GLuint visible_windows(num_visible_windows(window_list));
116 GLfloat angular_step(2 * M_PI / visible_windows);
117
118 /* Draw the windows in a circle using the calculated angular step */
119 float scale_bias(scaler.bias());
120 GLint i(0);
121 for(list<CompositeWindow*>::iterator iter = window_list.begin();
122 iter != window_list.end(); ++iter)
123 {
124 CompositeWindow *comp_win = *iter;
125 GLuint tex = comp_win->get_texture().i;
126 if (tex) {
127 model_view_matrix.push();
128 model_view_matrix.translate(cos(angular_step * i),
129 sin(angular_step * i), 0);
130 model_view_matrix.scale(scale_bias, scale_bias, scale_bias);
131
132 /* Load shader ModelView uniform */
133 program_[model_view_matrix_name_] = model_view_matrix.getCurrent();
134
135 Log::debug("Drawing Win: 0x%x Tex: 0x%x\n",
136 comp_win->get_xwindow(), comp_win->get_texture().i);
137
138 glBindTexture(GL_TEXTURE_2D, tex);
139 vboData_.draw();
140 model_view_matrix.pop();
141 ++i;
142 }
143 }
144
145 // Disable the attributes
146 glDisableVertexAttribArray(vertexIndex_);
147 glDisableVertexAttribArray(texcoordIndex_);
148 vboData_.unbind();
149 scaler.update();
150}
0151
=== modified file 'src/composite-test.h'
--- src/composite-test.h 2012-03-09 03:58:54 +0000
+++ src/composite-test.h 2012-07-13 15:30:25 +0000
@@ -244,4 +244,18 @@
244 virtual void prepare_for_run(std::list<CompositeWindow*> &window_list);244 virtual void prepare_for_run(std::list<CompositeWindow*> &window_list);
245};245};
246246
247class CompositeTestSimpleScale : public CompositeTestSimpleBase
248{
249public:
250 CompositeTestSimpleScale() :
251 CompositeTestSimpleBase("scale",
252 GLCOMPBENCH_DATA_PATH"/default.vert",
253 GLCOMPBENCH_DATA_PATH"/default.frag")
254 {}
255
256 virtual bool init_shaders(ShaderSource& vtx, ShaderSource& frg);
257 virtual void draw(std::list<CompositeWindow*> &window_list);
258 virtual void prepare_for_run(std::list<CompositeWindow*> &window_list);
259};
260
247#endif // COMPOSITE_TEST_H_261#endif // COMPOSITE_TEST_H_
248262
=== modified file 'src/glcompbench.cc'
--- src/glcompbench.cc 2012-05-16 13:14:53 +0000
+++ src/glcompbench.cc 2012-07-13 15:30:25 +0000
@@ -47,6 +47,7 @@
47 "fade",47 "fade",
48 "blur",48 "blur",
49 "brick",49 "brick",
50 "scale",
50 "pixman",51 "pixman",
51 "xrender",52 "xrender",
52 NULL53 NULL
@@ -199,6 +200,7 @@
199 Benchmark::register_test(*new CompositeTestSimpleBlur());200 Benchmark::register_test(*new CompositeTestSimpleBlur());
200 Benchmark::register_test(*new CompositeTestSimpleFade());201 Benchmark::register_test(*new CompositeTestSimpleFade());
201 Benchmark::register_test(*new CompositeTestSimpleBrick());202 Benchmark::register_test(*new CompositeTestSimpleBrick());
203 Benchmark::register_test(*new CompositeTestSimpleScale());
202 Benchmark::register_test(*new CompositeTestPixman());204 Benchmark::register_test(*new CompositeTestPixman());
203 Benchmark::register_test(*new CompositeTestXRender());205 Benchmark::register_test(*new CompositeTestXRender());
204206

Subscribers

People subscribed via source and target branches

to all changes: