From a93ca3be01e51df30c0e7ec58927053e7057afd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 20 Dec 2020 02:45:20 -0500 Subject: [PATCH] gallium/api: add state invalidate interface as alternative to cso_save/restore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some cso_context save/restore capabilities will be removed to decrease CPU overhead. This is the alternative solution that e.g. the HUD will use. Reviewed-by: Eric Anholt Reviewed-by: Zoltán Böszörményi Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/include/frontend/api.h | 15 +++++++++++++++ src/mesa/state_tracker/st_manager.c | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index b0cafc7073c..70afed3499a 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -146,6 +146,15 @@ enum st_attachment_type { #define ST_FLUSH_WAIT (1 << 2) #define ST_FLUSH_FENCE_FD (1 << 3) +/** + * State invalidation flags to notify frontends that states have been changed + * behind their back. + */ +#define ST_INVALIDATE_FS_SAMPLER_VIEWS (1 << 0) +#define ST_INVALIDATE_FS_CONSTBUF0 (1 << 1) +#define ST_INVALIDATE_VS_CONSTBUF0 (1 << 2) +#define ST_INVALIDATE_VERTEX_BUFFERS (1 << 3) + /** * Value to st_manager->get_param function. */ @@ -430,6 +439,12 @@ struct st_context_iface * Called from the main thread. */ void (*thread_finish)(struct st_context_iface *stctxi); + + /** + * Invalidate states to notify the frontend that states have been changed + * behind its back. + */ + void (*invalidate_state)(struct st_context_iface *stctxi, unsigned flags); }; diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index ea3d5207ffd..42c3947b7af 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -833,6 +833,23 @@ st_thread_finish(struct st_context_iface *stctxi) } +static void +st_context_invalidate_state(struct st_context_iface *stctxi, + unsigned flags) +{ + struct st_context *st = (struct st_context *) stctxi; + + if (flags & ST_INVALIDATE_FS_SAMPLER_VIEWS) + st->dirty |= ST_NEW_FS_SAMPLER_VIEWS; + if (flags & ST_INVALIDATE_FS_CONSTBUF0) + st->dirty |= ST_NEW_FS_CONSTANTS; + if (flags & ST_INVALIDATE_VS_CONSTBUF0) + st->dirty |= ST_NEW_VS_CONSTANTS; + if (flags & ST_INVALIDATE_VERTEX_BUFFERS) + st->dirty |= ST_NEW_VERTEX_ARRAYS; +} + + static void st_manager_destroy(struct st_manager *smapi) { @@ -985,6 +1002,7 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi, st->iface.share = st_context_share; st->iface.start_thread = st_start_thread; st->iface.thread_finish = st_thread_finish; + st->iface.invalidate_state = st_context_invalidate_state; st->iface.st_context_private = (void *) smapi; st->iface.cso_context = st->cso_context; st->iface.pipe = st->pipe;