gallium/api: add state invalidate interface as alternative to cso_save/restore

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 <eric@anholt.net>
Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8180>
This commit is contained in:
Marek Olšák
2020-12-20 02:45:20 -05:00
parent 7afa7cb4b4
commit a93ca3be01
2 changed files with 33 additions and 0 deletions
+15
View File
@@ -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);
};
+18
View File
@@ -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;