st/mesa: inline st_validate_state and remove redundant checking in callers
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19953>
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#include "state_tracker/st_manager.h"
|
||||
#include "state_tracker/st_atom.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
#include "state_tracker/st_util.h"
|
||||
|
||||
#define BAD_MASK ~0u
|
||||
|
||||
|
||||
@@ -295,10 +295,7 @@ prepare_compute(struct gl_context *ctx)
|
||||
if (ctx->NewState)
|
||||
_mesa_update_state(ctx);
|
||||
|
||||
if (ctx->NewDriverState & st->active_states &
|
||||
ST_PIPELINE_COMPUTE_STATE_MASK)
|
||||
st_validate_state(st, ST_PIPELINE_COMPUTE_STATE_MASK);
|
||||
|
||||
st_validate_state(st, ST_PIPELINE_COMPUTE_STATE_MASK);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "state_tracker/st_cb_eglimage.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
#include "state_tracker/st_format.h"
|
||||
#include "state_tracker/st_util.h"
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "state_tracker/st_context.h"
|
||||
#include "state_tracker/st_format.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
#include "state_tracker/st_util.h"
|
||||
|
||||
/**
|
||||
* Called via glSampleCoverageARB
|
||||
|
||||
@@ -41,25 +41,23 @@
|
||||
#include "util/u_cpu_detect.h"
|
||||
|
||||
|
||||
typedef void (*update_func_t)(struct st_context *st);
|
||||
|
||||
/* The list state update functions. */
|
||||
static update_func_t update_functions[ST_NUM_ATOMS];
|
||||
st_update_func_t st_update_functions[ST_NUM_ATOMS];
|
||||
|
||||
static void
|
||||
init_atoms_once(void)
|
||||
{
|
||||
#define ST_STATE(FLAG, st_update) update_functions[FLAG##_INDEX] = st_update;
|
||||
#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)
|
||||
update_functions[ST_NEW_VERTEX_ARRAYS_INDEX] = st_update_array_with_popcnt;
|
||||
st_update_functions[ST_NEW_VERTEX_ARRAYS_INDEX] = st_update_array_with_popcnt;
|
||||
}
|
||||
|
||||
void st_init_atoms( struct st_context *st )
|
||||
{
|
||||
STATIC_ASSERT(ARRAY_SIZE(update_functions) <= 64);
|
||||
STATIC_ASSERT(ARRAY_SIZE(st_update_functions) <= 64);
|
||||
|
||||
static once_flag flag = ONCE_FLAG_INIT;
|
||||
call_once(&flag, init_atoms_once);
|
||||
@@ -69,31 +67,3 @@ void st_destroy_atoms( struct st_context *st )
|
||||
{
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Update all derived state:
|
||||
*/
|
||||
|
||||
void st_validate_state(struct st_context *st, uint64_t pipeline_state_mask)
|
||||
{
|
||||
struct gl_context *ctx = st->ctx;
|
||||
|
||||
/* Inactive states are shader states not used by shaders at the moment. */
|
||||
uint64_t dirty = ctx->NewDriverState & st->active_states & pipeline_state_mask;
|
||||
if (!dirty)
|
||||
return;
|
||||
|
||||
ctx->NewDriverState &= ~dirty;
|
||||
|
||||
uint32_t dirty_lo = dirty;
|
||||
uint32_t dirty_hi = dirty >> 32;
|
||||
|
||||
/* Update states.
|
||||
*
|
||||
* Don't use u_bit_scan64, it may be slower on 32-bit.
|
||||
*/
|
||||
while (dirty_lo)
|
||||
update_functions[u_bit_scan(&dirty_lo)](st);
|
||||
while (dirty_hi)
|
||||
update_functions[32 + u_bit_scan(&dirty_hi)](st);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#define ST_ATOM_H
|
||||
|
||||
#include "util/glheader.h"
|
||||
#include "main/mtypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -50,7 +51,6 @@ struct cso_velems_state;
|
||||
|
||||
void st_init_atoms( struct st_context *st );
|
||||
void st_destroy_atoms( struct st_context *st );
|
||||
void st_validate_state(struct st_context *st, uint64_t pipeline_state_mask);
|
||||
|
||||
void
|
||||
st_setup_arrays(struct st_context *st,
|
||||
@@ -183,6 +183,10 @@ enum {
|
||||
#define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
|
||||
ST_PIPELINE_COMPUTE_STATE_MASK)
|
||||
|
||||
typedef void (*st_update_func_t)(struct st_context *st);
|
||||
|
||||
extern st_update_func_t st_update_functions[ST_NUM_ATOMS];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -633,10 +633,7 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
|
||||
* for bitmap drawing uses no constants and the FS constants are
|
||||
* explicitly uploaded in the draw_bitmap_quad() function.
|
||||
*/
|
||||
if (ctx->NewDriverState & st->active_states &
|
||||
~ST_NEW_CONSTANTS & ST_PIPELINE_RENDER_STATE_MASK) {
|
||||
st_validate_state(st, ST_PIPELINE_META_STATE_MASK);
|
||||
}
|
||||
st_validate_state(st, ST_PIPELINE_META_STATE_MASK & ~ST_NEW_CONSTANTS);
|
||||
|
||||
struct pipe_sampler_view *view = NULL;
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "st_draw.h"
|
||||
#include "st_program.h"
|
||||
#include "st_cb_rasterpos.h"
|
||||
#include "st_util.h"
|
||||
#include "draw/draw_context.h"
|
||||
#include "draw/draw_pipe.h"
|
||||
#include "vbo/vbo.h"
|
||||
|
||||
@@ -85,9 +85,7 @@ prepare_draw(struct st_context *st, struct gl_context *ctx, uint64_t state_mask)
|
||||
st_invalidate_readpix_cache(st);
|
||||
|
||||
/* Validate state. */
|
||||
if (ctx->NewDriverState & st->active_states & state_mask) {
|
||||
st_validate_state(st, state_mask);
|
||||
}
|
||||
st_validate_state(st, state_mask);
|
||||
|
||||
/* Pin threads regularly to the same Zen CCX that the main thread is
|
||||
* running on. The main thread can move between CCXs.
|
||||
|
||||
@@ -106,6 +106,30 @@ st_point_size_per_vertex(struct gl_context *ctx)
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void
|
||||
st_validate_state(struct st_context *st, uint64_t pipeline_state_mask)
|
||||
{
|
||||
struct gl_context *ctx = st->ctx;
|
||||
|
||||
/* Inactive states are shader states not used by shaders at the moment. */
|
||||
uint64_t dirty = ctx->NewDriverState & st->active_states & pipeline_state_mask;
|
||||
|
||||
if (dirty) {
|
||||
ctx->NewDriverState &= ~dirty;
|
||||
|
||||
uint32_t dirty_lo = dirty;
|
||||
uint32_t dirty_hi = dirty >> 32;
|
||||
|
||||
/* Update states. Don't use u_bit_scan64 because 64-bit ffs (x86 BSF)
|
||||
* is slower on x86_64 and emulated on i386.
|
||||
*/
|
||||
while (dirty_lo)
|
||||
st_update_functions[u_bit_scan(&dirty_lo)](st);
|
||||
while (dirty_hi)
|
||||
st_update_functions[32 + u_bit_scan(&dirty_hi)](st);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user