st/mesa: remove the switch from st_validate_state by passing state mask directly
Instead of passing the enum that represents which states should be updated to st_validate_state, pass the state bitmask to st_validate_state directly. This removes the switch statement over the enums. 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:
@@ -949,7 +949,7 @@ read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
|
||||
/* add the buffer */
|
||||
st_manager_add_color_renderbuffer(ctx, fb, fb->_ColorReadBufferIndex);
|
||||
_mesa_update_state(ctx);
|
||||
st_validate_state(st_context(ctx), ST_PIPELINE_UPDATE_FRAMEBUFFER);
|
||||
st_validate_state(st_context(ctx), ST_PIPELINE_UPDATE_FB_STATE_MASK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ prepare_compute(struct gl_context *ctx)
|
||||
|
||||
if (ctx->NewDriverState & st->active_states &
|
||||
ST_PIPELINE_COMPUTE_STATE_MASK)
|
||||
st_validate_state(st, ST_PIPELINE_COMPUTE);
|
||||
st_validate_state(st, ST_PIPELINE_COMPUTE_STATE_MASK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5733,7 +5733,7 @@ _mesa_EvaluateDepthValuesARB(void)
|
||||
return;
|
||||
}
|
||||
|
||||
st_validate_state(st_context(ctx), ST_PIPELINE_UPDATE_FRAMEBUFFER);
|
||||
st_validate_state(st_context(ctx), ST_PIPELINE_UPDATE_FB_STATE_MASK);
|
||||
|
||||
ctx->pipe->evaluate_depth_buffer(ctx->pipe);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ get_sample_position(struct gl_context *ctx,
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
|
||||
st_validate_state(st, ST_PIPELINE_UPDATE_FRAMEBUFFER);
|
||||
st_validate_state(st, ST_PIPELINE_UPDATE_FB_STATE_MASK);
|
||||
|
||||
if (ctx->pipe->get_sample_position)
|
||||
ctx->pipe->get_sample_position(ctx->pipe,
|
||||
@@ -409,7 +409,7 @@ _mesa_GetProgrammableSampleCaps(struct gl_context *ctx, const struct gl_framebuf
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_screen *screen = ctx->pipe->screen;
|
||||
|
||||
st_validate_state(st, ST_PIPELINE_UPDATE_FRAMEBUFFER);
|
||||
st_validate_state(st, ST_PIPELINE_UPDATE_FB_STATE_MASK);
|
||||
|
||||
*outBits = 4;
|
||||
*outWidth = 1;
|
||||
|
||||
@@ -74,51 +74,12 @@ void st_destroy_atoms( struct st_context *st )
|
||||
* Update all derived state:
|
||||
*/
|
||||
|
||||
void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
|
||||
void st_validate_state(struct st_context *st, uint64_t pipeline_state_mask)
|
||||
{
|
||||
struct gl_context *ctx = st->ctx;
|
||||
uint64_t pipeline_mask;
|
||||
|
||||
/* Get pipeline state. */
|
||||
switch (pipeline) {
|
||||
case ST_PIPELINE_RENDER:
|
||||
case ST_PIPELINE_RENDER_NO_VARRAYS:
|
||||
if (pipeline == ST_PIPELINE_RENDER)
|
||||
pipeline_mask = ST_PIPELINE_RENDER_STATE_MASK;
|
||||
else
|
||||
pipeline_mask = ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS;
|
||||
break;
|
||||
|
||||
case ST_PIPELINE_CLEAR:
|
||||
pipeline_mask = ST_PIPELINE_CLEAR_STATE_MASK;
|
||||
break;
|
||||
|
||||
case ST_PIPELINE_META:
|
||||
pipeline_mask = ST_PIPELINE_META_STATE_MASK;
|
||||
break;
|
||||
|
||||
case ST_PIPELINE_UPDATE_FRAMEBUFFER:
|
||||
pipeline_mask = ST_PIPELINE_UPDATE_FB_STATE_MASK;
|
||||
break;
|
||||
|
||||
case ST_PIPELINE_COMPUTE: {
|
||||
/*
|
||||
* We add the ST_NEW_FB_STATE bit here as well, because glBindFramebuffer
|
||||
* acts as a barrier that breaks feedback loops between the framebuffer
|
||||
* and textures bound to the framebuffer, even when those textures are
|
||||
* accessed by compute shaders; so we must inform the driver of new
|
||||
* framebuffer state.
|
||||
*/
|
||||
pipeline_mask = ST_PIPELINE_COMPUTE_STATE_MASK | ST_NEW_FB_STATE;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
unreachable("Invalid pipeline specified");
|
||||
}
|
||||
|
||||
/* Inactive states are shader states not used by shaders at the moment. */
|
||||
uint64_t dirty = ctx->NewDriverState & st->active_states & pipeline_mask;
|
||||
uint64_t dirty = ctx->NewDriverState & st->active_states & pipeline_state_mask;
|
||||
if (!dirty)
|
||||
return;
|
||||
|
||||
|
||||
@@ -47,21 +47,10 @@ struct pipe_vertex_buffer;
|
||||
struct pipe_vertex_element;
|
||||
struct cso_velems_state;
|
||||
|
||||
/**
|
||||
* Enumeration of state tracker pipelines.
|
||||
*/
|
||||
enum st_pipeline {
|
||||
ST_PIPELINE_RENDER,
|
||||
ST_PIPELINE_RENDER_NO_VARRAYS,
|
||||
ST_PIPELINE_CLEAR,
|
||||
ST_PIPELINE_META,
|
||||
ST_PIPELINE_UPDATE_FRAMEBUFFER,
|
||||
ST_PIPELINE_COMPUTE,
|
||||
};
|
||||
|
||||
void st_init_atoms( struct st_context *st );
|
||||
void st_destroy_atoms( struct st_context *st );
|
||||
void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
|
||||
void st_validate_state(struct st_context *st, uint64_t pipeline_state_mask);
|
||||
|
||||
void
|
||||
st_setup_arrays(struct st_context *st,
|
||||
@@ -175,7 +164,6 @@ enum {
|
||||
#define ST_PIPELINE_RENDER_STATE_MASK (ST_NEW_CS_STATE - 1)
|
||||
#define ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS \
|
||||
(ST_PIPELINE_RENDER_STATE_MASK & ~ST_NEW_VERTEX_ARRAYS)
|
||||
#define ST_PIPELINE_COMPUTE_STATE_MASK (0xffull << ST_NEW_CS_STATE_INDEX)
|
||||
#define ST_PIPELINE_CLEAR_STATE_MASK (ST_NEW_FB_STATE | \
|
||||
ST_NEW_SCISSOR | \
|
||||
ST_NEW_WINDOW_RECTANGLES)
|
||||
@@ -183,6 +171,15 @@ enum {
|
||||
/* For ReadPixels, ReadBuffer, GetSamplePosition: */
|
||||
#define ST_PIPELINE_UPDATE_FB_STATE_MASK (ST_NEW_FB_STATE)
|
||||
|
||||
/* We add the ST_NEW_FB_STATE bit here as well, because glBindFramebuffer
|
||||
* acts as a barrier that breaks feedback loops between the framebuffer
|
||||
* and textures bound to the framebuffer, even when those textures are
|
||||
* accessed by compute shaders; so we must inform the driver of new
|
||||
* framebuffer state.
|
||||
*/
|
||||
#define ST_PIPELINE_COMPUTE_STATE_MASK ((0xffull << ST_NEW_CS_STATE_INDEX) | \
|
||||
ST_NEW_FB_STATE)
|
||||
|
||||
#define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
|
||||
ST_PIPELINE_COMPUTE_STATE_MASK)
|
||||
|
||||
|
||||
@@ -635,7 +635,7 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
|
||||
*/
|
||||
if (ctx->NewDriverState & st->active_states &
|
||||
~ST_NEW_CONSTANTS & ST_PIPELINE_RENDER_STATE_MASK) {
|
||||
st_validate_state(st, ST_PIPELINE_META);
|
||||
st_validate_state(st, ST_PIPELINE_META_STATE_MASK);
|
||||
}
|
||||
|
||||
struct pipe_sampler_view *view = NULL;
|
||||
|
||||
@@ -429,7 +429,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
|
||||
st_invalidate_readpix_cache(st);
|
||||
|
||||
/* This makes sure the pipe has the latest scissor, etc values */
|
||||
st_validate_state(st, ST_PIPELINE_CLEAR);
|
||||
st_validate_state(st, ST_PIPELINE_CLEAR_STATE_MASK);
|
||||
|
||||
if (mask & BUFFER_BITS_COLOR) {
|
||||
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
|
||||
|
||||
@@ -1291,7 +1291,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
|
||||
st_flush_bitmap_cache(st);
|
||||
st_invalidate_readpix_cache(st);
|
||||
|
||||
st_validate_state(st, ST_PIPELINE_META);
|
||||
st_validate_state(st, ST_PIPELINE_META_STATE_MASK);
|
||||
|
||||
clippedUnpack = *unpack;
|
||||
unpack = &clippedUnpack;
|
||||
@@ -1690,7 +1690,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
||||
st_flush_bitmap_cache(st);
|
||||
st_invalidate_readpix_cache(st);
|
||||
|
||||
st_validate_state(st, ST_PIPELINE_META);
|
||||
st_validate_state(st, ST_PIPELINE_META_STATE_MASK);
|
||||
|
||||
if (blit_copy_pixels(ctx, srcx, srcy, width, height, dstx, dsty, type))
|
||||
return;
|
||||
|
||||
@@ -176,7 +176,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
|
||||
st_flush_bitmap_cache(st);
|
||||
st_invalidate_readpix_cache(st);
|
||||
|
||||
st_validate_state(st, ST_PIPELINE_META);
|
||||
st_validate_state(st, ST_PIPELINE_META_STATE_MASK);
|
||||
|
||||
/* determine if we need vertex color */
|
||||
if (ctx->FragmentProgram._Current->info.inputs_read & VARYING_BIT_COL0)
|
||||
|
||||
@@ -250,7 +250,7 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
|
||||
draw_set_rasterize_stage(st->draw, st->rastpos_stage);
|
||||
|
||||
/* make sure everything's up to date */
|
||||
st_validate_state(st, ST_PIPELINE_RENDER);
|
||||
st_validate_state(st, ST_PIPELINE_RENDER_STATE_MASK);
|
||||
|
||||
/* This will get set only if rastpos_point(), above, gets called */
|
||||
ctx->PopAttribState |= GL_CURRENT_BIT;
|
||||
|
||||
@@ -429,7 +429,7 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
|
||||
|
||||
/* Validate state (to be sure we have up-to-date framebuffer surfaces)
|
||||
* and flush the bitmap cache prior to reading. */
|
||||
st_validate_state(st, ST_PIPELINE_UPDATE_FRAMEBUFFER);
|
||||
st_validate_state(st, ST_PIPELINE_UPDATE_FB_STATE_MASK);
|
||||
st_flush_bitmap_cache(st);
|
||||
|
||||
if (!st->prefer_blit_based_texture_transfer) {
|
||||
|
||||
@@ -74,8 +74,7 @@ static_assert(GL_TRIANGLE_STRIP_ADJACENCY == PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY,
|
||||
static_assert(GL_PATCHES == PIPE_PRIM_PATCHES, "enum mismatch");
|
||||
|
||||
static inline void
|
||||
prepare_draw(struct st_context *st, struct gl_context *ctx, uint64_t state_mask,
|
||||
enum st_pipeline pipeline)
|
||||
prepare_draw(struct st_context *st, struct gl_context *ctx, uint64_t state_mask)
|
||||
{
|
||||
/* Mesa core state should have been validated already */
|
||||
assert(ctx->NewState == 0x0);
|
||||
@@ -87,7 +86,7 @@ prepare_draw(struct st_context *st, struct gl_context *ctx, uint64_t state_mask,
|
||||
|
||||
/* Validate state. */
|
||||
if (ctx->NewDriverState & st->active_states & state_mask) {
|
||||
st_validate_state(st, pipeline);
|
||||
st_validate_state(st, state_mask);
|
||||
}
|
||||
|
||||
/* Pin threads regularly to the same Zen CCX that the main thread is
|
||||
@@ -165,7 +164,7 @@ st_draw_gallium(struct gl_context *ctx,
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK, ST_PIPELINE_RENDER);
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK);
|
||||
|
||||
if (!prepare_indexed_draw(st, ctx, info, draws, num_draws))
|
||||
return;
|
||||
@@ -182,7 +181,7 @@ st_draw_gallium_multimode(struct gl_context *ctx,
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK, ST_PIPELINE_RENDER);
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK);
|
||||
|
||||
if (!prepare_indexed_draw(st, ctx, info, draws, num_draws))
|
||||
return;
|
||||
@@ -239,7 +238,7 @@ st_indirect_draw_vbo(struct gl_context *ctx,
|
||||
return;
|
||||
|
||||
assert(stride);
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK, ST_PIPELINE_RENDER);
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK);
|
||||
|
||||
memset(&indirect, 0, sizeof(indirect));
|
||||
util_draw_init_info(&info);
|
||||
@@ -322,7 +321,7 @@ st_draw_transform_feedback(struct gl_context *ctx, GLenum mode,
|
||||
struct pipe_draw_indirect_info indirect;
|
||||
struct pipe_draw_start_count_bias draw = {0};
|
||||
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK, ST_PIPELINE_RENDER);
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK);
|
||||
|
||||
memset(&indirect, 0, sizeof(indirect));
|
||||
util_draw_init_info(&info);
|
||||
@@ -349,8 +348,7 @@ st_draw_gallium_vertex_state(struct gl_context *ctx,
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS,
|
||||
ST_PIPELINE_RENDER_NO_VARRAYS);
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS);
|
||||
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
uint32_t velem_mask = ctx->VertexProgram._Current->info.inputs_read;
|
||||
@@ -516,7 +514,7 @@ st_hw_select_draw_gallium(struct gl_context *ctx,
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK, ST_PIPELINE_RENDER);
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK);
|
||||
|
||||
if (!prepare_indexed_draw(st, ctx, info, draws, num_draws))
|
||||
return;
|
||||
@@ -537,7 +535,7 @@ st_hw_select_draw_gallium_multimode(struct gl_context *ctx,
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK, ST_PIPELINE_RENDER);
|
||||
prepare_draw(st, ctx, ST_PIPELINE_RENDER_STATE_MASK);
|
||||
|
||||
if (!prepare_indexed_draw(st, ctx, info, draws, num_draws))
|
||||
return;
|
||||
|
||||
@@ -117,7 +117,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
||||
st_flush_bitmap_cache(st);
|
||||
st_invalidate_readpix_cache(st);
|
||||
|
||||
st_validate_state(st, ST_PIPELINE_RENDER);
|
||||
st_validate_state(st, ST_PIPELINE_RENDER_STATE_MASK);
|
||||
|
||||
if (info->index_size && info->has_user_indices && !info->index_bounds_valid) {
|
||||
vbo_get_minmax_indices_gallium(ctx, info, draws, num_draws);
|
||||
|
||||
Reference in New Issue
Block a user