st/mesa: move st_update_functions into st_context

st_update_array will be set differently based on driver CAPs.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27198>
This commit is contained in:
Marek Olšák
2022-12-24 12:51:16 -05:00
committed by Marge Bot
parent 5fd80f4fae
commit 50c3e9f87b
3 changed files with 19 additions and 25 deletions

View File

@@ -72,22 +72,6 @@
DEBUG_GET_ONCE_BOOL_OPTION(mesa_mvp_dp4, "MESA_MVP_DP4", false)
/* The list of state update functions. */
st_update_func_t st_update_functions[ST_NUM_ATOMS];
static void
init_atoms_once(void)
{
STATIC_ASSERT(ARRAY_SIZE(st_update_functions) <= 64);
#define ST_STATE(FLAG, st_update) st_update_functions[FLAG##_INDEX] = st_update;
#include "st_atom_list.h"
#undef ST_STATE
if (util_get_cpu_caps()->has_popcnt)
st_update_functions[ST_NEW_VERTEX_ARRAYS_INDEX] = st_update_array_with_popcnt;
}
void
st_invalidate_buffers(struct st_context *st)
{
@@ -487,8 +471,16 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
st->cso_context = cso_create_context(pipe, cso_flags);
ctx->cso_context = st->cso_context;
static once_flag flag = ONCE_FLAG_INIT;
call_once(&flag, init_atoms_once);
STATIC_ASSERT(ARRAY_SIZE(st->update_functions) <= 64);
#define ST_STATE(FLAG, st_update) st->update_functions[FLAG##_INDEX] = st_update;
#include "st_atom_list.h"
#undef ST_STATE
if (util_get_cpu_caps()->has_popcnt) {
st->update_functions[ST_NEW_VERTEX_ARRAYS_INDEX] =
st_update_array_with_popcnt;
}
st_init_clear(st);
{

View File

@@ -120,6 +120,7 @@ struct st_zombie_shader_node
struct list_head node;
};
typedef void (*st_update_func_t)(struct st_context *st);
struct st_context
{
@@ -128,6 +129,9 @@ struct st_context
struct pipe_context *pipe;
struct cso_context *cso_context;
/* The list of state update functions. */
st_update_func_t update_functions[ST_NUM_ATOMS];
struct pipe_frontend_screen *frontend_screen; /* e.g. dri_screen */
void *frontend_context; /* e.g. dri_context */
@@ -514,10 +518,6 @@ st_api_destroy_drawable(struct pipe_frontend_drawable *drawable);
void
st_screen_destroy(struct pipe_frontend_screen *fscreen);
typedef void (*st_update_func_t)(struct st_context *st);
extern st_update_func_t st_update_functions[ST_NUM_ATOMS];
#ifdef __cplusplus
}
#endif

View File

@@ -124,18 +124,20 @@ st_validate_state(struct st_context *st, uint64_t pipeline_state_mask)
* x86_64: u_bit_scan64 is negligibly faster than u_bit_scan
* i386: u_bit_scan64 is noticably slower than u_bit_scan
*/
st_update_func_t *update_state = st->update_functions;
if (sizeof(void*) == 8) {
while (dirty)
st_update_functions[u_bit_scan64(&dirty)](st);
update_state[u_bit_scan64(&dirty)](st);
} else {
/* Split u_bit_scan64 into 2x u_bit_scan32 for i386. */
uint32_t dirty_lo = dirty;
uint32_t dirty_hi = dirty >> 32;
while (dirty_lo)
st_update_functions[u_bit_scan(&dirty_lo)](st);
update_state[u_bit_scan(&dirty_lo)](st);
while (dirty_hi)
st_update_functions[32 + u_bit_scan(&dirty_hi)](st);
update_state[32 + u_bit_scan(&dirty_hi)](st);
}
}
}