From patchwork Thu Nov 10 10:49:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 5026 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 6CECB23E04 for ; Thu, 10 Nov 2011 10:49:16 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 5603EA18960 for ; Thu, 10 Nov 2011 10:49:16 +0000 (UTC) Received: by faan26 with SMTP id n26so3782483faa.11 for ; Thu, 10 Nov 2011 02:49:16 -0800 (PST) Received: by 10.152.110.166 with SMTP id ib6mr4145218lab.19.1320922155899; Thu, 10 Nov 2011 02:49:15 -0800 (PST) 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.40.7 with SMTP id t7cs1041lak; Thu, 10 Nov 2011 02:49:15 -0800 (PST) Received: by 10.180.90.19 with SMTP id bs19mr7893721wib.7.1320922153727; Thu, 10 Nov 2011 02:49:13 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id cz6si4479205wib.45.2011.11.10.02.49.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 Nov 2011 02:49:13 -0800 (PST) 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 1ROSC0-0004R1-RM for ; Thu, 10 Nov 2011 10:49:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id BC94AE002F for ; Thu, 10 Nov 2011 10:49:12 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 163 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 163: Scene*: Implement validation support for all default benchmarks. Message-Id: <20111110104912.18078.20054.launchpad@ackee.canonical.com> Date: Thu, 10 Nov 2011 10:49: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="14263"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: eb120e4af9aaf1fcc8c7732b294b896174d977f1 Merge authors: Alexandros Frantzis (afrantzis) ------------------------------------------------------------ revno: 163 [merge] committer: Alexandros Frantzis branch nick: trunk timestamp: Thu 2011-11-10 12:30:53 +0200 message: Scene*: Implement validation support for all default benchmarks. modified: src/canvas.h src/main.cpp src/scene-buffer.cpp src/scene-build.cpp src/scene-bump.cpp src/scene-conditionals.cpp src/scene-desktop.cpp src/scene-effect-2d.cpp src/scene-function.cpp src/scene-loop.cpp src/scene-pulsar.cpp src/scene-shading.cpp src/scene-texture.cpp src/scene.cpp src/scene.h --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'src/canvas.h' --- src/canvas.h 2011-11-01 16:49:42 +0000 +++ src/canvas.h 2011-11-10 10:21:27 +0000 @@ -31,6 +31,7 @@ #include #include #include +#include /** * Abstraction for a GL rendering target. @@ -61,6 +62,24 @@ (static_cast(a) << 24); } + + /** + * Gets the euclidian distance from this pixel in 3D RGB space. + * + * @param p the pixel to get the distance from + * + * @return the euclidian distance + */ + double distance_rgb(const Canvas::Pixel &p) + { + // These work without casts because of integer promotion rules + // (the uint8_ts are promoted to ints) + double d = (r - p.r) * (r - p.r) + + (g - p.g) * (g - p.g) + + (b - p.b) * (b - p.b); + return std::sqrt(d); + } + uint8_t r; uint8_t g; uint8_t b; === modified file 'src/main.cpp' --- src/main.cpp 2011-11-02 14:56:58 +0000 +++ src/main.cpp 2011-11-08 11:58:19 +0000 @@ -270,6 +270,15 @@ return 0; } + /* Force 800x600 output for validation */ + if (Options::validate && + Options::size != std::pair(800, 600)) + { + Log::info("Ignoring custom size %dx%d for validation. Using 800x600.\n", + Options::size.first, Options::size.second); + Options::size = std::pair(800, 600); + } + // Create the canvas #if USE_GL CanvasX11GLX canvas(Options::size.first, Options::size.second); === modified file 'src/scene-buffer.cpp' --- src/scene-buffer.cpp 2011-11-01 16:46:08 +0000 +++ src/scene-buffer.cpp 2011-11-09 15:22:18 +0000 @@ -445,5 +445,20 @@ Scene::ValidationResult SceneBuffer::validate() { + static const double radius_3d(std::sqrt(3.0 * 2.0 * 2.0)); + + Canvas::Pixel ref(0x34, 0x99, 0xd7, 0xff); + Canvas::Pixel pixel = canvas_.read_pixel(402, 189); + + double dist = pixel.distance_rgb(ref); + if (dist < radius_3d + 0.01) { + return Scene::ValidationSuccess; + } + else { + Log::debug("Validation failed! Expected: 0x%x Actual: 0x%x Distance: %f\n", + ref.to_le32(), pixel.to_le32(), dist); + return Scene::ValidationFailure; + } + return Scene::ValidationUnknown; } === modified file 'src/scene-build.cpp' --- src/scene-build.cpp 2011-10-26 14:09:17 +0000 +++ src/scene-build.cpp 2011-11-08 13:57:38 +0000 @@ -252,7 +252,7 @@ Canvas::Pixel pixel = canvas_.read_pixel(canvas_.width() / 2, canvas_.height() / 2); - double dist = pixel_value_distance(pixel, ref); + double dist = pixel.distance_rgb(ref); if (dist < radius_3d + 0.01) { return Scene::ValidationSuccess; } === modified file 'src/scene-bump.cpp' --- src/scene-bump.cpp 2011-10-26 14:09:17 +0000 +++ src/scene-bump.cpp 2011-11-08 13:57:38 +0000 @@ -262,7 +262,7 @@ else return Scene::ValidationUnknown; - double dist = pixel_value_distance(pixel, ref); + double dist = pixel.distance_rgb(ref); if (dist < radius_3d + 0.01) { return Scene::ValidationSuccess; === modified file 'src/scene-conditionals.cpp' --- src/scene-conditionals.cpp 2011-11-01 16:46:08 +0000 +++ src/scene-conditionals.cpp 2011-11-09 15:22:18 +0000 @@ -116,3 +116,38 @@ startTime_ = Scene::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; } + +Scene::ValidationResult +SceneConditionals::validate() +{ + static const double radius_3d(std::sqrt(3.0 * 5.0 * 5.0)); + + bool frg_conditionals = options_["fragment-conditionals"].value == "true"; + int frg_steps(Util::fromString(options_["fragment-steps"].value)); + + if (!frg_conditionals) + return Scene::ValidationUnknown; + + Canvas::Pixel ref; + + if (frg_steps == 0) + ref = Canvas::Pixel(0xa0, 0xa0, 0xa0, 0xff); + else if (frg_steps == 5) + ref = Canvas::Pixel(0x25, 0x25, 0x25, 0xff); + else + return Scene::ValidationUnknown; + + Canvas::Pixel pixel = canvas_.read_pixel(293, 89); + + double dist = pixel.distance_rgb(ref); + if (dist < radius_3d + 0.01) { + return Scene::ValidationSuccess; + } + else { + Log::debug("Validation failed! Expected: 0x%x Actual: 0x%x Distance: %f\n", + ref.to_le32(), pixel.to_le32(), dist); + return Scene::ValidationFailure; + } + + return Scene::ValidationUnknown; +} === modified file 'src/scene-desktop.cpp' --- src/scene-desktop.cpp 2011-11-01 16:46:08 +0000 +++ src/scene-desktop.cpp 2011-11-09 15:22:18 +0000 @@ -935,5 +935,54 @@ Scene::ValidationResult SceneDesktop::validate() { - return ValidationUnknown; + static const double radius_3d(std::sqrt(3.0 * 2.0 * 2.0)); + + Canvas::Pixel ref; + + /* Parse the options */ + unsigned int windows(0); + unsigned int passes(0); + unsigned int blur_radius(0); + float window_size_factor(0.0); + unsigned int shadow_size(0); + + windows = Util::fromString(options_["windows"].value); + window_size_factor = Util::fromString(options_["window-size"].value); + passes = Util::fromString(options_["passes"].value); + blur_radius = Util::fromString(options_["blur-radius"].value); + shadow_size = Util::fromString(options_["shadow-size"].value); + + if (options_["effect"].value == "blur") + { + if (windows == 4 && passes == 1 && blur_radius == 5) + ref = Canvas::Pixel(0x89, 0xa3, 0x53, 0xff); + else + return Scene::ValidationUnknown; + } + else if (options_["effect"].value == "shadow") + { + if (windows == 4 && fabs(window_size_factor - 0.35) < 0.0001 && + shadow_size == 20) + { + ref = Canvas::Pixel(0x1f, 0x27, 0x0d, 0xff); + } + else + { + return Scene::ValidationUnknown; + } + } + + Canvas::Pixel pixel = canvas_.read_pixel(512, 209); + + double dist = pixel.distance_rgb(ref); + if (dist < radius_3d + 0.01) { + return Scene::ValidationSuccess; + } + else { + Log::debug("Validation failed! Expected: 0x%x Actual: 0x%x Distance: %f\n", + ref.to_le32(), pixel.to_le32(), dist); + return Scene::ValidationFailure; + } + + return Scene::ValidationUnknown; } === modified file 'src/scene-effect-2d.cpp' --- src/scene-effect-2d.cpp 2011-11-02 14:56:58 +0000 +++ src/scene-effect-2d.cpp 2011-11-08 13:57:38 +0000 @@ -186,7 +186,7 @@ * @return whether parsing succeeded */ static bool -parse_matrix(std::string &str, std::vector &matrix, +parse_matrix(const std::string &str, std::vector &matrix, unsigned int &width, unsigned int &height) { std::vector rows; @@ -392,5 +392,53 @@ Scene::ValidationResult SceneEffect2D::validate() { - return ValidationUnknown; + static const double radius_3d(std::sqrt(3.0)); + + std::vector kernel; + std::vector kernel_edge; + std::vector kernel_blur; + unsigned int kernel_width = 0; + unsigned int kernel_height = 0; + + if (!parse_matrix("0,1,0;1,-4,1;0,1,0;", kernel_edge, + kernel_width, kernel_height)) + { + return Scene::ValidationUnknown; + } + + if (!parse_matrix("1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;", + kernel_blur, + kernel_width, kernel_height)) + { + return Scene::ValidationUnknown; + } + + if (!parse_matrix(options_["kernel"].value, kernel, + kernel_width, kernel_height)) + { + return Scene::ValidationUnknown; + } + + Canvas::Pixel ref; + + if (kernel == kernel_edge) + ref = Canvas::Pixel(0x17, 0x0c, 0x2f, 0xff); + else if (kernel == kernel_blur) + ref = Canvas::Pixel(0xc7, 0xe1, 0x8d, 0xff); + else + return Scene::ValidationUnknown; + + Canvas::Pixel pixel = canvas_.read_pixel(452, 237); + + double dist = pixel.distance_rgb(ref); + if (dist < radius_3d + 0.01) { + return Scene::ValidationSuccess; + } + else { + Log::debug("Validation failed! Expected: 0x%x Actual: 0x%x Distance: %f\n", + ref.to_le32(), pixel.to_le32(), dist); + return Scene::ValidationFailure; + } + + return Scene::ValidationUnknown; } === modified file 'src/scene-function.cpp' --- src/scene-function.cpp 2011-11-01 16:46:08 +0000 +++ src/scene-function.cpp 2011-11-09 15:22:18 +0000 @@ -19,6 +19,8 @@ * Authors: * Alexandros Frantzis (glmark2) */ +#include + #include "scene.h" #include "mat.h" #include "stack.h" @@ -146,3 +148,32 @@ startTime_ = Scene::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; } + +Scene::ValidationResult +SceneFunction::validate() +{ + static const double radius_3d(std::sqrt(3.0 * 15.0 * 15.0)); + + int frg_steps = Util::fromString(options_["fragment-steps"].value); + + Canvas::Pixel ref; + + if (frg_steps == 5) + ref = Canvas::Pixel(0x5e, 0x5e, 0x5e, 0xff); + else + return Scene::ValidationUnknown; + + Canvas::Pixel pixel = canvas_.read_pixel(293, 89); + + double dist = pixel.distance_rgb(ref); + if (dist < radius_3d + 0.01) { + return Scene::ValidationSuccess; + } + else { + Log::debug("Validation failed! Expected: 0x%x Actual: 0x%x Distance: %f\n", + ref.to_le32(), pixel.to_le32(), dist); + return Scene::ValidationFailure; + } + + return Scene::ValidationUnknown; +} === modified file 'src/scene-loop.cpp' --- src/scene-loop.cpp 2011-11-01 16:46:08 +0000 +++ src/scene-loop.cpp 2011-11-09 15:22:18 +0000 @@ -19,6 +19,8 @@ * Authors: * Alexandros Frantzis (glmark2) */ +#include + #include "scene.h" #include "mat.h" #include "stack.h" @@ -141,3 +143,32 @@ startTime_ = Scene::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; } + +Scene::ValidationResult +SceneLoop::validate() +{ + static const double radius_3d(std::sqrt(3.0 * 15.0 * 15.0)); + + int frg_steps = Util::fromString(options_["fragment-steps"].value); + + Canvas::Pixel ref; + + if (frg_steps == 5) + ref = Canvas::Pixel(0x5e, 0x5e, 0x5e, 0xff); + else + return Scene::ValidationUnknown; + + Canvas::Pixel pixel = canvas_.read_pixel(293, 89); + + double dist = pixel.distance_rgb(ref); + if (dist < radius_3d + 0.01) { + return Scene::ValidationSuccess; + } + else { + Log::debug("Validation failed! Expected: 0x%x Actual: 0x%x Distance: %f\n", + ref.to_le32(), pixel.to_le32(), dist); + return Scene::ValidationFailure; + } + + return Scene::ValidationUnknown; +} === modified file 'src/scene-pulsar.cpp' --- src/scene-pulsar.cpp 2011-11-01 16:50:07 +0000 +++ src/scene-pulsar.cpp 2011-11-08 13:57:38 +0000 @@ -224,7 +224,31 @@ Scene::ValidationResult ScenePulsar::validate() { - return ValidationUnknown; + static const double radius_3d(std::sqrt(3.0)); + + int quads = Util::fromString(options_["quads"].value); + + if (options_["texture"].value != "false" || + options_["light"].value != "false" || + quads != 5) + { + return Scene::ValidationUnknown; + } + + Canvas::Pixel ref(0x77, 0x02, 0x77, 0xff); + Canvas::Pixel pixel = canvas_.read_pixel(400, 299); + + double dist = pixel.distance_rgb(ref); + if (dist < radius_3d + 0.01) { + return Scene::ValidationSuccess; + } + else { + Log::debug("Validation failed! Expected: 0x%x Actual: 0x%x Distance: %f\n", + ref.to_le32(), pixel.to_le32(), dist); + return Scene::ValidationFailure; + } + + return Scene::ValidationUnknown; } void === modified file 'src/scene-shading.cpp' --- src/scene-shading.cpp 2011-10-31 20:42:52 +0000 +++ src/scene-shading.cpp 2011-11-08 13:57:38 +0000 @@ -331,7 +331,7 @@ else return Scene::ValidationUnknown; - double dist = pixel_value_distance(pixel, ref); + double dist = pixel.distance_rgb(ref); if (dist < radius_3d + 0.01) { return Scene::ValidationSuccess; === modified file 'src/scene-texture.cpp' --- src/scene-texture.cpp 2011-10-26 14:09:17 +0000 +++ src/scene-texture.cpp 2011-11-08 13:57:38 +0000 @@ -208,7 +208,7 @@ else return Scene::ValidationUnknown; - double dist = pixel_value_distance(pixel, ref); + double dist = pixel.distance_rgb(ref); if (dist < radius_3d + 0.01) { return Scene::ValidationSuccess; === modified file 'src/scene.cpp' --- src/scene.cpp 2011-11-01 16:46:08 +0000 +++ src/scene.cpp 2011-11-08 13:57:38 +0000 @@ -187,24 +187,6 @@ } -double -Scene::pixel_value_distance(Canvas::Pixel p1, Canvas::Pixel p2, - bool use_alpha) -{ - double s(0.0); - - // These work without casts because of integer promotion rules - // (the Uint8s are promoted to ints) - s += (p1.r - p2.r) * (p1.r - p2.r); - s += (p1.g - p2.g) * (p1.g - p2.g); - s += (p1.b - p2.b) * (p1.b - p2.b); - - if (use_alpha) - s += (p1.a - p2.a) * (p1.a - p2.a); - - return std::sqrt(s); -} - bool Scene::load_shaders_from_strings(Program &program, const std::string &vtx_shader, === modified file 'src/scene.h' --- src/scene.h 2011-10-25 18:05:37 +0000 +++ src/scene.h 2011-11-08 13:57:38 +0000 @@ -109,8 +109,6 @@ protected: Scene(Canvas &pCanvas, const std::string &name); std::string construct_title(const std::string &title); - double pixel_value_distance(Canvas::Pixel p1, Canvas::Pixel p2, - bool use_alpha=false); Canvas &canvas_; std::string name_; @@ -240,6 +238,7 @@ public: SceneConditionals(Canvas &pCanvas); void setup(); + ValidationResult validate(); ~SceneConditionals(); }; @@ -249,6 +248,7 @@ public: SceneFunction(Canvas &pCanvas); void setup(); + ValidationResult validate(); ~SceneFunction(); }; @@ -258,6 +258,7 @@ public: SceneLoop(Canvas &pCanvas); void setup(); + ValidationResult validate(); ~SceneLoop(); };