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:
@@ -72,22 +72,6 @@
|
|||||||
|
|
||||||
DEBUG_GET_ONCE_BOOL_OPTION(mesa_mvp_dp4, "MESA_MVP_DP4", false)
|
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
|
void
|
||||||
st_invalidate_buffers(struct st_context *st)
|
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);
|
st->cso_context = cso_create_context(pipe, cso_flags);
|
||||||
ctx->cso_context = st->cso_context;
|
ctx->cso_context = st->cso_context;
|
||||||
|
|
||||||
static once_flag flag = ONCE_FLAG_INIT;
|
STATIC_ASSERT(ARRAY_SIZE(st->update_functions) <= 64);
|
||||||
call_once(&flag, init_atoms_once);
|
|
||||||
|
#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);
|
st_init_clear(st);
|
||||||
{
|
{
|
||||||
|
@@ -120,6 +120,7 @@ struct st_zombie_shader_node
|
|||||||
struct list_head node;
|
struct list_head node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*st_update_func_t)(struct st_context *st);
|
||||||
|
|
||||||
struct st_context
|
struct st_context
|
||||||
{
|
{
|
||||||
@@ -128,6 +129,9 @@ struct st_context
|
|||||||
struct pipe_context *pipe;
|
struct pipe_context *pipe;
|
||||||
struct cso_context *cso_context;
|
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 */
|
struct pipe_frontend_screen *frontend_screen; /* e.g. dri_screen */
|
||||||
void *frontend_context; /* e.g. dri_context */
|
void *frontend_context; /* e.g. dri_context */
|
||||||
|
|
||||||
@@ -514,10 +518,6 @@ st_api_destroy_drawable(struct pipe_frontend_drawable *drawable);
|
|||||||
void
|
void
|
||||||
st_screen_destroy(struct pipe_frontend_screen *fscreen);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -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
|
* x86_64: u_bit_scan64 is negligibly faster than u_bit_scan
|
||||||
* i386: u_bit_scan64 is noticably slower 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) {
|
if (sizeof(void*) == 8) {
|
||||||
while (dirty)
|
while (dirty)
|
||||||
st_update_functions[u_bit_scan64(&dirty)](st);
|
update_state[u_bit_scan64(&dirty)](st);
|
||||||
} else {
|
} else {
|
||||||
/* Split u_bit_scan64 into 2x u_bit_scan32 for i386. */
|
/* Split u_bit_scan64 into 2x u_bit_scan32 for i386. */
|
||||||
uint32_t dirty_lo = dirty;
|
uint32_t dirty_lo = dirty;
|
||||||
uint32_t dirty_hi = dirty >> 32;
|
uint32_t dirty_hi = dirty >> 32;
|
||||||
|
|
||||||
while (dirty_lo)
|
while (dirty_lo)
|
||||||
st_update_functions[u_bit_scan(&dirty_lo)](st);
|
update_state[u_bit_scan(&dirty_lo)](st);
|
||||||
while (dirty_hi)
|
while (dirty_hi)
|
||||||
st_update_functions[32 + u_bit_scan(&dirty_hi)](st);
|
update_state[32 + u_bit_scan(&dirty_hi)](st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user