From patchwork Mon Jul 16 17:01:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jesse Barker X-Patchwork-Id: 10015 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 23E0324024 for ; Mon, 16 Jul 2012 17:01:13 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id C1670A18038 for ; Mon, 16 Jul 2012 17:01:12 +0000 (UTC) Received: by ghbz12 with SMTP id z12so5642168ghb.11 for ; Mon, 16 Jul 2012 10:01:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=3NhmCT3eb2TSFZIAd1NvVHfgXxF9N3DVXVkAkbCYB4o=; b=FbAN6IYcwbjnSlHCBuuwMNSfCJyPN88BEEsifIJr4k8dpLoJbuOiD13YKknLXKub5A /D1JBo7nwUe0GZwid22t/23fdVuggZxaMiAYLRtXAFV7dwWHTNIu/c8urS4z2C+7PkCN 151cQGJm56L5ojHIihMf883MYn1htGpnMgvPhILXS5QH7JjkV4Z24lwxP8++VrRVUCRd +hz4n7J3zktP/ENsq4bNuzQB94rcwq6Z87pNaVUJ7Apf3YCPFLrdlZGh0kUt9v8vpaVS dhg86jWDI5A4UjGMJVBPjgbJqrtkoyuZ/ufARZzfhQHWNfMg1Q249sEkQY5xijy5PQsR habQ== Received: by 10.50.193.196 with SMTP id hq4mr5707442igc.57.1342458072067; Mon, 16 Jul 2012 10:01:12 -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.231.241.2 with SMTP id lc2csp10642ibb; Mon, 16 Jul 2012 10:01:11 -0700 (PDT) Received: by 10.180.83.234 with SMTP id t10mr23142099wiy.0.1342458070890; Mon, 16 Jul 2012 10:01:10 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id i9si25117411wiy.24.2012.07.16.10.01.10 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jul 2012 10:01:10 -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 1SqofW-0008W4-7v for ; Mon, 16 Jul 2012 17:01:10 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 2A17DE00AD for ; Mon, 16 Jul 2012 17:01:10 +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: 87 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glcompbench-dev/glcompbench/trunk] Rev 87: Merge of lp:~glcompbench-dev/glcompbench/scale. Message-Id: <20120716170110.9443.17828.launchpad@ackee.canonical.com> Date: Mon, 16 Jul 2012 17:01:10 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15627"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 2269b348e941bcb0de6a9a1db581dd52b729be7c X-Gm-Message-State: ALoCoQlkZDtsLGTrGccPEMJLkKzLzHQ+MqL8D806czugcLL2DXJQFw+LOrOz2pWkb1En8sf+2VbP Merge authors: Jesse Barker (jesse-barker) Related merge proposals: https://code.launchpad.net/~glcompbench-dev/glcompbench/scale/+merge/113989 proposed by: Jesse Barker (jesse-barker) review: Approve - Alexandros Frantzis (afrantzis) review: Resubmit - Jesse Barker (jesse-barker) ------------------------------------------------------------ revno: 87 [merge] committer: Jesse Barker branch nick: trunk timestamp: Mon 2012-07-16 09:58:40 -0700 message: Merge of lp:~glcompbench-dev/glcompbench/scale. Adds new test CompositeTestSimpleScale (based upon CompositeTestSimpleBase). added: src/composite-test-simple-scale.cc modified: src/composite-test.h src/glcompbench.cc --- 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 '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:26:14 +0000 @@ -0,0 +1,150 @@ +/* + * Copyright © 2012 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; +using std::list; + +bool +CompositeTestSimpleScale::init_shaders(ShaderSource& vtx, ShaderSource& frg) +{ + static const string precisionString("default,default,default,default"); + static const ShaderSource::Precision precision(precisionString); + vtx.precision(precision); + frg.precision(precision); + static const float alpha_bias(0.5); + frg.add_const("alpha_bias", alpha_bias); + + return true; +} + +// We want to scale 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 update the scale bias. +class Scaler +{ + uint64_t start_time_; + uint64_t last_eof_; + float bias_; + float duration_; +public: + Scaler() : + start_time_(0), + last_eof_(0), + bias_(0.0), + duration_(0.0) {} + ~Scaler() {} + void init(const string& duration) + { + // 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(); + } + 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_; } +}; + +static Scaler scaler; + +void +CompositeTestSimpleScale::prepare_for_run(list& window_list) +{ + CompositeTestSimpleBase::prepare_for_run(window_list); + scaler.init(options_["duration"].value); +} + +void +CompositeTestSimpleScale::draw(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(); + + /* 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 */ + float scale_bias(scaler.bias()); + GLint i(0); + for(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); + model_view_matrix.scale(scale_bias, scale_bias, scale_bias); + + /* 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(); + scaler.update(); +} === modified file 'src/composite-test.h' --- src/composite-test.h 2012-07-13 15:40:15 +0000 +++ src/composite-test.h 2012-07-16 16:58:40 +0000 @@ -245,4 +245,18 @@ virtual void prepare_for_run(std::list &window_list); }; +class CompositeTestSimpleScale : public CompositeTestSimpleBase +{ +public: + CompositeTestSimpleScale() : + CompositeTestSimpleBase("scale", + GLCOMPBENCH_DATA_PATH"/default.vert", + GLCOMPBENCH_DATA_PATH"/default.frag") + {} + + virtual bool init_shaders(ShaderSource& vtx, ShaderSource& frg); + virtual void draw(std::list &window_list); + virtual void prepare_for_run(std::list &window_list); +}; + #endif // COMPOSITE_TEST_H_ === modified file 'src/glcompbench.cc' --- src/glcompbench.cc 2012-05-16 13:14:53 +0000 +++ src/glcompbench.cc 2012-07-06 17:28:21 +0000 @@ -47,6 +47,7 @@ "fade", "blur", "brick", + "scale", "pixman", "xrender", NULL @@ -199,6 +200,7 @@ Benchmark::register_test(*new CompositeTestSimpleBlur()); Benchmark::register_test(*new CompositeTestSimpleFade()); Benchmark::register_test(*new CompositeTestSimpleBrick()); + Benchmark::register_test(*new CompositeTestSimpleScale()); Benchmark::register_test(*new CompositeTestPixman()); Benchmark::register_test(*new CompositeTestXRender());