[Mesa-dev] [PATCH 26/26] gallium: implement the backend of threaded GL dispatch

Matt Turner mattst88 at gmail.com
Thu Feb 9 17:48:00 UTC 2017


On Wed, Feb 8, 2017 at 6:03 PM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>  src/gallium/include/state_tracker/st_api.h      | 19 +++++++++++++++++++
>  src/gallium/state_trackers/dri/dri_context.c    | 10 ++++++++++
>  src/gallium/state_trackers/dri/dri_drawable.c   |  6 ++++++
>  src/gallium/state_trackers/dri/dri_screen.c     | 21 +++++++++++++++++++++
>  src/mesa/drivers/dri/common/xmlpool/t_options.h |  4 ++++
>  src/mesa/state_tracker/st_context.c             | 13 +++++++++++++
>  src/mesa/state_tracker/st_manager.c             | 19 +++++++++++++++++++
>  7 files changed, 92 insertions(+)
>
> diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
> index a2e37d2..19c38af 100644
> --- a/src/gallium/include/state_tracker/st_api.h
> +++ b/src/gallium/include/state_tracker/st_api.h
> @@ -407,20 +407,33 @@ struct st_context_iface
>     boolean (*share)(struct st_context_iface *stctxi,
>                      struct st_context_iface *stsrci);
>
>     /**
>      * Look up and return the info of a resource for EGLImage.
>      *
>      * This function is optional.
>      */
>     boolean (*get_resource_for_egl_image)(struct st_context_iface *stctxi,
>                                           struct st_context_resource *stres);
> +
> +   /**
> +    * Start the thread if the API has a worker thread.
> +    * Called after the context has been created and fully initialized on both
> +    * sides (e.g. st/mesa and st/dri).
> +    */
> +   void (*start_thread)(struct st_context_iface *stctxi);
> +
> +   /**
> +    * If the API is multithreaded, wait for all queued commands to complete.
> +    * Called from the main thread.
> +    */
> +   void (*thread_finish)(struct st_context_iface *stctxi);
>  };
>
>
>  /**
>   * Represent a state tracker manager.
>   *
>   * This interface is implemented by the state tracker manager.  It corresponds
>   * to a "display" in the window system.
>   */
>  struct st_manager
> @@ -444,20 +457,26 @@ struct st_manager
>      */
>     boolean (*get_egl_image)(struct st_manager *smapi,
>                              void *egl_image,
>                              struct st_egl_image *out);
>
>     /**
>      * Query an manager param.
>      */
>     int (*get_param)(struct st_manager *smapi,
>                      enum st_manager_param param);
> +
> +   /**
> +    * Call the loader function setBackgroundContext. Called from the worker
> +    * thread.
> +    */
> +   void (*set_background_context)(struct st_context_iface *stctxi);
>  };
>
>  /**
>   * Represent a rendering API such as OpenGL or OpenVG.
>   *
>   * Implemented by the state tracker and used by the state tracker manager.
>   */
>  struct st_api
>  {
>     /**
> diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c
> index 3d8af65..91d2d1f 100644
> --- a/src/gallium/state_trackers/dri/dri_context.c
> +++ b/src/gallium/state_trackers/dri/dri_context.c
> @@ -149,20 +149,27 @@ dri_create_context(gl_api api, const struct gl_config * visual,
>        goto fail;
>     }
>     ctx->st->st_manager_private = (void *) ctx;
>     ctx->stapi = stapi;
>
>     if (ctx->st->cso_context) {
>        ctx->pp = pp_init(ctx->st->pipe, screen->pp_enabled, ctx->st->cso_context);
>        ctx->hud = hud_create(ctx->st->pipe, ctx->st->cso_context);
>     }
>
> +   /* Do this last. */
> +   if (ctx->st->start_thread &&
> +       /* the driver loader must implement this */
> +       screen->sPriv->dri2.backgroundCallable &&
> +       driQueryOptionb(&screen->optionCache, "mesa_glthread"))

The original i965 patch uses an environment variable named "glthread".
We should definitely be consistent, but I'm not sure if "glthread" is
too generic of a name.


More information about the mesa-dev mailing list