Browse Source

add sync-flip

David Rose 18 years ago
parent
commit
ed353d83f8

+ 8 - 0
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 "
           "time, while setting it false can get a better frame rate as more "
           "is achieved in parallel with the graphics card."));
           "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
 ConfigVariableBool yield_timeslice
 ("yield-timeslice", false,
 ("yield-timeslice", false,
  PRC_DESC("Set this true to yield the timeslice at the end of the frame to be "
  PRC_DESC("Set this true to yield the timeslice at the end of the frame to be "

+ 1 - 0
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 ConfigVariableString threading_model;
 extern EXPCL_PANDA ConfigVariableBool allow_nonpipeline_threads;
 extern EXPCL_PANDA ConfigVariableBool allow_nonpipeline_threads;
 extern EXPCL_PANDA ConfigVariableBool auto_flip;
 extern EXPCL_PANDA ConfigVariableBool auto_flip;
+extern EXPCL_PANDA ConfigVariableBool sync_flip;
 extern EXPCL_PANDA ConfigVariableBool yield_timeslice;
 extern EXPCL_PANDA ConfigVariableBool yield_timeslice;
 
 
 extern EXPCL_PANDA ConfigVariableString screenshot_filename;
 extern EXPCL_PANDA ConfigVariableString screenshot_filename;

+ 23 - 1
panda/src/display/graphicsEngine.cxx

@@ -614,7 +614,7 @@ render_frame() {
     do_resort_windows();
     do_resort_windows();
   }
   }
 
 
-  if (_flip_state != FS_flip) {
+  if (sync_flip && _flip_state != FS_flip) {
     do_flip_frame(current_thread);
     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) {
   for (wi = wlist.begin(); wi != wlist.end(); ++wi) {
     GraphicsOutput *win = (*wi);
     GraphicsOutput *win = (*wi);
     if (win->is_active() && win->get_gsg()->is_active()) {
     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)) {
       if (win->begin_frame(GraphicsOutput::FM_render, current_thread)) {
         win->clear(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) {
   for (wi = wlist.begin(); wi != wlist.end(); ++wi) {
     GraphicsOutput *win = (*wi);
     GraphicsOutput *win = (*wi);
     if (win->is_active() && win->get_gsg()->is_active()) {
     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);
       PStatTimer timer(win->get_draw_window_pcollector(), current_thread);
       if (win->begin_frame(GraphicsOutput::FM_render, current_thread)) {
       if (win->begin_frame(GraphicsOutput::FM_render, current_thread)) {
         win->clear(current_thread);
         win->clear(current_thread);