From 4f63ef635d88b6066a2c77558e5bc309553f3d99 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 19 Nov 2020 23:27:46 +0200 Subject: [PATCH 1/3] panda: Remove PyEval_InitThreads calls when compiling against Python 3.9+ Cherry-pick from #1053 --- panda/src/event/pythonTask.cxx | 6 +++--- panda/src/pipeline/pythonThread.cxx | 6 +++--- panda/src/putil/pythonCallbackObject.cxx | 9 +++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index 6264345348..e6183c56dd 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -72,12 +72,12 @@ PythonTask(PyObject *func_or_coro, const std::string &name) : __dict__ = PyDict_New(); -#ifndef SIMPLE_THREADS +#if !defined(SIMPLE_THREADS) && defined(WITH_THREAD) && PY_VERSION_HEX < 0x03090000 // Ensure that the Python threading system is initialized and ready to go. -#ifdef WITH_THREAD // This symbol defined within Python.h + // WITH_THREAD symbol defined within Python.h + // PyEval_InitThreads is now a deprecated no-op in Python 3.9+ PyEval_InitThreads(); #endif -#endif } /** diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index 13b31e0539..066553eaea 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -38,12 +38,12 @@ PythonThread(PyObject *function, PyObject *args, set_args(args); -#ifndef SIMPLE_THREADS +#if !defined(SIMPLE_THREADS) && defined(WITH_THREAD) && PY_VERSION_HEX < 0x03090000 // Ensure that the Python threading system is initialized and ready to go. -#ifdef WITH_THREAD // This symbol defined within Python.h + // WITH_THREAD symbol defined within Python.h + // PyEval_InitThreads is now a deprecated no-op in Python 3.9+ PyEval_InitThreads(); #endif -#endif } /** diff --git a/panda/src/putil/pythonCallbackObject.cxx b/panda/src/putil/pythonCallbackObject.cxx index e8ef005c2e..3e185e8514 100644 --- a/panda/src/putil/pythonCallbackObject.cxx +++ b/panda/src/putil/pythonCallbackObject.cxx @@ -41,17 +41,18 @@ PythonCallbackObject(PyObject *function) { set_function(function); -#ifndef SIMPLE_THREADS +#if !defined(SIMPLE_THREADS) && defined(WITH_THREAD) // Ensure that the Python threading system is initialized and ready to go. -#ifdef WITH_THREAD // This symbol defined within Python.h #if PY_VERSION_HEX >= 0x03020000 Py_Initialize(); #endif +#if PY_VERSION_HEX < 0x03090000 + // PyEval_InitThreads is now a deprecated no-op in Python 3.9+ PyEval_InitThreads(); -#endif -#endif +#endif // PY_VERSION_HEX +#endif // WITH_THREAD } /** From 761c54f63dff387b8eed60565146198d9d568d92 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 12 Dec 2020 13:54:14 +0100 Subject: [PATCH 2/3] pgui: Workaround for DirectEntry flickering issues w/ pipelining See #1070. This is a temporary solution (one which isn't complete- it doesn't properly handle state changes). --- panda/src/pgui/pgEntry.I | 46 ++++++++++++++++++++++++++++++--- panda/src/pgui/pgEntry.cxx | 53 +++++++++++++++++++++++++++++++++----- panda/src/pgui/pgEntry.h | 1 + 3 files changed, 91 insertions(+), 9 deletions(-) diff --git a/panda/src/pgui/pgEntry.I b/panda/src/pgui/pgEntry.I index 7f76e3ef63..e398b42b54 100644 --- a/panda/src/pgui/pgEntry.I +++ b/panda/src/pgui/pgEntry.I @@ -113,6 +113,12 @@ set_cursor_position(int position) { _cursor_position = position; _cursor_stale = true; _blink_start = ClockObject::get_global_clock()->get_frame_time(); + +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + update_cursor(); + } +#endif } } @@ -185,6 +191,13 @@ set_max_width(PN_stdfloat max_width) { LightReMutexHolder holder(_lock); _max_width = max_width; _text_geom_stale = true; + +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + update_text(); + update_cursor(); + } +#endif } /** @@ -206,9 +219,17 @@ INLINE void PGEntry:: set_num_lines(int num_lines) { LightReMutexHolder holder(_lock); nassertv(num_lines >= 1); - _num_lines = num_lines; - _text_geom_stale = true; - update_text(); + if (_num_lines != num_lines) { + _num_lines = num_lines; + _text_geom_stale = true; + update_text(); + +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + update_cursor(); + } +#endif + } } /** @@ -300,6 +321,13 @@ set_obscure_mode(bool flag) { if (_obscure_mode != flag) { _obscure_mode = flag; _text_geom_stale = true; + +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + update_text(); + update_cursor(); + } +#endif } } @@ -325,6 +353,13 @@ set_overflow_mode(bool flag) { _overflow_mode = flag; _text_geom_stale = true; _cursor_stale = true; + +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + update_text(); + update_cursor(); + } +#endif } } @@ -518,6 +553,11 @@ set_wtext(const std::wstring &wtext) { ret = _obscure_text.set_wtext(std::wstring(_text.get_num_characters(), '*')); } _text_geom_stale = true; +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + update_text(); + } +#endif set_cursor_position(std::min(_cursor_position, _text.get_num_characters())); return ret; } diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index 97d200f8e1..633f999769 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -176,8 +176,10 @@ bool PGEntry:: cull_callback(CullTraverser *trav, CullTraverserData &data) { LightReMutexHolder holder(_lock); PGItem::cull_callback(trav, data); - update_text(); - update_cursor(); + if (Thread::get_current_pipeline_stage() == 0) { + update_text(); + update_cursor(); + } // Now render the text. CullTraverserData next_data(data, _text_render_root.node()); @@ -260,7 +262,7 @@ press(const MouseWatcherParameter ¶m, bool background) { } _cursor_stale = true; if (overflow_mode){ - _text_geom_stale = true; + _text_geom_stale = true; } } @@ -276,7 +278,7 @@ press(const MouseWatcherParameter ¶m, bool background) { } _cursor_stale = true; if (overflow_mode){ - _text_geom_stale = true; + _text_geom_stale = true; } } @@ -286,7 +288,7 @@ press(const MouseWatcherParameter ¶m, bool background) { _cursor_position = 0; _cursor_stale = true; if (overflow_mode){ - _text_geom_stale = true; + _text_geom_stale = true; } type(param); } @@ -297,7 +299,7 @@ press(const MouseWatcherParameter ¶m, bool background) { _cursor_position = _text.get_num_characters(); _cursor_stale = true; if (overflow_mode){ - _text_geom_stale = true; + _text_geom_stale = true; } type(param); } @@ -306,6 +308,17 @@ press(const MouseWatcherParameter ¶m, bool background) { } } PGItem::press(param, background); + +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + if (_text_geom_stale) { + update_text(); + } + if (_cursor_stale) { + update_cursor(); + } + } +#endif } /** @@ -411,6 +424,17 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { } } PGItem::keystroke(param, background); + +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + if (_text_geom_stale) { + update_text(); + } + if (_cursor_stale) { + update_cursor(); + } + } +#endif } /** @@ -434,6 +458,17 @@ candidate(const MouseWatcherParameter ¶m, bool background) { } } PGItem::candidate(param, background); + +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + if (_text_geom_stale) { + update_text(); + } + if (_cursor_stale) { + update_cursor(); + } + } +#endif } /** @@ -924,4 +959,10 @@ update_state() { } else { set_state(S_inactive); } +#ifdef THREADED_PIPELINE + if (Pipeline::get_render_pipeline()->get_num_stages() > 1) { + update_text(); + update_cursor(); + } +#endif } diff --git a/panda/src/pgui/pgEntry.h b/panda/src/pgui/pgEntry.h index 825562aa82..45548c8b12 100644 --- a/panda/src/pgui/pgEntry.h +++ b/panda/src/pgui/pgEntry.h @@ -23,6 +23,7 @@ #include "pvector.h" #include "clockObject.h" #include "textAssembler.h" +#include "pipeline.h" /** * This is a particular kind of PGItem that handles simple one-line or short From 130c70a9f5caabf4669531771f509f94de29a2ab Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 12 Dec 2020 13:58:43 +0100 Subject: [PATCH 3/3] Update BACKERS.md [skip ci] --- BACKERS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BACKERS.md b/BACKERS.md index 4b5b5a5bb6..82715b9749 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -22,6 +22,7 @@ This is a list of all the people who are contributing financially to Panda3D. I * Sam Edwards * Max Voss +* Hawkheart ## Enthusiasts