diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 79cd6834a0a..169987a572d 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -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); } } } diff --git a/src/mesa/main/compute.c b/src/mesa/main/compute.c index 8b4d9f910d4..c0ba026d6e4 100644 --- a/src/mesa/main/compute.c +++ b/src/mesa/main/compute.c @@ -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); } diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index be1d61907a4..be1a8ddc642 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -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); } diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c index 78516678fc9..e5f9f0aa453 100644 --- a/src/mesa/main/multisample.c +++ b/src/mesa/main/multisample.c @@ -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; diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 4854edeaa4e..c69f4e6aa36 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -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; diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 241d21eebfb..0f8063fa5de 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -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) diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index c9d88406fc9..7d8e12aed1a 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -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; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index ba4e2f43c41..be836b62eae 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -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++) { diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 8309379d8af..6c1e716f23c 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -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; diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c index 8a6ed2d2c08..1ea43748eb4 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.c +++ b/src/mesa/state_tracker/st_cb_drawtex.c @@ -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) diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 64dbd491b3a..244df25a0ef 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -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; diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 49fe00d0fb7..5c2738d057d 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -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) { diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index d605366f85d..d47fe46a76f 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -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; diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 070af57a433..4914ab2b15e 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -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);