Module: Mesa Branch: main Commit: e20718e8fa69bace9d5acf0ea484df6ca9421b98 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e20718e8fa69bace9d5acf0ea484df6ca9421b98
Author: Vlad Zahorodnii <[email protected]> Date: Thu May 19 21:42:57 2022 +0300 radeonsi: Add support for EGL_IMG_context_priority This allows creating high priority contexts when using radeonsi. It's primarily intended for apps whose rendering commands must be processed as soon as possible, e.g. wayland compositors. Signed-off-by: Vlad Zahorodnii <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16594> --- src/gallium/drivers/radeonsi/si_get.c | 7 +++++++ src/gallium/drivers/radeonsi/si_pipe.c | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c index 05023665383..84d6e67bdbf 100644 --- a/src/gallium/drivers/radeonsi/si_get.c +++ b/src/gallium/drivers/radeonsi/si_get.c @@ -254,6 +254,13 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF: return 0; + case PIPE_CAP_CONTEXT_PRIORITY_MASK: + if (!(sscreen->info.is_amdgpu && sscreen->info.drm_minor >= 22)) + return 0; + return PIPE_CONTEXT_PRIORITY_LOW | + PIPE_CONTEXT_PRIORITY_MEDIUM | + PIPE_CONTEXT_PRIORITY_HIGH; + case PIPE_CAP_FENCE_SIGNAL: return sscreen->info.has_syncobj; diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 70b49394a66..161f1a73320 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -501,10 +501,25 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign } } - priority = RADEON_CTX_PRIORITY_MEDIUM; + if (flags & PIPE_CONTEXT_HIGH_PRIORITY) { + priority = RADEON_CTX_PRIORITY_HIGH; + } else if (flags & PIPE_CONTEXT_LOW_PRIORITY) { + priority = RADEON_CTX_PRIORITY_LOW; + } else { + priority = RADEON_CTX_PRIORITY_MEDIUM; + } /* Initialize the context handle and the command stream. */ sctx->ctx = sctx->ws->ctx_create(sctx->ws, priority); + if (!sctx->ctx && priority != RADEON_CTX_PRIORITY_MEDIUM) { + /* Context priority should be treated as a hint. If context creation + * fails with the requested priority, for example because the caller + * lacks CAP_SYS_NICE capability or other system resource constraints, + * fallback to normal priority. + */ + priority = RADEON_CTX_PRIORITY_MEDIUM; + sctx->ctx = sctx->ws->ctx_create(sctx->ws, priority); + } if (!sctx->ctx) { fprintf(stderr, "radeonsi: can't create radeon_winsys_ctx\n"); goto fail;
