From 44d59edc30168fb663b3f20b3fc28701ebe7f326 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 9 Jul 2016 14:42:25 +0200 Subject: [PATCH] Fix cube map render and rendering the same camera with two GSGs The problem was that the cull result was being reused across different lens indices and GSGs --- doc/ReleaseNotes | 1 + panda/src/display/graphicsEngine.cxx | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 19191e3e06..242ce2db87 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -18,6 +18,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix crashes with pbuffers on Intel cards on Windows * Support for Autodesk Maya 2016.5 * Add shadow-depth-bits config var to control shadow map depth +* No longer reuses cull result for different GSG or lens index ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index da90172088..2fcc98b47a 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -120,6 +120,23 @@ PStatCollector GraphicsEngine::_occlusion_passed_pcollector("Occlusion results:V PStatCollector GraphicsEngine::_occlusion_failed_pcollector("Occlusion results:Occluded"); PStatCollector GraphicsEngine::_occlusion_tests_pcollector("Occlusion tests"); +// This is used to keep track of which scenes we have already culled. +struct CullKey { + GraphicsStateGuardian *_gsg; + NodePath _camera; + int _lens_index; +}; + +INLINE static bool operator < (const CullKey &a, const CullKey &b) { + if (a._gsg != b._gsg) { + return a._gsg < b._gsg; + } + if (a._camera != b._camera) { + return a._camera < b._camera; + } + return a._lens_index < b._lens_index; +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsEngine::Constructor // Access: Published @@ -1487,7 +1504,7 @@ cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { // Keep track of the cameras we have already used in this thread to // render DisplayRegions. - typedef pmap AlreadyCulled; + typedef pmap AlreadyCulled; AlreadyCulled already_culled; size_t wlist_size = wlist.size(); @@ -1501,8 +1518,13 @@ cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { if (dr != (DisplayRegion *)NULL) { DisplayRegionPipelineReader *dr_reader = new DisplayRegionPipelineReader(dr, current_thread); - NodePath camera = dr_reader->get_camera(); - AlreadyCulled::iterator aci = already_culled.insert(AlreadyCulled::value_type(camera, (DisplayRegion *)NULL)).first; + + CullKey key; + key._gsg = win->get_gsg(); + key._camera = dr_reader->get_camera(); + key._lens_index = dr_reader->get_lens_index(); + + AlreadyCulled::iterator aci = already_culled.insert(AlreadyCulled::value_type(key, (DisplayRegion *)NULL)).first; if ((*aci).second == NULL) { // We have not used this camera already in this thread. // Perform the cull operation.