[Mesa-dev] [PATCH 03/25] mesa: Add SetBackgroundContext to dd_function_table

Timothy Arceri tarceri at itsqueeze.com
Tue Mar 7 06:21:15 UTC 2017


From: Paul Berry <stereotype441 at gmail.com>

---
 src/mesa/drivers/common/driverfuncs.c |  3 +++
 src/mesa/main/dd.h                    | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 6069138..642cd91 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -194,20 +194,23 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->LightingSpaceChange = NULL;
 
    /* GL_ARB_texture_storage */
    driver->AllocTextureStorage = _mesa_AllocTextureStorage_sw;
 
    /* GL_ARB_texture_view */
    driver->TextureView = NULL;
 
    /* GL_ARB_texture_multisample */
    driver->GetSamplePosition = NULL;
+
+   /* Multithreading */
+   driver->SetBackgroundContext = NULL;
 }
 
 
 /**
  * Call the ctx->Driver.* state functions with current values to initialize
  * driver state.
  * Only the Intel drivers use this so far.
  */
 void
 _mesa_init_driver_state(struct gl_context *ctx)
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 63fc621..f300ad6 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1018,20 +1018,38 @@ struct dd_function_table {
                                     const GLuint *num_groups,
                                     const GLuint *group_size);
    /*@}*/
 
    /**
     * Query information about memory. Device memory is e.g. VRAM. Staging
     * memory is e.g. GART. All sizes are in kilobytes.
     */
    void (*QueryMemoryInfo)(struct gl_context *ctx,
                            struct gl_memory_info *info);
+
+   /**
+    * Indicate that this thread is being used by Mesa as a background drawing
+    * thread for the given GL context.
+    *
+    * If this function is called more than once from any given thread, each
+    * subsequent call overrides the context that was passed in the previous
+    * call.  Mesa takes advantage of this to re-use a background thread to
+    * perform drawing on behalf of multiple contexts.
+    *
+    * Mesa may sometimes call this function from a non-background thread
+    * (i.e. a thread that has already been bound to a context using
+    * __DriverAPIRec::MakeCurrent()); when this happens, ctx will be equal to
+    * the context that is bound to this thread.
+    *
+    * Mesa will only call this function if GL multithreading is enabled.
+    */
+   void (*SetBackgroundContext)(struct gl_context *ctx);
 };
 
 
 /**
  * Per-vertex functions.
  *
  * These are the functions which can appear between glBegin and glEnd.
  * Depending on whether we're inside or outside a glBegin/End pair
  * and whether we're in immediate mode or building a display list, these
  * functions behave differently.  This structure allows us to switch
-- 
2.9.3



More information about the mesa-dev mailing list