Quellcode durchsuchen

x11display: fix crash with multithreading and NVIDIA driver

rdb vor 7 Jahren
Ursprung
Commit
544ef137ee

+ 17 - 0
panda/src/x11display/x11GraphicsWindow.cxx

@@ -218,6 +218,23 @@ move_pointer(int device, int x, int y) {
   }
 }
 
+/**
+ * Clears the entire framebuffer before rendering, according to the settings
+ * of get_color_clear_active() and get_depth_clear_active() (inherited from
+ * DrawableRegion).
+ *
+ * This function is called only within the draw thread.
+ */
+void x11GraphicsWindow::
+clear(Thread *current_thread) {
+  if (is_any_clear_active()) {
+    // Evidently the NVIDIA driver may call glXCreateNewContext inside
+    // prepare_display_region, so we need to hold the X11 lock.
+    LightReMutexHolder holder(x11GraphicsPipe::_x_mutex);
+    GraphicsOutput::clear(current_thread);
+  }
+}
+
 /**
  * This function will be called within the draw thread before beginning
  * rendering for a given frame.  It should do whatever setup is required, and

+ 2 - 0
panda/src/x11display/x11GraphicsWindow.h

@@ -36,6 +36,8 @@ public:
 
   virtual MouseData get_pointer(int device) const;
   virtual bool move_pointer(int device, int x, int y);
+
+  virtual void clear(Thread *current_thread);
   virtual bool begin_frame(FrameMode mode, Thread *current_thread);
   virtual void end_frame(FrameMode mode, Thread *current_thread);