From patchwork Thu Aug 16 17:25:14 2012 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: 10776 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 B47B623E29 for ; Thu, 16 Aug 2012 17:25:19 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 3B46FA18682 for ; Thu, 16 Aug 2012 17:25:19 +0000 (UTC) Received: by yhpp61 with SMTP id p61so3338902yhp.11 for ; Thu, 16 Aug 2012 10:25:18 -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=Er/dXtEWdQ2aXB6gGfHEV4EOKs1zUsOfhWqDDC2U7mc=; b=R+fL9O2pU+2HHLCqMiXc3mnOonmQGUTbF078FdxaWv3JSKUWBHrUtKPQrxo8f16XfH VSSgjOSaFlqq4nhCNzAwVrw8ZTT5klklnRHZqHRcehP1L68NaWHLGuqN/s+XnP8hEeGQ S+1J3Wfi3hp/E1GsgCak5KmXoh8jWkHcuBkfy0tXAp0Ruq1rmQOZtKjghZYLXdl4PEnZ 1zKWC+RkSxrdgOzsUqJ4wK9JkS7FqkkACxLG+Gd/Rnq4y/gBbkdsI4ip15rBehRnBVIM +ZAssDnlR/V3qYY5VRbjLGa4ezUVmkr5P9TsUn1IIIZvaedKCDYcE4yzGS+LHHySkTKJ WjFw== Received: by 10.50.6.229 with SMTP id e5mr2670614iga.9.1345137917982; Thu, 16 Aug 2012 10:25:17 -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.50.184.200 with SMTP id ew8csp139689igc; Thu, 16 Aug 2012 10:25:16 -0700 (PDT) Received: by 10.180.86.3 with SMTP id l3mr4856369wiz.16.1345137916144; Thu, 16 Aug 2012 10:25:16 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id p14si7002455wei.109.2012.08.16.10.25.15 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 16 Aug 2012 10:25:16 -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 1T23op-0001XK-1b for ; Thu, 16 Aug 2012 17:25:15 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id C6D62E01BB for ; Thu, 16 Aug 2012 17:25:14 +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: 246 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 246: Scene*: Add ::supported() and change ::setup() to return bool. Message-Id: <20120816172514.18745.18680.launchpad@ackee.canonical.com> Date: Thu, 16 Aug 2012 17:25:14 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15810"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: afa52cd4f407de8c3eb952d66f06f6d565f157e1 X-Gm-Message-State: ALoCoQkziJNXnXnaKmeTzw/JtBWqVmc+6YiksBuTzB1VQQt90LNfiMXk9Pxcd5pJujZD5f26P2V8 Merge authors: Alexandros Frantzis (afrantzis) ------------------------------------------------------------ revno: 246 [merge] committer: Alexandros Frantzis branch nick: trunk timestamp: Thu 2012-08-16 19:01:59 +0300 message: Scene*: Add ::supported() and change ::setup() to return bool. modified: src/scene-buffer.cpp src/scene-build.cpp src/scene-bump.cpp src/scene-conditionals.cpp src/scene-default-options.cpp src/scene-desktop.cpp src/scene-effect-2d.cpp src/scene-function.cpp src/scene-grid.cpp src/scene-ideas.cpp src/scene-jellyfish.cpp src/scene-jellyfish.h src/scene-loop.cpp src/scene-pulsar.cpp src/scene-shading.cpp src/scene-terrain.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/scene-buffer.cpp' --- src/scene-buffer.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-buffer.cpp 2012-08-15 09:45:06 +0000 @@ -327,6 +327,22 @@ } bool +SceneBuffer::supported(bool show_errors) +{ + if (options_["update-method"].value != "subdata" && + (GLExtensions::MapBuffer == 0 || GLExtensions::UnmapBuffer == 0)) + { + if (show_errors) { + Log::error("Requested MapBuffer VBO update method but GL_OES_mapbuffer" + " is not supported!\n"); + } + return false; + } + + return true; +} + +bool SceneBuffer::load() { running_ = false; @@ -339,14 +355,14 @@ { } -void +bool SceneBuffer::setup() { using LibMatrix::vec3; - Scene::setup(); + if (!Scene::setup()) + return false; - bool should_run = true; bool interleave = (options_["interleave"].value == "true"); Mesh::VBOUpdateMethod update_method; Mesh::VBOUsage usage; @@ -374,13 +390,6 @@ nlength = Util::fromString(options_["columns"].value); nwidth = Util::fromString(options_["rows"].value); - if (update_method == Mesh::VBOUpdateMethodMap && - (GLExtensions::MapBuffer == 0 || GLExtensions::UnmapBuffer == 0)) - { - Log::error("Requested MapBuffer VBO update method but GL_OES_mapbuffer" - " is not supported!\n"); - should_run = false; - } priv_->wave = new WaveMesh(5.0, 2.0, nlength, nwidth, update_fraction * (1.0 - update_dispersion + 0.0001), @@ -397,9 +406,11 @@ glDisable(GL_CULL_FACE); currentFrame_ = 0; - running_ = should_run; + running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } void === modified file 'src/scene-build.cpp' --- src/scene-build.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-build.cpp 2012-08-15 09:45:06 +0000 @@ -80,12 +80,13 @@ mesh_.reset(); } -void +bool SceneBuild::setup() { using LibMatrix::vec3; - Scene::setup(); + if (!Scene::setup()) + return false; /* Set up shaders */ static const std::string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/light-basic.vert"); @@ -102,7 +103,7 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } Model model; @@ -110,7 +111,7 @@ bool modelLoaded = model.load(whichModel); if(!modelLoaded) - return; + return false; // Now that we're successfully loaded, there are a few quirks about // some of the known models that we need to account for. The draw @@ -187,6 +188,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } void === modified file 'src/scene-bump.cpp' --- src/scene-bump.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-bump.cpp 2012-08-15 09:45:06 +0000 @@ -58,7 +58,7 @@ { } -void +bool SceneBump::setup_model_plain(const std::string &type) { static const std::string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/bump-poly.vert"); @@ -78,7 +78,7 @@ high_poly_filename : low_poly_filename; if(!model.load(poly_filename)) - return; + return false; model.calculate_normals(); @@ -100,16 +100,18 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } std::vector attrib_locations; attrib_locations.push_back(program_["position"].location()); attrib_locations.push_back(program_["normal"].location()); mesh_.set_attrib_locations(attrib_locations); + + return true; } -void +bool SceneBump::setup_model_normals() { static const std::string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/bump-normals.vert"); @@ -118,7 +120,7 @@ Model model; if(!model.load("asteroid-low")) - return; + return false; /* Calculate the half vector */ LibMatrix::vec3 halfVector(lightPosition.x(), lightPosition.y(), lightPosition.z()); @@ -147,7 +149,7 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } std::vector attrib_locations; @@ -155,11 +157,16 @@ attrib_locations.push_back(program_["texcoord"].location()); mesh_.set_attrib_locations(attrib_locations); - Texture::load("asteroid-normal-map", &texture_, - GL_NEAREST, GL_NEAREST, 0); + if (!Texture::load("asteroid-normal-map", &texture_, + GL_NEAREST, GL_NEAREST, 0)) + { + return false; + } + + return true; } -void +bool SceneBump::setup_model_normals_tangent() { static const std::string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/bump-normals-tangent.vert"); @@ -168,7 +175,7 @@ Model model; if(!model.load("asteroid-low")) - return; + return false; model.calculate_normals(); @@ -197,7 +204,7 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } std::vector attrib_locations; @@ -207,11 +214,16 @@ attrib_locations.push_back(program_["tangent"].location()); mesh_.set_attrib_locations(attrib_locations); - Texture::load("asteroid-normal-map-tangent", &texture_, - GL_NEAREST, GL_NEAREST, 0); + if (!Texture::load("asteroid-normal-map-tangent", &texture_, + GL_NEAREST, GL_NEAREST, 0)) + { + return false; + } + + return true; } -void +bool SceneBump::setup_model_height() { static const std::string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/bump-height.vert"); @@ -220,7 +232,7 @@ Model model; if(!model.load("asteroid-low")) - return; + return false; model.calculate_normals(); @@ -251,7 +263,7 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } std::vector attrib_locations; @@ -261,27 +273,38 @@ attrib_locations.push_back(program_["tangent"].location()); mesh_.set_attrib_locations(attrib_locations); - Texture::load("asteroid-height-map", &texture_, - GL_NEAREST, GL_NEAREST, 0); + if (!Texture::load("asteroid-height-map", &texture_, + GL_NEAREST, GL_NEAREST, 0)) + { + return false; + } + + return true; } -void +bool SceneBump::setup() { - Scene::setup(); + if (!Scene::setup()) + return false; const std::string &bump_render = options_["bump-render"].value; Texture::find_textures(); Model::find_models(); + + bool setup_succeeded = false; + if (bump_render == "normals") - setup_model_normals(); + setup_succeeded = setup_model_normals(); else if (bump_render == "normals-tangent") - setup_model_normals_tangent(); + setup_succeeded = setup_model_normals_tangent(); else if (bump_render == "height") - setup_model_height(); + setup_succeeded = setup_model_height(); else if (bump_render == "off" || bump_render == "high-poly") - setup_model_plain(bump_render); + setup_succeeded = setup_model_plain(bump_render); + if (!setup_succeeded) + return false; mesh_.build_vbo(); @@ -296,6 +319,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } void === modified file 'src/scene-conditionals.cpp' --- src/scene-conditionals.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-conditionals.cpp 2012-08-15 09:45:06 +0000 @@ -89,10 +89,11 @@ return source.str(); } -void +bool SceneConditionals::setup() { - SceneGrid::setup(); + if (!SceneGrid::setup()) + return false; /* Parse options */ bool vtx_conditionals = options_["vertex-conditionals"].value == "true"; @@ -104,7 +105,7 @@ std::string frg_shader(get_fragment_shader_source(frg_steps, frg_conditionals)); if (!Scene::load_shaders_from_strings(program_, vtx_shader, frg_shader)) - return; + return false; program_.start(); @@ -115,6 +116,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } Scene::ValidationResult === modified file 'src/scene-default-options.cpp' --- src/scene-default-options.cpp 2012-07-17 09:29:41 +0000 +++ src/scene-default-options.cpp 2012-08-15 09:45:06 +0000 @@ -23,7 +23,7 @@ #include "benchmark.h" #include "log.h" -void +bool SceneDefaultOptions::setup() { const std::map &scenes = Benchmark::scenes(); @@ -50,6 +50,8 @@ } } } + + return true; } bool === modified file 'src/scene-desktop.cpp' --- src/scene-desktop.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-desktop.cpp 2012-08-15 09:45:06 +0000 @@ -792,10 +792,11 @@ { } -void +bool SceneDesktop::setup() { - Scene::setup(); + if (!Scene::setup()) + return false; /* Parse the options */ unsigned int windows(0); @@ -868,6 +869,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } void === modified file 'src/scene-effect-2d.cpp' --- src/scene-effect-2d.cpp 2012-08-13 10:09:08 +0000 +++ src/scene-effect-2d.cpp 2012-08-15 09:45:06 +0000 @@ -295,10 +295,11 @@ glDeleteTextures(1, &texture_); } -void +bool SceneEffect2D::setup() { - Scene::setup(); + if (!Scene::setup()) + return false; Texture::find_textures(); @@ -312,7 +313,7 @@ if (!parse_matrix(options_["kernel"].value, kernel, kernel_width, kernel_height)) { - return; + return false; } /* Normalize the kernel matrix if needed */ @@ -330,12 +331,12 @@ kernel_height)); if (frg_source.str().empty()) - return; + return false; if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } std::vector vertex_format; @@ -358,6 +359,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } void === modified file 'src/scene-function.cpp' --- src/scene-function.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-function.cpp 2012-08-15 09:45:06 +0000 @@ -116,10 +116,11 @@ return source.str(); } -void +bool SceneFunction::setup() { - SceneGrid::setup(); + if (!SceneGrid::setup()) + return false; /* Parse options */ bool vtx_function = options_["vertex-function"].value == "true"; @@ -136,7 +137,7 @@ frg_complexity)); if (!Scene::load_shaders_from_strings(program_, vtx_shader, frg_shader)) - return; + return false; program_.start(); @@ -147,6 +148,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } Scene::ValidationResult === modified file 'src/scene-grid.cpp' --- src/scene-grid.cpp 2011-12-08 11:09:09 +0000 +++ src/scene-grid.cpp 2012-08-15 09:45:06 +0000 @@ -53,10 +53,11 @@ { } -void +bool SceneGrid::setup() { - Scene::setup(); + if (!Scene::setup()) + return false; int grid_size(Util::fromString(options_["grid-size"].value)); double grid_length(Util::fromString(options_["grid-length"].value)); @@ -78,6 +79,8 @@ currentFrame_ = 0; rotation_ = 0.0f; + + return true; } void === modified file 'src/scene-ideas.cpp' --- src/scene-ideas.cpp 2012-07-04 10:07:42 +0000 +++ src/scene-ideas.cpp 2012-08-15 09:45:06 +0000 @@ -58,6 +58,7 @@ void update_time(); void update_projection(const mat4& proj); void draw(); + bool valid() { return valid_; } private: void postIdle(); @@ -223,12 +224,17 @@ { } -void +bool SceneIdeas::setup() { - Scene::setup(); + if (!Scene::setup()) + return false; + priv_ = new SceneIdeasPrivate(); priv_->initialize(options_); + if (!priv_->valid()) + return false; + priv_->update_projection(canvas_.projection()); // Core Scene state @@ -236,6 +242,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } void === modified file 'src/scene-jellyfish.cpp' --- src/scene-jellyfish.cpp 2012-07-26 16:07:43 +0000 +++ src/scene-jellyfish.cpp 2012-08-16 15:55:56 +0000 @@ -54,20 +54,24 @@ { } -void +bool SceneJellyfish::setup() { - Scene::setup(); + if (!Scene::setup()) + return false; // Set up our private object that does all of the lifting priv_ = new JellyfishPrivate(); - priv_->initialize(); + if (!priv_->initialize()) + return false; // Set core scene timing after actual initialization so we don't measure // set up time. startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; running_ = true; + + return true; } void @@ -107,7 +111,7 @@ using std::string; using std::vector; -void +bool GradientRenderer::init() { // Program set up @@ -118,7 +122,7 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } positionLocation_ = program_["position"].location(); uvLocation_ = program_["uvIn"].location(); @@ -144,6 +148,8 @@ glBufferSubData(GL_ARRAY_BUFFER, uvOffset_, uvs_.size() * sizeof(vec2), &uvs_.front()); glBindBuffer(GL_ARRAY_BUFFER, 0); + + return true; } void @@ -355,10 +361,24 @@ blendFuncSrc_(0), blendFuncDst_(0) { +} + +JellyfishPrivate::~JellyfishPrivate() +{ + positions_.clear(); + normals_.clear(); + colors_.clear(); + texcoords_.clear(); + indices_.clear(); +} + +bool +JellyfishPrivate::initialize() +{ static const string modelFilename(GLMARK_DATA_PATH"/models/jellyfish.jobj"); if (!load_obj(modelFilename)) { - return; + return false; } // Now that we've setup the vertex data, we can setup the map of how @@ -376,26 +396,16 @@ dataMap_.texcoordOffset = dataMap_.colorOffset + dataMap_.colorSize; dataMap_.texcoordSize = texcoords_.size() * sv3; dataMap_.totalSize += dataMap_.texcoordSize; -} - -JellyfishPrivate::~JellyfishPrivate() -{ - positions_.clear(); - normals_.clear(); - colors_.clear(); - texcoords_.clear(); - indices_.clear(); -} - -void -JellyfishPrivate::initialize() -{ + lastUpdateTime_ = Util::get_timestamp_us() / 1000.0; currentTime_ = static_cast(lastUpdateTime_) % 100000000 / 1000.0; whichCaustic_ = static_cast(currentTime_ * 30) % 32 + 1; rotation_ = 0.0; - gradient_.init(); + if (!gradient_.init()) + { + return false; + } // Set up program first so we can store attribute and uniform locations // away for the @@ -409,7 +419,7 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } // Stash away attribute and uniform locations for handy use. @@ -452,6 +462,7 @@ if (!gotTex || textureObjects_[0] == 0) { Log::error("Jellyfish texture set up failed!!!\n"); + return false; } glBindTexture(GL_TEXTURE_2D, 0); // Then, the caustics textures @@ -467,6 +478,7 @@ if (!gotTex || textureObjects_[i] == 0) { Log::error("Caustics texture[%u] set up failed!!!\n", i); + return false; } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); @@ -484,6 +496,8 @@ glEnable(GL_BLEND); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); + + return true; } void === modified file 'src/scene-jellyfish.h' --- src/scene-jellyfish.h 2012-07-26 16:07:43 +0000 +++ src/scene-jellyfish.h 2012-08-16 15:55:56 +0000 @@ -48,7 +48,7 @@ vertices_.clear(); uvs_.clear(); } - void init(); + bool init(); void cleanup(); void draw(); }; @@ -114,7 +114,7 @@ public: JellyfishPrivate(); ~JellyfishPrivate(); - void initialize(); + bool initialize(); void update_viewport(const LibMatrix::vec2& viewport); void update_time(); void cleanup(); === modified file 'src/scene-loop.cpp' --- src/scene-loop.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-loop.cpp 2012-08-15 09:45:06 +0000 @@ -110,10 +110,11 @@ } -void +bool SceneLoop::setup() { - SceneGrid::setup(); + if (!SceneGrid::setup()) + return false; /* Parse options */ bool vtx_loop = options_["vertex-loop"].value == "true"; @@ -130,7 +131,7 @@ frg_uniform)); if (!Scene::load_shaders_from_strings(program_, vtx_shader, frg_shader)) - return; + return false; program_.start(); @@ -144,6 +145,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } Scene::ValidationResult === modified file 'src/scene-pulsar.cpp' --- src/scene-pulsar.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-pulsar.cpp 2012-08-15 09:45:06 +0000 @@ -73,10 +73,11 @@ { } -void +bool ScenePulsar::setup() { - Scene::setup(); + if (!Scene::setup()) + return false; // Disable back-face culling glDisable(GL_CULL_FACE); @@ -119,8 +120,8 @@ if (options_["texture"].value == "true") { frg_shader_filename = GLMARK_DATA_PATH"/shaders/light-basic-tex.frag"; Texture::find_textures(); - Texture::load("crate-base", &texture_, - GL_NEAREST, GL_NEAREST, 0); + if (!Texture::load("crate-base", &texture_, GL_NEAREST, GL_NEAREST, 0)) + return false; } else { frg_shader_filename = GLMARK_DATA_PATH"/shaders/light-basic.frag"; @@ -136,7 +137,7 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } create_and_setup_mesh(); @@ -148,6 +149,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } void === modified file 'src/scene-shading.cpp' --- src/scene-shading.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-shading.cpp 2012-08-15 09:45:06 +0000 @@ -132,10 +132,11 @@ return source.str(); } -void +bool SceneShading::setup() { - Scene::setup(); + if (!Scene::setup()) + return false; static const LibMatrix::vec4 lightPosition(20.0f, 20.0f, 10.0f, 1.0f); static const LibMatrix::vec4 materialDiffuse(0.0f, 0.0f, 1.0f, 1.0f); @@ -181,7 +182,7 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } Model model; @@ -189,7 +190,7 @@ bool modelLoaded = model.load(whichModel); if(!modelLoaded) - return; + return false; // Now that we're successfully loaded, there are a few quirks about // some of the known models that we need to account for. The draw @@ -257,6 +258,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } void === modified file 'src/scene-terrain.cpp' --- src/scene-terrain.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-terrain.cpp 2012-08-15 09:45:06 +0000 @@ -231,6 +231,21 @@ } bool +SceneTerrain::supported(bool show_errors) +{ + GLint vertex_textures; + glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &vertex_textures); + + if (show_errors && vertex_textures <= 0) { + Log::error("SceneTerrain requires Vertex Texture Fetch support, " + "but GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS is %d\n", + vertex_textures); + } + + return vertex_textures > 0; +} + +bool SceneTerrain::load() { Scene::load(); @@ -246,23 +261,11 @@ Scene::unload(); } -void +bool SceneTerrain::setup() { - Scene::setup(); - - /* Ensure implementation supports vertex texture fetch */ - GLint vertex_textures; - glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &vertex_textures); - if (vertex_textures <= 0) { - Log::error("SceneTerrain requires Vertex Texture Fetch support, " - "but GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS is %d\n", - vertex_textures); - currentFrame_ = 0; - startTime_ = Util::get_timestamp_us() / 1000000.0; - running_ = false; - return; - } + if (!Scene::setup()) + return false; /* Parse options */ float repeat = Util::fromString(options_["repeat-overlay"].value); @@ -313,6 +316,8 @@ currentFrame_ = 0; startTime_ = Util::get_timestamp_us() / 1000000.0; running_ = true; + + return true; } void === modified file 'src/scene-texture.cpp' --- src/scene-texture.cpp 2012-07-16 14:25:30 +0000 +++ src/scene-texture.cpp 2012-08-15 09:45:06 +0000 @@ -103,10 +103,11 @@ mesh_.reset(); } -void +bool SceneTexture::setup() { - Scene::setup(); + if (!Scene::setup()) + return false; static const std::string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/light-basic.vert"); static const std::string vtx_shader_texgen_filename(GLMARK_DATA_PATH"/shaders/light-basic-texgen.vert"); @@ -138,8 +139,8 @@ } const string& whichTexture(options_["texture"].value); - Texture::load(whichTexture, &texture_, - min_filter, mag_filter, 0); + if (!Texture::load(whichTexture, &texture_, min_filter, mag_filter, 0)) + return false; // Load shaders bool doTexGen(options_["texgen"].value == "true"); @@ -168,14 +169,14 @@ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { - return; + return false; } Model model; const string& whichModel(options_["model"].value); bool modelLoaded = model.load(whichModel); if(!modelLoaded) - return; + return false; // Now that we're successfully loaded, there are a few quirks about // some of the known models that we need to account for. The draw @@ -251,6 +252,8 @@ running_ = true; startTime_ = Util::get_timestamp_us() / 1000000.0; lastUpdateTime_ = startTime_; + + return true; } void === modified file 'src/scene.cpp' --- src/scene.cpp 2012-08-13 10:09:08 +0000 +++ src/scene.cpp 2012-08-15 09:45:06 +0000 @@ -76,6 +76,13 @@ } bool +Scene::supported(bool show_errors) +{ + static_cast(show_errors); + return true; +} + +bool Scene::load() { return true; @@ -86,7 +93,7 @@ { } -void +bool Scene::setup() { duration_ = Util::fromString(options_["duration"].value); @@ -101,6 +108,12 @@ ShaderSource::ShaderTypeFragment ); + currentFrame_ = 0; + running_ = false; + startTime_ = Util::get_timestamp_us() / 1000000.0; + lastUpdateTime_ = startTime_; + + return supported(true); } void === modified file 'src/scene.h' --- src/scene.h 2012-07-16 14:00:56 +0000 +++ src/scene.h 2012-08-15 09:45:06 +0000 @@ -74,6 +74,15 @@ }; /** + * Checks whether this scene (in its current configuration) is supported. + * + * @param show_errors whether to log errors about unsupported features + * + * @return whether the scene is supported + */ + virtual bool supported(bool show_errors); + + /** * Performs option-independent resource loading and configuration. * * It should be safe to call ::load() (and the corresponding ::unload()) @@ -95,9 +104,12 @@ * This method also prepares a scene for a benchmark run. * It should be called just before running a scene/benchmark. * - * @return the operation status + * The base Scene::setup() method also checks whether a scene + * configuration is supported by calling ::supported(true). + * + * @return whether setting the scene up succeeded */ - virtual void setup(); + virtual bool setup(); /** * Performs option-dependent resource unloading. @@ -232,7 +244,7 @@ public: SceneDefaultOptions(Canvas &pCanvas) : Scene(pCanvas, "") {} bool set_option(const std::string &opt, const std::string &val); - void setup(); + bool setup(); private: std::list > defaultOptions_; @@ -244,7 +256,7 @@ SceneBuild(Canvas &pCanvas); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -272,7 +284,7 @@ SceneTexture(Canvas &pCanvas); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -300,7 +312,7 @@ SceneShading(Canvas &pCanvas); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -327,7 +339,7 @@ SceneGrid(Canvas &pCanvas, const std::string &name); virtual bool load(); virtual void unload(); - virtual void setup(); + virtual bool setup(); virtual void teardown(); virtual void update(); virtual void draw(); @@ -346,7 +358,7 @@ { public: SceneConditionals(Canvas &pCanvas); - void setup(); + bool setup(); ValidationResult validate(); ~SceneConditionals(); @@ -356,7 +368,7 @@ { public: SceneFunction(Canvas &pCanvas); - void setup(); + bool setup(); ValidationResult validate(); ~SceneFunction(); @@ -366,7 +378,7 @@ { public: SceneLoop(Canvas &pCanvas); - void setup(); + bool setup(); ValidationResult validate(); ~SceneLoop(); @@ -378,7 +390,7 @@ SceneBump(Canvas &pCanvas); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -393,10 +405,10 @@ float rotation_; float rotationSpeed_; private: - void setup_model_plain(const std::string &type); - void setup_model_normals(); - void setup_model_normals_tangent(); - void setup_model_height(); + bool setup_model_plain(const std::string &type); + bool setup_model_normals(); + bool setup_model_normals_tangent(); + bool setup_model_height(); }; class SceneEffect2D : public Scene @@ -405,7 +417,7 @@ SceneEffect2D(Canvas &pCanvas); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -426,7 +438,7 @@ ScenePulsar(Canvas &pCanvas); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -455,7 +467,7 @@ SceneDesktop(Canvas &canvas); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -473,9 +485,10 @@ { public: SceneBuffer(Canvas &canvas); + bool supported(bool show_errors); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -495,7 +508,7 @@ SceneIdeas(Canvas &pCanvas); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -513,9 +526,10 @@ { public: SceneTerrain(Canvas &pCanvas); + bool supported(bool show_errors); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw(); @@ -536,7 +550,7 @@ ~SceneJellyfish(); bool load(); void unload(); - void setup(); + bool setup(); void teardown(); void update(); void draw();