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

Proposed by Jesse Barker on 2012-07-09
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 2012-07-09 Approve on 2012-07-16
Jesse Barker Resubmit on 2012-07-13
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.
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
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?

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 on 2012-07-13

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.

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: Resubmit
review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches

to all changes: