We stored the same state in 2 different variables, and then we OR'd them.
This changes the st_validate_state logic slightly, but should be identical.
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19953>
if (ctx->NewState)
_mesa_update_state(ctx);
- if ((st->dirty | ctx->NewDriverState) & st->active_states &
+ if (ctx->NewDriverState & st->active_states &
ST_PIPELINE_COMPUTE_STATE_MASK)
st_validate_state(st, ST_PIPELINE_COMPUTE);
ctx->TileRasterOrderIncreasingX = GL_TRUE;
ctx->TileRasterOrderIncreasingY = GL_TRUE;
ctx->NewState = _NEW_ALL;
- ctx->NewDriverState = ~0;
+ ctx->NewDriverState = ST_ALL_STATES_MASK;
ctx->ErrorValue = GL_NO_ERROR;
ctx->ShareGroupReset = false;
ctx->VertexProgram._VaryingInputs = VERT_BIT_ALL;
/* XXX FIXME: Call callbacks?
*/
dst->NewState = _NEW_ALL;
- dst->NewDriverState = ~0;
+ dst->NewDriverState = ST_ALL_STATES_MASK;
}
if (st->lower_point_size && last_vertex_stage_dirty &&
!ctx->VertexProgram.PointSizeEnabled && !ctx->PointSizeIsSet) {
if (ctx->GeometryProgram._Current) {
- st->dirty |= ST_NEW_GS_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_GS_CONSTANTS;
} else if (ctx->TessEvalProgram._Current) {
- st->dirty |= ST_NEW_TES_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_TES_CONSTANTS;
} else {
- st->dirty |= ST_NEW_VS_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_VS_CONSTANTS;
}
}
void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
{
struct gl_context *ctx = st->ctx;
- uint64_t dirty, pipeline_mask;
- uint32_t dirty_lo, dirty_hi;
-
- /* Get Mesa driver state.
- *
- * Inactive states are shader states not used by shaders at the moment.
- */
- st->dirty |= ctx->NewDriverState & st->active_states & ST_ALL_STATES_MASK;
- ctx->NewDriverState &= ~st->dirty;
+ uint64_t pipeline_mask;
/* Get pipeline state. */
switch (pipeline) {
unreachable("Invalid pipeline specified");
}
- dirty = st->dirty & pipeline_mask;
+ /* Inactive states are shader states not used by shaders at the moment. */
+ uint64_t dirty = ctx->NewDriverState & st->active_states & pipeline_mask;
if (!dirty)
return;
- dirty_lo = dirty;
- dirty_hi = dirty >> 32;
+ ctx->NewDriverState &= ~dirty;
+
+ uint32_t dirty_lo = dirty;
+ uint32_t dirty_hi = dirty >> 32;
/* Update states.
*
update_functions[u_bit_scan(&dirty_lo)](st);
while (dirty_hi)
update_functions[32 + u_bit_scan(&dirty_hi)](st);
-
- /* Clear the render or compute state bits. */
- st->dirty &= ~pipeline_mask;
}
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
ctx->Array.NewVertexElements = true;
- st->dirty |= ST_NEW_VERTEX_ARRAYS |
- ST_NEW_FS_SAMPLER_VIEWS;
+ ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS |
+ ST_NEW_FS_SAMPLER_VIEWS;
}
restore_render_state(ctx);
/* We uploaded modified constants, need to invalidate them. */
- st->dirty |= ST_NEW_FS_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_FS_CONSTANTS;
}
* for bitmap drawing uses no constants and the FS constants are
* explicitly uploaded in the draw_bitmap_quad() function.
*/
- if ((st->dirty | ctx->NewDriverState) & st->active_states &
+ if (ctx->NewDriverState & st->active_states &
~ST_NEW_CONSTANTS & ST_PIPELINE_RENDER_STATE_MASK) {
st_validate_state(st, ST_PIPELINE_META);
}
/* Restore pipe state */
cso_restore_state(cso, 0);
ctx->Array.NewVertexElements = true;
- st->dirty |= ST_NEW_VERTEX_ARRAYS |
- ST_NEW_FS_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS |
+ ST_NEW_FS_CONSTANTS;
}
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
ctx->Array.NewVertexElements = true;
- st->dirty |= ST_NEW_VERTEX_ARRAYS |
- ST_NEW_FS_SAMPLER_VIEWS;
+ ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS |
+ ST_NEW_FS_SAMPLER_VIEWS;
}
/* restore state */
cso_restore_state(cso, 0);
ctx->Array.NewVertexElements = true;
- st->dirty |= ST_NEW_VERTEX_ARRAYS;
+ ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS;
}
/**
ctx->Driver.DrawGalliumMultiMode = st_feedback_draw_vbo_multi_mode;
/* need to generate/use a vertex program that emits pos/color/tex */
if (vp)
- st->dirty |= ST_NEW_VERTEX_PROGRAM(ctx, vp);
+ ctx->NewDriverState |= ST_NEW_VERTEX_PROGRAM(ctx, vp);
}
/* Restore geometry shader states when leaving GL_SELECT mode. */
if (ctx->RenderMode == GL_SELECT && ctx->Const.HardwareAcceleratedSelect)
- st->dirty |= ST_NEW_GS_SSBOS | ST_NEW_GS_CONSTANTS | ST_NEW_GS_STATE;
+ ctx->NewDriverState |= ST_NEW_GS_SSBOS | ST_NEW_GS_CONSTANTS | ST_NEW_GS_STATE;
}
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
st->ctx->Array.NewVertexElements = true;
- st->dirty |= ST_NEW_FS_CONSTANTS |
- ST_NEW_FS_IMAGES |
- ST_NEW_FS_SAMPLER_VIEWS |
- ST_NEW_VERTEX_ARRAYS;
+ st->ctx->NewDriverState |= ST_NEW_FS_CONSTANTS |
+ ST_NEW_FS_IMAGES |
+ ST_NEW_FS_SAMPLER_VIEWS |
+ ST_NEW_VERTEX_ARRAYS;
return success;
}
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
ctx->Array.NewVertexElements = true;
- st->dirty |= ST_NEW_VERTEX_ARRAYS |
- ST_NEW_FS_CONSTANTS |
- ST_NEW_FS_SAMPLER_VIEWS;
+ ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS |
+ ST_NEW_FS_CONSTANTS |
+ ST_NEW_FS_SAMPLER_VIEWS;
return success;
}
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
st->ctx->Array.NewVertexElements = true;
- st->dirty |= ST_NEW_FS_CONSTANTS |
- ST_NEW_FS_IMAGES |
- ST_NEW_FS_SAMPLER_VIEWS |
- ST_NEW_VERTEX_ARRAYS;
+ st->ctx->NewDriverState |= ST_NEW_FS_CONSTANTS |
+ ST_NEW_FS_IMAGES |
+ ST_NEW_FS_SAMPLER_VIEWS |
+ ST_NEW_VERTEX_ARRAYS;
return success;
}
*/
pipe_resource_reference(&tObj->pt, NULL);
st_texture_release_all_sampler_views(st, tObj);
- st->dirty |= ST_NEW_FRAMEBUFFER;
+ ctx->NewDriverState |= ST_NEW_FRAMEBUFFER;
}
}
void
st_invalidate_buffers(struct st_context *st)
{
- st->dirty |= ST_NEW_BLEND |
- ST_NEW_DSA |
- ST_NEW_FB_STATE |
- ST_NEW_SAMPLE_STATE |
- ST_NEW_SAMPLE_SHADING |
- ST_NEW_FS_STATE |
- ST_NEW_POLY_STIPPLE |
- ST_NEW_VIEWPORT |
- ST_NEW_RASTERIZER |
- ST_NEW_SCISSOR |
- ST_NEW_WINDOW_RECTANGLES;
+ st->ctx->NewDriverState |= ST_NEW_BLEND |
+ ST_NEW_DSA |
+ ST_NEW_FB_STATE |
+ ST_NEW_SAMPLE_STATE |
+ ST_NEW_SAMPLE_SHADING |
+ ST_NEW_FS_STATE |
+ ST_NEW_POLY_STIPPLE |
+ ST_NEW_VIEWPORT |
+ ST_NEW_RASTERIZER |
+ ST_NEW_SCISSOR |
+ ST_NEW_WINDOW_RECTANGLES;
}
* check them when _NEW_BUFFERS isn't set.
*/
if (new_state & _NEW_FOG)
- st->dirty |= ST_NEW_FS_STATE;
+ ctx->NewDriverState |= ST_NEW_FS_STATE;
}
if (new_state & (_NEW_LIGHT_STATE |
_NEW_POINT))
- st->dirty |= ST_NEW_RASTERIZER;
+ ctx->NewDriverState |= ST_NEW_RASTERIZER;
if ((new_state & _NEW_LIGHT_STATE) &&
(st->lower_flatshade || st->lower_two_sided_color))
- st->dirty |= ST_NEW_FS_STATE;
+ ctx->NewDriverState |= ST_NEW_FS_STATE;
if (new_state & _NEW_PROJECTION &&
st_user_clip_planes_enabled(ctx))
- st->dirty |= ST_NEW_CLIP_STATE;
+ ctx->NewDriverState |= ST_NEW_CLIP_STATE;
if (new_state & _NEW_PIXEL)
- st->dirty |= ST_NEW_PIXEL_TRANSFER;
+ ctx->NewDriverState |= ST_NEW_PIXEL_TRANSFER;
if (new_state & _NEW_CURRENT_ATTRIB && st_vp_uses_current_values(ctx)) {
- st->dirty |= ST_NEW_VERTEX_ARRAYS;
+ ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS;
/* glColor3f -> glColor4f changes the vertex format. */
ctx->Array.NewVertexElements = true;
}
/* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT_STATE)) {
- st->dirty |= ST_NEW_VS_STATE;
+ ctx->NewDriverState |= ST_NEW_VS_STATE;
if (st->ctx->API == API_OPENGL_COMPAT && ctx->Version >= 32) {
- st->dirty |= ST_NEW_GS_STATE | ST_NEW_TES_STATE;
+ ctx->NewDriverState |= ST_NEW_GS_STATE | ST_NEW_TES_STATE;
}
}
/* Update the vertex shader if ctx->Point was changed. */
if (st->lower_point_size && new_state & _NEW_POINT) {
if (ctx->GeometryProgram._Current)
- st->dirty |= ST_NEW_GS_STATE | ST_NEW_GS_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_GS_STATE | ST_NEW_GS_CONSTANTS;
else if (ctx->TessEvalProgram._Current)
- st->dirty |= ST_NEW_TES_STATE | ST_NEW_TES_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_TES_STATE | ST_NEW_TES_CONSTANTS;
else
- st->dirty |= ST_NEW_VS_STATE | ST_NEW_VS_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_VS_STATE | ST_NEW_VS_CONSTANTS;
}
if (new_state & _NEW_TEXTURE_OBJECT) {
- st->dirty |= st->active_states &
- (ST_NEW_SAMPLER_VIEWS |
- ST_NEW_SAMPLERS |
- ST_NEW_IMAGE_UNITS);
+ ctx->NewDriverState |= st->active_states &
+ (ST_NEW_SAMPLER_VIEWS |
+ ST_NEW_SAMPLERS |
+ ST_NEW_IMAGE_UNITS);
if (ctx->FragmentProgram._Current) {
struct gl_program *fp = ctx->FragmentProgram._Current;
if (fp->ExternalSamplersUsed || fp->ati_fs)
- st->dirty |= ST_NEW_FS_STATE;
+ ctx->NewDriverState |= ST_NEW_FS_STATE;
}
}
}
st->ctx = ctx;
st->screen = screen;
st->pipe = pipe;
- st->dirty = ST_ALL_STATES_MASK;
st->can_bind_const_buffer_as_vertex =
screen->get_param(screen, PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX);
PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE * 32];
} state;
- uint64_t dirty; /**< dirty states */
-
/** This masks out unused shader resources. Only valid in draw calls. */
uint64_t active_states;
st_invalidate_readpix_cache(st);
/* Validate state. */
- if ((st->dirty | ctx->NewDriverState) & st->active_states & state_mask) {
+ if (ctx->NewDriverState & st->active_states & state_mask) {
st_validate_state(st, pipeline);
}
struct gl_framebuffer *stread)
{
if (stdraw && stdraw->stamp != st->draw_stamp) {
- st->dirty |= ST_NEW_FRAMEBUFFER;
+ st->ctx->NewDriverState |= ST_NEW_FRAMEBUFFER;
_mesa_resize_framebuffer(st->ctx, stdraw,
stdraw->Width,
stdraw->Height);
if (stread && stread->stamp != st->read_stamp) {
if (stread != stdraw) {
- st->dirty |= ST_NEW_FRAMEBUFFER;
+ st->ctx->NewDriverState |= ST_NEW_FRAMEBUFFER;
_mesa_resize_framebuffer(st->ctx, stread,
stread->Width,
stread->Height);
void
st_context_invalidate_state(struct st_context *st, unsigned flags)
{
+ struct gl_context *ctx = st->ctx;
+
if (flags & ST_INVALIDATE_FS_SAMPLER_VIEWS)
- st->dirty |= ST_NEW_FS_SAMPLER_VIEWS;
+ ctx->NewDriverState |= ST_NEW_FS_SAMPLER_VIEWS;
if (flags & ST_INVALIDATE_FS_CONSTBUF0)
- st->dirty |= ST_NEW_FS_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_FS_CONSTANTS;
if (flags & ST_INVALIDATE_VS_CONSTBUF0)
- st->dirty |= ST_NEW_VS_CONSTANTS;
+ ctx->NewDriverState |= ST_NEW_VS_CONSTANTS;
if (flags & ST_INVALIDATE_VERTEX_BUFFERS) {
- st->ctx->Array.NewVertexElements = true;
- st->dirty |= ST_NEW_VERTEX_ARRAYS;
+ ctx->Array.NewVertexElements = true;
+ ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS;
}
if (flags & ST_INVALIDATE_FB_STATE)
- st->dirty |= ST_NEW_FB_STATE;
+ ctx->NewDriverState |= ST_NEW_FB_STATE;
}
rb->defined = GL_FALSE;
/* Trigger an update of rb->defined on next draw */
- st->dirty |= ST_NEW_FB_STATE;
+ st->ctx->NewDriverState |= ST_NEW_FB_STATE;
}
}
st->state.num_sampler_views[PIPE_SHADER_COMPUTE] = 0;
pipe->set_shader_buffers(pipe, PIPE_SHADER_COMPUTE, 0, 1, NULL, 0);
- st->dirty |= ST_NEW_CS_CONSTANTS |
- ST_NEW_CS_SSBOS |
- ST_NEW_CS_SAMPLER_VIEWS;
+ st->ctx->NewDriverState |= ST_NEW_CS_CONSTANTS |
+ ST_NEW_CS_SSBOS |
+ ST_NEW_CS_SAMPLER_VIEWS;
return dst;
}
static void
st_unbind_program(struct st_context *st, struct gl_program *p)
{
+ struct gl_context *ctx = st->ctx;
+
/* Unbind the shader in cso_context and re-bind in st/mesa. */
switch (p->info.stage) {
case MESA_SHADER_VERTEX:
cso_set_vertex_shader_handle(st->cso_context, NULL);
- st->dirty |= ST_NEW_VS_STATE;
+ ctx->NewDriverState |= ST_NEW_VS_STATE;
break;
case MESA_SHADER_TESS_CTRL:
cso_set_tessctrl_shader_handle(st->cso_context, NULL);
- st->dirty |= ST_NEW_TCS_STATE;
+ ctx->NewDriverState |= ST_NEW_TCS_STATE;
break;
case MESA_SHADER_TESS_EVAL:
cso_set_tesseval_shader_handle(st->cso_context, NULL);
- st->dirty |= ST_NEW_TES_STATE;
+ ctx->NewDriverState |= ST_NEW_TES_STATE;
break;
case MESA_SHADER_GEOMETRY:
cso_set_geometry_shader_handle(st->cso_context, NULL);
- st->dirty |= ST_NEW_GS_STATE;
+ ctx->NewDriverState |= ST_NEW_GS_STATE;
break;
case MESA_SHADER_FRAGMENT:
cso_set_fragment_shader_handle(st->cso_context, NULL);
- st->dirty |= ST_NEW_FS_STATE;
+ ctx->NewDriverState |= ST_NEW_FS_STATE;
break;
case MESA_SHADER_COMPUTE:
cso_set_compute_shader_handle(st->cso_context, NULL);
- st->dirty |= ST_NEW_CS_STATE;
+ ctx->NewDriverState |= ST_NEW_CS_STATE;
break;
default:
unreachable("invalid shader type");
void
st_finalize_program(struct st_context *st, struct gl_program *prog)
{
+ struct gl_context *ctx = st->ctx;
bool is_bound = false;
if (prog->info.stage == MESA_SHADER_VERTEX)
- is_bound = prog == st->ctx->VertexProgram._Current;
+ is_bound = prog == ctx->VertexProgram._Current;
else if (prog->info.stage == MESA_SHADER_TESS_CTRL)
- is_bound = prog == st->ctx->TessCtrlProgram._Current;
+ is_bound = prog == ctx->TessCtrlProgram._Current;
else if (prog->info.stage == MESA_SHADER_TESS_EVAL)
- is_bound = prog == st->ctx->TessEvalProgram._Current;
+ is_bound = prog == ctx->TessEvalProgram._Current;
else if (prog->info.stage == MESA_SHADER_GEOMETRY)
- is_bound = prog == st->ctx->GeometryProgram._Current;
+ is_bound = prog == ctx->GeometryProgram._Current;
else if (prog->info.stage == MESA_SHADER_FRAGMENT)
- is_bound = prog == st->ctx->FragmentProgram._Current;
+ is_bound = prog == ctx->FragmentProgram._Current;
else if (prog->info.stage == MESA_SHADER_COMPUTE)
- is_bound = prog == st->ctx->ComputeProgram._Current;
+ is_bound = prog == ctx->ComputeProgram._Current;
if (is_bound) {
if (prog->info.stage == MESA_SHADER_VERTEX) {
- st->ctx->Array.NewVertexElements = true;
- st->dirty |= ST_NEW_VERTEX_PROGRAM(st->ctx, prog);
+ ctx->Array.NewVertexElements = true;
+ ctx->NewDriverState |= ST_NEW_VERTEX_PROGRAM(ctx, prog);
} else {
- st->dirty |= prog->affected_states;
+ ctx->NewDriverState |= prog->affected_states;
}
}