[Mesa-dev] [PATCH 1/6] gallium: plumb context priority through to driver
Marek Olšák
maraeo at gmail.com
Wed Oct 4 19:53:51 UTC 2017
What others said, and yes radeonsi shouldn't expose the extension.
Other than those:
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Wed, Oct 4, 2017 at 5:44 PM, Rob Clark <robdclark at gmail.com> wrote:
> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
> src/gallium/drivers/etnaviv/etnaviv_screen.c | 1 +
> src/gallium/drivers/freedreno/freedreno_screen.c | 1 +
> src/gallium/drivers/i915/i915_screen.c | 1 +
> src/gallium/drivers/llvmpipe/lp_screen.c | 1 +
> src/gallium/drivers/nouveau/nv30/nv30_screen.c | 1 +
> src/gallium/drivers/nouveau/nv50/nv50_screen.c | 1 +
> src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 +
> src/gallium/drivers/r300/r300_screen.c | 1 +
> src/gallium/drivers/r600/r600_pipe.c | 1 +
> src/gallium/drivers/radeonsi/si_pipe.c | 1 +
> src/gallium/drivers/softpipe/sp_screen.c | 1 +
> src/gallium/drivers/svga/svga_screen.c | 1 +
> src/gallium/drivers/swr/swr_screen.cpp | 1 +
> src/gallium/drivers/vc4/vc4_screen.c | 1 +
> src/gallium/drivers/virgl/virgl_screen.c | 1 +
> src/gallium/include/pipe/p_defines.h | 21 +++++++++++++++++++++
> src/gallium/include/state_tracker/st_api.h | 2 ++
> src/gallium/state_trackers/dri/dri_context.c | 11 +++++++++++
> src/gallium/state_trackers/dri/dri_query_renderer.c | 8 +++++++-
> src/mesa/state_tracker/st_manager.c | 5 +++++
> 20 files changed, 61 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index 42905ab0620..16bd4b7c0fb 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -264,6 +264,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> /* Stream output. */
> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
> index 040c2c99ec0..96866d656be 100644
> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
> @@ -325,6 +325,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> case PIPE_CAP_MAX_VIEWPORTS:
> diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
> index 8411c0f15cc..7bcf479c4be 100644
> --- a/src/gallium/drivers/i915/i915_screen.c
> +++ b/src/gallium/drivers/i915/i915_screen.c
> @@ -317,6 +317,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> case PIPE_CAP_MAX_VIEWPORTS:
> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
> index 53171162a54..19411adaf07 100644
> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
> @@ -360,6 +360,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
> case PIPE_CAP_NIR_SAMPLERS_AS_DEREF:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
> }
> /* should only get here on unhandled cases */
> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> index a66b4fbe67b..782ba0a64db 100644
> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> @@ -224,6 +224,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> case PIPE_CAP_VENDOR_ID:
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> index 479283e1b7c..997cb4e71dc 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> @@ -276,6 +276,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> case PIPE_CAP_VENDOR_ID:
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> index ac850c493da..05913bccb65 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> @@ -305,6 +305,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> case PIPE_CAP_VENDOR_ID:
> diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
> index 0c3e097535d..021f1df2db4 100644
> --- a/src/gallium/drivers/r300/r300_screen.c
> +++ b/src/gallium/drivers/r300/r300_screen.c
> @@ -246,6 +246,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> /* SWTCL-only features. */
> diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
> index 655b5411ed5..98c0b10c4d0 100644
> --- a/src/gallium/drivers/r600/r600_pipe.c
> +++ b/src/gallium/drivers/r600/r600_pipe.c
> @@ -402,6 +402,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> case PIPE_CAP_DOUBLES:
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
> index 33f5adbd3ad..2881bd8f9fb 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.c
> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
> @@ -488,6 +488,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 1;
>
> case PIPE_CAP_INT64:
> diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
> index 7e9d9e6592f..d68bb238053 100644
> --- a/src/gallium/drivers/softpipe/sp_screen.c
> +++ b/src/gallium/drivers/softpipe/sp_screen.c
> @@ -311,6 +311,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
> case PIPE_CAP_NIR_SAMPLERS_AS_DEREF:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
> case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
> return 4;
> diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
> index 08cc50f6664..7e11ec78350 100644
> --- a/src/gallium/drivers/svga/svga_screen.c
> +++ b/src/gallium/drivers/svga/svga_screen.c
> @@ -456,6 +456,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
> }
>
> diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp
> index ee7782d648d..5e36a432bc1 100644
> --- a/src/gallium/drivers/swr/swr_screen.cpp
> +++ b/src/gallium/drivers/swr/swr_screen.cpp
> @@ -346,6 +346,7 @@ swr_get_param(struct pipe_screen *screen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> case PIPE_CAP_VENDOR_ID:
> diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
> index 5743e13045f..d69db6e6343 100644
> --- a/src/gallium/drivers/vc4/vc4_screen.c
> +++ b/src/gallium/drivers/vc4/vc4_screen.c
> @@ -265,6 +265,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
>
> /* Stream output. */
> diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
> index 935ce2f9b0a..f186b8c6136 100644
> --- a/src/gallium/drivers/virgl/virgl_screen.c
> +++ b/src/gallium/drivers/virgl/virgl_screen.c
> @@ -269,6 +269,7 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> + case PIPE_CAP_CONTEXT_PRIORITY_MASK:
> return 0;
> case PIPE_CAP_VENDOR_ID:
> return 0x1af4;
> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
> index 155d0e3979c..c525c335bb4 100644
> --- a/src/gallium/include/pipe/p_defines.h
> +++ b/src/gallium/include/pipe/p_defines.h
> @@ -387,6 +387,15 @@ enum pipe_flush_flags
> */
> #define PIPE_CONTEXT_PREFER_THREADED (1 << 3)
>
> +/**
> + * Create a high priority context.
> + */
> +#define PIPE_CONTEXT_HIGH_PRIORITY (1 << 4)
> +
> +/**
> + * Create a low priority context.
> + */
> +#define PIPE_CONTEXT_LOW_PRIORITY (1 << 5)
>
> /**
> * Flags for pipe_context::memory_barrier.
> @@ -777,8 +786,20 @@ enum pipe_cap
> PIPE_CAP_QUERY_SO_OVERFLOW,
> PIPE_CAP_MEMOBJ,
> PIPE_CAP_LOAD_CONSTBUF,
> + PIPE_CAP_CONTEXT_PRIORITY_MASK,
> };
>
> +/**
> + * Possible bits for PIPE_CAP_CONTEXT_PRIORITY_MASK param, which should
> + * return a bitmask of the supported priorities. If the driver does not
> + * support prioritized contexts, it can return 0.
> + *
> + * Note that these match __DRI2_RENDER_HAS_CONTEXT_PRIORITY_*
> + */
> +#define PIPE_CONTEXT_PRIORITY_LOW (1 << 0)
> +#define PIPE_CONTEXT_PRIORITY_MEDIUM (1 << 1)
> +#define PIPE_CONTEXT_PRIORITY_HIGH (1 << 2)
> +
> #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
> #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600 (1 << 1)
>
> diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
> index 2eaf891ab7a..03e8f1a7393 100644
> --- a/src/gallium/include/state_tracker/st_api.h
> +++ b/src/gallium/include/state_tracker/st_api.h
> @@ -91,6 +91,8 @@ enum st_api_feature
> #define ST_CONTEXT_FLAG_ROBUST_ACCESS (1 << 2)
> #define ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED (1 << 3)
> #define ST_CONTEXT_FLAG_NO_ERROR (1 << 4)
> +#define ST_CONTEXT_FLAG_HIGH_PRIORITY (1 << 5)
> +#define ST_CONTEXT_FLAG_LOW_PRIORITY (1 << 6)
>
> /**
> * Reasons that context creation might fail.
> diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c
> index 8776aacc093..85007c34d25 100644
> --- a/src/gallium/state_trackers/dri/dri_context.c
> +++ b/src/gallium/state_trackers/dri/dri_context.c
> @@ -112,6 +112,17 @@ dri_create_context(gl_api api, const struct gl_config * visual,
> if (flags & __DRI_CTX_FLAG_NO_ERROR)
> attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR;
>
> + switch (priority) {
> + case __DRI_CTX_PRIORITY_LOW:
> + attribs.flags |= ST_CONTEXT_FLAG_LOW_PRIORITY;
> + break;
> + case __DRI_CTX_PRIORITY_HIGH:
> + attribs.flags |= ST_CONTEXT_FLAG_HIGH_PRIORITY;
> + break;
> + default:
> + break;
> + }
> +
> if (sharedContextPrivate) {
> st_share = ((struct dri_context *)sharedContextPrivate)->st;
> }
> diff --git a/src/gallium/state_trackers/dri/dri_query_renderer.c b/src/gallium/state_trackers/dri/dri_query_renderer.c
> index ea31b6c1e10..80847e3d314 100644
> --- a/src/gallium/state_trackers/dri/dri_query_renderer.c
> +++ b/src/gallium/state_trackers/dri/dri_query_renderer.c
> @@ -55,7 +55,13 @@ dri2_query_renderer_integer(__DRIscreen *_screen, int param,
> PIPE_TEXTURE_2D, 0,
> PIPE_BIND_RENDER_TARGET);
> return 0;
> -
> + case __DRI2_RENDERER_HAS_CONTEXT_PRIORITY:
> + value[0] =
> + screen->base.screen->get_param(screen->base.screen,
> + PIPE_CAP_CONTEXT_PRIORITY_MASK);
> + if (!value[0])
> + return -1;
> + return 0;
> default:
> return driQueryRendererIntegerCommon(_screen, param, value);
> }
> diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
> index 6c7d836827b..4ed37fb7d14 100644
> --- a/src/mesa/state_tracker/st_manager.c
> +++ b/src/mesa/state_tracker/st_manager.c
> @@ -842,6 +842,11 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
> if (attribs->flags & ST_CONTEXT_FLAG_NO_ERROR)
> no_error = true;
>
> + if (attribs->flags & ST_CONTEXT_FLAG_LOW_PRIORITY)
> + ctx_flags |= PIPE_CONTEXT_LOW_PRIORITY;
> + else if (attribs->flags & ST_CONTEXT_FLAG_HIGH_PRIORITY)
> + ctx_flags |= PIPE_CONTEXT_HIGH_PRIORITY;
> +
> pipe = smapi->screen->context_create(smapi->screen, NULL, ctx_flags);
> if (!pipe) {
> *error = ST_CONTEXT_ERROR_NO_MEMORY;
> --
> 2.13.5
>
More information about the mesa-dev
mailing list