From ed353d83f84bf85db926bca708a62f7d0dcd2e0e Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 14 Jul 2007 05:48:47 +0000 Subject: [PATCH] add sync-flip --- panda/src/display/config_display.cxx | 8 ++++++++ panda/src/display/config_display.h | 1 + panda/src/display/graphicsEngine.cxx | 24 +++++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 7b659efa17..d61bb71e28 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -80,6 +80,14 @@ ConfigVariableBool auto_flip "time, while setting it false can get a better frame rate as more " "is achieved in parallel with the graphics card.")); +ConfigVariableBool sync_flip +("sync-flip", false, + PRC_DESC("Set this true to attempt to flip all windows at the same time, " + "or false to flip each window as late as possible. Setting this " + "false can improve parallelization. This is a temporary " + "variable; it will later be replaced with a more explicit control " + "over synchronizing window flip.")); + ConfigVariableBool yield_timeslice ("yield-timeslice", false, PRC_DESC("Set this true to yield the timeslice at the end of the frame to be " diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index 2774c6c6c7..9b4ac05484 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -43,6 +43,7 @@ extern EXPCL_PANDA ConfigVariableBool pstats_unused_states; extern EXPCL_PANDA ConfigVariableString threading_model; extern EXPCL_PANDA ConfigVariableBool allow_nonpipeline_threads; extern EXPCL_PANDA ConfigVariableBool auto_flip; +extern EXPCL_PANDA ConfigVariableBool sync_flip; extern EXPCL_PANDA ConfigVariableBool yield_timeslice; extern EXPCL_PANDA ConfigVariableString screenshot_filename; diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index a92531067d..1f5df13e03 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -614,7 +614,7 @@ render_frame() { do_resort_windows(); } - if (_flip_state != FS_flip) { + if (sync_flip && _flip_state != FS_flip) { do_flip_frame(current_thread); } @@ -1037,6 +1037,17 @@ cull_and_draw_together(const GraphicsEngine::Windows &wlist, for (wi = wlist.begin(); wi != wlist.end(); ++wi) { GraphicsOutput *win = (*wi); if (win->is_active() && win->get_gsg()->is_active()) { + if (win->flip_ready()) { + { + PStatTimer timer(GraphicsEngine::_flip_begin_pcollector, current_thread); + win->begin_flip(); + } + { + PStatTimer timer(GraphicsEngine::_flip_end_pcollector, current_thread); + win->end_flip(); + } + } + if (win->begin_frame(GraphicsOutput::FM_render, current_thread)) { win->clear(current_thread); @@ -1233,6 +1244,17 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { for (wi = wlist.begin(); wi != wlist.end(); ++wi) { GraphicsOutput *win = (*wi); if (win->is_active() && win->get_gsg()->is_active()) { + if (win->flip_ready()) { + { + PStatTimer timer(GraphicsEngine::_flip_begin_pcollector, current_thread); + win->begin_flip(); + } + { + PStatTimer timer(GraphicsEngine::_flip_end_pcollector, current_thread); + win->end_flip(); + } + } + PStatTimer timer(win->get_draw_window_pcollector(), current_thread); if (win->begin_frame(GraphicsOutput::FM_render, current_thread)) { win->clear(current_thread);