From fd8dd360b2c8600a29c7146c28befe7856288193 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 9 Jul 2016 09:59:51 +0200 Subject: [PATCH 1/5] Fix compile error statically linking build with DX9 --- panda/src/framework/pandaFramework.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 2f886bae29..ba5e023d40 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -96,7 +96,7 @@ open_framework(int &argc, char **&argv) { extern EXPCL_PANDAGL void init_libpandagl(); init_libpandagl(); #elif defined(HAVE_DX9) - extern EXPCL_PANDADX9 void init_libpandadx9(); + extern EXPCL_PANDADX void init_libpandadx9(); init_libpandadx9(); #elif defined(HAVE_TINYDISPLAY) extern EXPCL_TINYDISPLAY void init_libtinydisplay(); From 47d1b4e220e4e3e78748dafe12830a936b055139 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 9 Jul 2016 10:02:55 +0200 Subject: [PATCH 2/5] PythonTask: don't crash if repr(owner) errors, deal better with bad owners --- panda/src/event/pythonTask.cxx | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index 88070bdb28..3408f98e2c 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -214,6 +214,19 @@ get_upon_death() { //////////////////////////////////////////////////////////////////// void PythonTask:: set_owner(PyObject *owner) { +#ifndef NDEBUG + if (owner != Py_None) { + PyObject *add = PyObject_GetAttrString(owner, "_addTask"); + PyObject *clear = PyObject_GetAttrString(owner, "_clearTask"); + + if (add == NULL || !PyCallable_Check(add) || + clear == NULL || !PyCallable_Check(clear)) { + Dtool_Raise_TypeError("owner object should have _addTask and _clearTask methods"); + return; + } + } +#endif + if (_owner != NULL && _owner != Py_None && _state != S_inactive) { unregister_from_owner(); } @@ -546,10 +559,16 @@ do_python_task() { ostringstream strm; #if PY_MAJOR_VERSION >= 3 PyObject *str = PyObject_ASCII(result); + if (str == NULL) { + str = PyUnicode_FromString(""); + } strm << *this << " returned " << PyUnicode_AsUTF8(str); #else PyObject *str = PyObject_Repr(result); + if (str == NULL) { + str = PyString_FromString(""); + } strm << *this << " returned " << PyString_AsString(str); #endif @@ -672,18 +691,9 @@ call_owner_method(const char *method_name) { if (_owner != Py_None) { PyObject *func = PyObject_GetAttrString(_owner, (char *)method_name); if (func == (PyObject *)NULL) { -#if PY_MAJOR_VERSION >= 3 - PyObject *str = PyObject_ASCII(_owner); task_cat.error() - << "Owner object " << PyUnicode_AsUTF8(str) << " added to " - << *this << " has no method " << method_name << "().\n"; -#else - PyObject *str = PyObject_Repr(_owner); - task_cat.error() - << "Owner object " << PyString_AsString(str) << " added to " - << *this << " has no method " << method_name << "().\n"; -#endif - Py_DECREF(str); + << "Owner object added to " << *this << " has no method " + << method_name << "().\n"; } else { call_function(func); From 11861cb73d7d52a9e831a1654d8769c89ac85e9f Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 9 Jul 2016 14:27:33 +0200 Subject: [PATCH 3/5] Backport shadow-depth-bits config var to 1.9 --- doc/ReleaseNotes | 1 + panda/src/display/config_display.cxx | 6 ++++++ panda/src/display/config_display.h | 1 + panda/src/display/graphicsStateGuardian.cxx | 14 +++++++++----- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 3a02861ab3..19191e3e06 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -17,6 +17,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Improve performance of texture load and store operations * 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 ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 0d219273e5..255a2cd482 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -445,6 +445,12 @@ ConfigVariableDouble pixel_zoom ("pixel-zoom", 1.0, PRC_DESC("The default pixel_zoom factor for new windows.")); +ConfigVariableInt shadow_depth_bits +("shadow-depth-bits", 1, + PRC_DESC("The minimum number of depth buffer bits requested when rendering " + "shadow maps. Set this to 32 for more depth resolution in shadow " + "maps.")); + ConfigVariableColor background_color ("background-color", "0.41 0.41 0.41 0.0", PRC_DESC("Specifies the rgb(a) value of the default background color for a " diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index be71d0b63d..23afbf578f 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -102,6 +102,7 @@ extern EXPCL_PANDA_DISPLAY ConfigVariableInt stencil_bits; extern EXPCL_PANDA_DISPLAY ConfigVariableInt accum_bits; extern EXPCL_PANDA_DISPLAY ConfigVariableInt multisamples; extern EXPCL_PANDA_DISPLAY ConfigVariableInt back_buffers; +extern EXPCL_PANDA_DISPLAY ConfigVariableInt shadow_depth_bits; extern EXPCL_PANDA_DISPLAY ConfigVariableDouble pixel_zoom; diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 5faf282e53..22a2caf498 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -3176,13 +3176,17 @@ make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host) { nassertr(light->_sbuffers.count(this) == 0, NULL); - display_cat.debug() << "Constructing shadow buffer for light '" << light->get_name() - << "', size=" << light->_sb_xsize << "x" << light->_sb_ysize - << ", sort=" << light->_sb_sort << "\n"; + if (display_cat.is_debug()) { + display_cat.debug() + << "Constructing shadow buffer for light '" << light->get_name() + << "', size=" << light->_sb_xsize << "x" << light->_sb_ysize + << ", sort=" << light->_sb_sort << "\n"; + } - // Setup some flags and properties + // Determine the properties for creating the depth buffer. FrameBufferProperties fbp; - fbp.set_depth_bits(1); // We only need depth + fbp.set_depth_bits(shadow_depth_bits); + WindowProperties props = WindowProperties::size(light->_sb_xsize, light->_sb_ysize); int flags = GraphicsPipe::BF_refuse_window; if (is_point) { From 44d59edc30168fb663b3f20b3fc28701ebe7f326 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 9 Jul 2016 14:42:25 +0200 Subject: [PATCH 4/5] 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. From 9c8c5434789e21e08dc8917ce3b4e54146a15296 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 9 Jul 2016 14:47:09 +0200 Subject: [PATCH 5/5] Clarify release notes a bit --- doc/ReleaseNotes | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 242ce2db87..26ab1d8813 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -18,7 +18,9 @@ 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 +* Fix cull issue when rendering cube map (or any multi-lens setup) +* Fix crash rendering with the same camera to different contexts +* Fix compile error when making static build with DX9 renderer ------------------------ RELEASE 1.9.2 ------------------------