From 9fdb0ce755d5f84df09b729fa8da2518ea2f31d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 27 Nov 2022 15:00:57 -0500 Subject: [PATCH] gallium: use PIPE_CONTEXT_* flags instead of ST_CONTEXT_FLAG_* where PIPE_CONTEXT_* flags are available Reviewed-by: Emma Anholt Reviewed-by: Adam Jackson Reviewed-by: Yonggang Luo Part-of: --- src/gallium/frontends/dri/dri_context.c | 10 +++++----- src/gallium/frontends/glx/xlib/xm_api.c | 2 +- src/gallium/frontends/wgl/stw_context.c | 4 ++-- src/gallium/include/frontend/api.h | 13 ++++++------- src/mesa/state_tracker/st_manager.c | 25 +++++++------------------ 5 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/gallium/frontends/dri/dri_context.c b/src/gallium/frontends/dri/dri_context.c index 248b02b6dda..a9d9a552f5d 100644 --- a/src/gallium/frontends/dri/dri_context.c +++ b/src/gallium/frontends/dri/dri_context.c @@ -113,11 +113,11 @@ dri_create_context(struct dri_screen *screen, attribs.flags |= ST_CONTEXT_FLAG_DEBUG; if (ctx_config->flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS) - attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS; + attribs.context_flags |= PIPE_CONTEXT_ROBUST_BUFFER_ACCESS; if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY) if (ctx_config->reset_strategy != __DRI_CTX_RESET_NO_NOTIFICATION) - attribs.flags |= ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED; + attribs.context_flags |= PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET; if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_NO_ERROR) attribs.flags |= ctx_config->no_error ? ST_CONTEXT_FLAG_NO_ERROR : 0; @@ -125,10 +125,10 @@ dri_create_context(struct dri_screen *screen, if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_PRIORITY) { switch (ctx_config->priority) { case __DRI_CTX_PRIORITY_LOW: - attribs.flags |= ST_CONTEXT_FLAG_LOW_PRIORITY; + attribs.context_flags |= PIPE_CONTEXT_LOW_PRIORITY; break; case __DRI_CTX_PRIORITY_HIGH: - attribs.flags |= ST_CONTEXT_FLAG_HIGH_PRIORITY; + attribs.context_flags |= PIPE_CONTEXT_HIGH_PRIORITY; break; default: break; @@ -140,7 +140,7 @@ dri_create_context(struct dri_screen *screen, attribs.flags |= ST_CONTEXT_FLAG_RELEASE_NONE; if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_PROTECTED) - attribs.flags |= ST_CONTEXT_FLAG_PROTECTED; + attribs.context_flags |= PIPE_CONTEXT_PROTECTED; struct dri_context *share_ctx = NULL; if (sharedContextPrivate) { diff --git a/src/gallium/frontends/glx/xlib/xm_api.c b/src/gallium/frontends/glx/xlib/xm_api.c index 89f9b8cb121..4b1187c55c1 100644 --- a/src/gallium/frontends/glx/xlib/xm_api.c +++ b/src/gallium/frontends/glx/xlib/xm_api.c @@ -959,7 +959,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list, if (contextFlags & GLX_CONTEXT_DEBUG_BIT_ARB) attribs.flags |= ST_CONTEXT_FLAG_DEBUG; if (contextFlags & GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB) - attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS; + attribs.context_flags |= PIPE_CONTEXT_ROBUST_BUFFER_ACCESS; switch (profileMask) { case GLX_CONTEXT_CORE_PROFILE_BIT_ARB: diff --git a/src/gallium/frontends/wgl/stw_context.c b/src/gallium/frontends/wgl/stw_context.c index 74dd3a579ea..c93aa3f6b2f 100644 --- a/src/gallium/frontends/wgl/stw_context.c +++ b/src/gallium/frontends/wgl/stw_context.c @@ -193,9 +193,9 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context *shareCt if (contextFlags & WGL_CONTEXT_DEBUG_BIT_ARB) attribs.flags |= ST_CONTEXT_FLAG_DEBUG; if (contextFlags & WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB) - attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS; + attribs.context_flags |= PIPE_CONTEXT_ROBUST_BUFFER_ACCESS; if (resetStrategy != WGL_NO_RESET_NOTIFICATION_ARB) - attribs.flags |= ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED; + attribs.context_flags |= PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET; switch (profileMask) { case WGL_CONTEXT_CORE_PROFILE_BIT_ARB: diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index eda81a576e7..4de23b3e2fd 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -68,13 +68,9 @@ enum st_profile_type */ #define ST_CONTEXT_FLAG_DEBUG (1 << 0) #define ST_CONTEXT_FLAG_FORWARD_COMPATIBLE (1 << 1) -#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_RELEASE_NONE (1 << 5) -#define ST_CONTEXT_FLAG_HIGH_PRIORITY (1 << 6) -#define ST_CONTEXT_FLAG_LOW_PRIORITY (1 << 7) -#define ST_CONTEXT_FLAG_PROTECTED (1 << 8) +#define ST_CONTEXT_FLAG_NO_ERROR (1 << 2) +#define ST_CONTEXT_FLAG_RELEASE_NONE (1 << 3) + /** * Reasons that context creation might fail. @@ -252,6 +248,9 @@ struct st_context_attribs /** Mask of ST_CONTEXT_FLAG_x bits */ unsigned flags; + /** Mask of PIPE_CONTEXT_x bits */ + unsigned context_flags; + /** * The visual of the framebuffers the context will be bound to. */ diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 28b370cedc6..ac581ef0507 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -945,7 +945,6 @@ st_api_create_context(struct pipe_frontend_screen *fscreen, struct gl_config mode, *mode_ptr = &mode; gl_api api; bool no_error = false; - unsigned ctx_flags = PIPE_CONTEXT_PREFER_THREADED; if (!(ST_PROFILE_ALL_MASK & (1 << attribs->profile))) return NULL; @@ -985,24 +984,12 @@ st_api_create_context(struct pipe_frontend_screen *fscreen, fscreen->destroy = st_manager_destroy; } - if (attribs->flags & ST_CONTEXT_FLAG_ROBUST_ACCESS) - ctx_flags |= PIPE_CONTEXT_ROBUST_BUFFER_ACCESS; - 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; - - if (attribs->flags & ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED) - ctx_flags |= PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET; - - if (attribs->flags & ST_CONTEXT_FLAG_PROTECTED) - ctx_flags |= PIPE_CONTEXT_PROTECTED; - - pipe = fscreen->screen->context_create(fscreen->screen, NULL, ctx_flags); + pipe = fscreen->screen->context_create(fscreen->screen, NULL, + PIPE_CONTEXT_PREFER_THREADED | + attribs->context_flags); if (!pipe) { *error = ST_CONTEXT_ERROR_NO_MEMORY; return NULL; @@ -1035,11 +1022,13 @@ st_api_create_context(struct pipe_frontend_screen *fscreen, if (attribs->flags & ST_CONTEXT_FLAG_FORWARD_COMPATIBLE) st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; - if (attribs->flags & ST_CONTEXT_FLAG_ROBUST_ACCESS) { + + if (attribs->context_flags & PIPE_CONTEXT_ROBUST_BUFFER_ACCESS) { st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB; st->ctx->Const.RobustAccess = GL_TRUE; } - if (attribs->flags & ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED) { + + if (attribs->context_flags & PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET) { st->ctx->Const.ResetStrategy = GL_LOSE_CONTEXT_ON_RESET_ARB; st_install_device_reset_callback(st); }