From patchwork Fri Oct 14 15:06:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jesse Barker X-Patchwork-Id: 4687 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 92D6023F59 for ; Fri, 14 Oct 2011 15:06:15 +0000 (UTC) Received: from mail-dy0-f52.google.com (mail-dy0-f52.google.com [209.85.220.52]) by fiordland.canonical.com (Postfix) with ESMTP id 7E11EA187EE for ; Fri, 14 Oct 2011 15:06:15 +0000 (UTC) Received: by dyj10 with SMTP id 10so207412dyj.11 for ; Fri, 14 Oct 2011 08:06:15 -0700 (PDT) Received: by 10.223.85.139 with SMTP id o11mr4613737fal.0.1318604775019; Fri, 14 Oct 2011 08:06:15 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.24.41 with SMTP id r9cs18047laf; Fri, 14 Oct 2011 08:06:14 -0700 (PDT) Received: by 10.213.9.16 with SMTP id j16mr1269786ebj.90.1318604773288; Fri, 14 Oct 2011 08:06:13 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id t69si3360099weq.49.2011.10.14.08.06.12 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Oct 2011 08:06:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1REjKu-0004W0-Mb for ; Fri, 14 Oct 2011 15:06:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 9D647E1FEB for ; Fri, 14 Oct 2011 15:06:12 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glcompbench X-Launchpad-Branch: ~glcompbench-dev/glcompbench/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 63 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glcompbench-dev/glcompbench/trunk] Rev 63: Merging fade feature branch. This adds a new test scenario that simulates the Message-Id: <20111014150612.26634.23436.launchpad@ackee.canonical.com> Date: Fri, 14 Oct 2011 15:06:12 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14124"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 96133e2283cf8b0df096c658d40ef862d60cadce Merge authors: Jesse Barker (jesse-barker) Related merge proposals: https://code.launchpad.net/~jesse-barker/glcompbench/fade/+merge/79357 proposed by: Jesse Barker (jesse-barker) review: Approve - Alexandros Frantzis (afrantzis) ------------------------------------------------------------ revno: 63 [merge] committer: Jesse Barker branch nick: trunk timestamp: Fri 2011-10-14 08:03:44 -0700 message: Merging fade feature branch. This adds a new test scenario that simulates the window fade in/out effect used by many window managers. added: data/fade.frag src/composite-test-simple-fade.cc modified: src/composite-test.h src/glcompbench.cc src/profiler.h --- lp:glcompbench https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk You are subscribed to branch lp:glcompbench. To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription === added file 'data/fade.frag' --- data/fade.frag 1970-01-01 00:00:00 +0000 +++ data/fade.frag 2011-10-13 22:48:52 +0000 @@ -0,0 +1,14 @@ +#ifdef GL_ES +precision mediump float; +#endif + +uniform float alpha_bias; +uniform sampler2D Texture0; +varying vec2 TextureCoord; + +void main(void) +{ + float alpha = 1.0 - alpha_bias; + vec4 texel = texture2D(Texture0, TextureCoord); + gl_FragColor = vec4(texel.xyz, alpha); +} === added file 'src/composite-test-simple-fade.cc' --- src/composite-test-simple-fade.cc 1970-01-01 00:00:00 +0000 +++ src/composite-test-simple-fade.cc 2011-10-14 12:41:30 +0000 @@ -0,0 +1,128 @@ +/* + * Copyright © 2011 Linaro Limited + * + * This file is part of glcompbench. + * + * glcompbench is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * glcompbench is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with glcompbench. If not, see . + * + * Authors: + * Alexandros Frantzis + * Jesse Barker + */ + +#include "gl-headers.h" +#include "composite-test.h" +#include "options.h" +#include "log.h" +#include + +using std::string; + +const string CompositeTestSimpleFade::fade_bias_name_("alpha_bias"); + +// We want to fade smoothly across the test duration, so take a timestamp +// at the beginning of the test (beginning of the first draw), and take one +// each time we'll update the fade bias to see if we should. We know based +// upon the fade increment constant how many times we should fade. +class Fader +{ + uint64_t start_time_; + uint64_t last_eof_; + float bias_; + float duration_; + Fader(); +public: + Fader(const string& duration) : + last_eof_(0), + bias_(0.0) + { + // Convert the string representation of the duration in seconds + // to microseconds as that's what we'll need to track the time. + std::stringstream ss(duration); + ss >> duration_; + duration_ *= 1000000; + start_time_ = Profiler::get_timestamp_us(); + } + ~Fader() {} + void update() + { + last_eof_ = Profiler::get_timestamp_us(); + uint64_t howLong(last_eof_ - start_time_); + if (howLong < duration_) + { + // Still inside of the test duration. Compute the bias. + bias_ = howLong / duration_; + return; + } + // Reset back to the beginning. + start_time_ = last_eof_; + bias_ = 0.0; + } + float bias() const { return bias_; } +}; + +void +CompositeTestSimpleFade::draw(std::list &window_list) +{ + vboData_.bind(); + glActiveTexture(GL_TEXTURE0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + /* Set up the position of the attributes in the vertex array */ + glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0, vboData_.vertexOffset()); + glVertexAttribPointer(texcoordIndex_, 2, GL_FLOAT, GL_FALSE, 0, vboData_.texcoordOffset()); + + /* Enable the attributes */ + glEnableVertexAttribArray(vertexIndex_); + glEnableVertexAttribArray(texcoordIndex_); + + program_[projection_matrix_name_] = projection_matrix.getCurrent(); + static Fader fader(options_["duration"].value); + program_[fade_bias_name_] = fader.bias(); + + /* Find out how many windows are visible and calculate the angular step */ + GLuint visible_windows(num_visible_windows(window_list)); + GLfloat angular_step(2 * M_PI / visible_windows); + + /* Draw the windows in a circle using the calculated angular step */ + GLint i(0); + for(std::list::iterator iter = window_list.begin(); + iter != window_list.end(); ++iter) + { + CompositeWindow *comp_win = *iter; + GLuint tex = comp_win->get_texture().i; + if (tex) { + model_view_matrix.push(); + model_view_matrix.translate(cos(angular_step * i), + sin(angular_step * i), 0); + + /* Load shader ModelView uniform */ + program_[model_view_matrix_name_] = model_view_matrix.getCurrent(); + + Log::debug("Drawing Win: 0x%x Tex: 0x%x\n", + comp_win->get_xwindow(), comp_win->get_texture().i); + + glBindTexture(GL_TEXTURE_2D, tex); + vboData_.draw(); + model_view_matrix.pop(); + ++i; + } + } + + // Disable the attributes + glDisableVertexAttribArray(vertexIndex_); + glDisableVertexAttribArray(texcoordIndex_); + vboData_.unbind(); + fader.update(); +} === modified file 'src/composite-test.h' --- src/composite-test.h 2011-08-03 17:14:34 +0000 +++ src/composite-test.h 2011-10-14 02:09:08 +0000 @@ -209,4 +209,17 @@ }; +class CompositeTestSimpleFade : public CompositeTestSimpleBase +{ + static const std::string fade_bias_name_; +public: + CompositeTestSimpleFade() : + CompositeTestSimpleBase("fade", + GLCOMPBENCH_DATA_PATH"/default.vert", + GLCOMPBENCH_DATA_PATH"/fade.frag") + {} + + virtual void draw(std::list &window_list); +}; + #endif // COMPOSITE_TEST_H_ === modified file 'src/glcompbench.cc' --- src/glcompbench.cc 2011-09-21 13:57:01 +0000 +++ src/glcompbench.cc 2011-10-13 22:48:52 +0000 @@ -38,6 +38,7 @@ static const char *default_benchmarks[] = { "default", + "fade", "brick", "pixman", "xrender", @@ -157,6 +158,7 @@ Benchmark::register_test(*new CompositeTestDefaultOptions()); Benchmark::register_test(*new CompositeTestSimpleDefault()); + Benchmark::register_test(*new CompositeTestSimpleFade()); Benchmark::register_test(*new CompositeTestSimpleBrick()); Benchmark::register_test(*new CompositeTestPixman()); Benchmark::register_test(*new CompositeTestXRender()); === modified file 'src/profiler.h' --- src/profiler.h 2011-04-04 12:56:06 +0000 +++ src/profiler.h 2011-10-14 12:41:30 +0000 @@ -135,6 +135,7 @@ void reset_point(Point p); void reset(void); Point get_num_points() { return points_.size(); } + static uint64_t get_timestamp_us(); /** * Gets the profiler singleton @@ -147,7 +148,6 @@ private: bool is_valid_point(Point p); - uint64_t get_timestamp_us(); std::vector points_; };