From b6cdb15d1486798ca709e406d2f044c277514ee2 Mon Sep 17 00:00:00 2001 From: Andre Schollmeyer Date: Thu, 5 Jun 2014 10:30:30 +0200 Subject: [PATCH 1/3] bugfix for trimeshubershader instantiation --- include/gua/renderer/GBufferPass.hpp | 2 +- include/gua/renderer/Pipeline.hpp | 2 +- src/gua/renderer/GBufferPass.cpp | 54 ++++++++++++---------------- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/include/gua/renderer/GBufferPass.hpp b/include/gua/renderer/GBufferPass.hpp index 57d83cc95..636029dda 100644 --- a/include/gua/renderer/GBufferPass.hpp +++ b/include/gua/renderer/GBufferPass.hpp @@ -102,7 +102,7 @@ class GBufferPass : public GeometryPass { void initialize_state_objects(RenderContext const& ctx); - void initialize_trimesh_ubershader() const; + void initialize_trimesh_ubershader(RenderContext const& ctx) const; private: // attributes diff --git a/include/gua/renderer/Pipeline.hpp b/include/gua/renderer/Pipeline.hpp index aa0b8569f..f1e1718f6 100644 --- a/include/gua/renderer/Pipeline.hpp +++ b/include/gua/renderer/Pipeline.hpp @@ -180,9 +180,9 @@ class GUA_DLL Pipeline { return prerender_pipelines_; } - inline float get_application_fps() const { return application_fps_; } inline float get_rendering_fps() const { return rendering_fps_; } + inline RenderContext const& get_context() const { return *context_; }; SerializedScene const& get_current_scene(CameraMode mode) const; diff --git a/src/gua/renderer/GBufferPass.cpp b/src/gua/renderer/GBufferPass.cpp index 4ddac58a5..2c42bc7d7 100644 --- a/src/gua/renderer/GBufferPass.cpp +++ b/src/gua/renderer/GBufferPass.cpp @@ -30,13 +30,14 @@ #include #include -#include #include +#include #include #include #include #include +#include #include #include @@ -54,7 +55,7 @@ GBufferPass::GBufferPass(Pipeline* pipeline) bbox_rasterizer_state_(), depth_stencil_state_() { - initialize_trimesh_ubershader(); + initialize_trimesh_ubershader(pipeline->get_context()); } //////////////////////////////////////////////////////////////////////////////// @@ -280,14 +281,9 @@ void GBufferPass::rendering(SerializedScene const& scene, void GBufferPass::display_bboxes(RenderContext const& ctx, SerializedScene const& scene, std::size_t viewid) { - if (!ubershaders_.count(typeid(TriMeshRessource))) { - auto ubershader = TriMeshRessource().create_ubershader(); - ubershader->cleanup(ctx); - ubershader->create(cached_materials_); - ubershaders_[typeid(TriMeshRessource)] = ubershader; - } - auto meshubershader = ubershaders_[typeid(TriMeshRessource)]; + + auto meshubershader = ubershaders_[typeid(TriMeshNode)]; if (pipeline_->config.enable_bbox_display()) { meshubershader->get_program()->use(ctx); @@ -323,14 +319,7 @@ void GBufferPass::display_rays(RenderContext const& ctx, SerializedScene const& scene, std::size_t viewid) { - if (!ubershaders_.count(typeid(TriMeshRessource))) { - auto ubershader = TriMeshRessource().create_ubershader(); - ubershader->cleanup(ctx); - ubershader->create(cached_materials_); - ubershaders_[typeid(TriMeshRessource)] = ubershader; - } - - auto meshubershader = ubershaders_[typeid(TriMeshRessource)]; + auto meshubershader = ubershaders_[typeid(TriMeshNode)]; if (pipeline_->config.enable_ray_display()) { meshubershader->get_program()->use(ctx); @@ -358,15 +347,7 @@ void GBufferPass::display_quads(RenderContext const& ctx, CameraMode eye, std::size_t viewid) { - - if (!ubershaders_.count(typeid(TriMeshRessource))) { - auto ubershader = TriMeshRessource().create_ubershader(); - ubershader->cleanup(ctx); - ubershader->create(cached_materials_); - ubershaders_[typeid(TriMeshRessource)] = ubershader; - } - - auto meshubershader = ubershaders_[typeid(TriMeshRessource)]; + auto meshubershader = ubershaders_[typeid(TriMeshNode)]; if (!scene.textured_quads_.empty()) { meshubershader->get_program()->use(ctx); @@ -492,16 +473,27 @@ void GBufferPass::apply_material_mapping( //////////////////////////////////////////////////////////////////////////////// LayerMapping const* GBufferPass::get_gbuffer_mapping() const { - return ubershaders_[typeid(TriMeshRessource)]->get_gbuffer_mapping(); + std::type_index trimesh_type = typeid(TriMeshNode); + + if (!ubershaders_.count(trimesh_type)) { + // trimesh shader has not been created yet -> return dummy mapping + return TriMeshRessource().create_ubershader()->get_gbuffer_mapping(); + } else { + return ubershaders_[trimesh_type]->get_gbuffer_mapping(); + } } //////////////////////////////////////////////////////////////////////////////// -void GBufferPass::initialize_trimesh_ubershader() const +void GBufferPass::initialize_trimesh_ubershader(RenderContext const& ctx) const { - if (!ubershaders_.count(typeid(TriMeshRessource))) - { - ubershaders_[typeid(TriMeshRessource)] = TriMeshRessource().create_ubershader(); + std::type_index trimesh_type = typeid(TriMeshNode); + + if (!ubershaders_.count(trimesh_type)) { + auto ubershader = TriMeshRessource().create_ubershader(); + ubershader->cleanup(ctx); + ubershader->create(cached_materials_); + ubershaders_[trimesh_type] = ubershader; } } From e7dd92078f6b823640dc4f7003847020688d51cc Mon Sep 17 00:00:00 2001 From: Andreas-Christoph Bernstein Date: Thu, 5 Jun 2014 13:23:16 +0200 Subject: [PATCH 2/3] Ignore files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c31256571..0ea6b0997 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ tags .vim.custom tests/tests plugins/guacamole-oculus/example-oculus/example-oculus +examples/multicontext/multicontext From 384ee91def6b9d7d32c9771735d817877e28e26e Mon Sep 17 00:00:00 2001 From: Andreas-Christoph Bernstein Date: Thu, 5 Jun 2014 13:24:19 +0200 Subject: [PATCH 3/3] Bump version. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdf1e2053..c0f4426b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ PROJECT(GUACAMOLE CXX) # version number set(GUACAMOLE_MAJOR 0) set(GUACAMOLE_MINOR 8) -set(GUACAMOLE_PATCH 3) +set(GUACAMOLE_PATCH 4) set(GUACAMOLE_VERSION ${GUACAMOLE_MAJOR}.${GUACAMOLE_MINOR}.${GUACAMOLE_PATCH}) set(GUACAMOLE_DESCRIPTION "GUACAMOLE - an astonishing virtual reality engine") set(GUACAMOLE_HOMEPAGE "http://www.GUACAMOLE.org")