st/mesa: remove st_context::dirty, use gl_context::NewDirtyState instead
authorMarek Olšák <marek.olsak@amd.com>
Mon, 21 Nov 2022 12:37:45 +0000 (07:37 -0500)
committerMarge Bot <emma+marge@anholt.net>
Mon, 12 Dec 2022 19:15:34 +0000 (19:15 +0000)
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>

17 files changed:
src/mesa/main/compute.c
src/mesa/main/context.c
src/mesa/main/state.c
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_drawtex.c
src/mesa/state_tracker/st_cb_feedback.c
src/mesa/state_tracker/st_cb_readpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_manager.c
src/mesa/state_tracker/st_pbo_compute.c
src/mesa/state_tracker/st_program.c

index 1705ec6..8b4d9f9 100644 (file)
@@ -295,7 +295,7 @@ prepare_compute(struct gl_context *ctx)
    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);
 
index 0a51f01..b418b3c 100644 (file)
@@ -708,7 +708,7 @@ init_attrib_groups(struct gl_context *ctx)
    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;
@@ -1278,7 +1278,7 @@ _mesa_copy_context( const struct gl_context *src, struct gl_context *dst,
    /* XXX FIXME:  Call callbacks?
     */
    dst->NewState = _NEW_ALL;
-   dst->NewDriverState = ~0;
+   dst->NewDriverState = ST_ALL_STATES_MASK;
 }
 
 
index a103457..8e06fae 100644 (file)
@@ -382,11 +382,11 @@ update_program(struct gl_context *ctx)
    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;
       }
    }
 
index 0b9f90d..4854ede 100644 (file)
@@ -77,15 +77,7 @@ void st_destroy_atoms( struct st_context *st )
 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) {
@@ -125,12 +117,15 @@ void st_validate_state( struct st_context *st, enum st_pipeline 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.
     *
@@ -140,7 +135,4 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
       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;
 }
index 86cd6cc..c9d8840 100644 (file)
@@ -281,8 +281,8 @@ restore_render_state(struct gl_context *ctx)
    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;
 }
 
 
@@ -342,7 +342,7 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
    restore_render_state(ctx);
 
    /* We uploaded modified constants, need to invalidate them. */
-   st->dirty |= ST_NEW_FS_CONSTANTS;
+   ctx->NewDriverState |= ST_NEW_FS_CONSTANTS;
 }
 
 
@@ -633,7 +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 ((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);
    }
index 0c0a104..ba4e2f4 100644 (file)
@@ -354,8 +354,8 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
    /* 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;
 }
 
 
index e54930c..8309379 100644 (file)
@@ -945,8 +945,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
    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;
 }
 
 
index 357440e..8a6ed2d 100644 (file)
@@ -350,7 +350,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
    /* restore state */
    cso_restore_state(cso, 0);
    ctx->Array.NewVertexElements = true;
-   st->dirty |= ST_NEW_VERTEX_ARRAYS;
+   ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS;
 }
 
 /**
index a070c4c..5680097 100644 (file)
@@ -313,10 +313,10 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
       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;
 }
index 6364d8f..49fe00d 100644 (file)
@@ -260,10 +260,10 @@ fail:
    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;
 }
index 48af25a..2e42b6e 100644 (file)
@@ -1622,9 +1622,9 @@ fail:
    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;
 }
@@ -1912,10 +1912,10 @@ fail:
    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;
 }
@@ -3079,7 +3079,7 @@ st_finalize_texture(struct gl_context *ctx,
           */
          pipe_resource_reference(&tObj->pt, NULL);
          st_texture_release_all_sampler_views(st, tObj);
-         st->dirty |= ST_NEW_FRAMEBUFFER;
+         ctx->NewDriverState |= ST_NEW_FRAMEBUFFER;
       }
    }
 
index 93cdba2..eda6649 100644 (file)
@@ -74,17 +74,17 @@ DEBUG_GET_ONCE_BOOL_OPTION(mesa_mvp_dp4, "MESA_MVP_DP4", FALSE)
 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;
 }
 
 
@@ -109,58 +109,58 @@ st_invalidate_state(struct gl_context *ctx)
        * 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;
       }
    }
 }
@@ -448,7 +448,6 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
    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);
index 57024f7..da27faa 100644 (file)
@@ -249,8 +249,6 @@ struct st_context
          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;
 
index bd7adb9..d605366 100644 (file)
@@ -86,7 +86,7 @@ prepare_draw(struct st_context *st, struct gl_context *ctx, uint64_t state_mask,
    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);
    }
 
index 4ea6347..2f8cce1 100644 (file)
@@ -169,7 +169,7 @@ st_context_validate(struct st_context *st,
                     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);
@@ -178,7 +178,7 @@ st_context_validate(struct st_context *st,
 
     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);
@@ -903,18 +903,20 @@ st_context_teximage(struct st_context *st, GLenum target,
 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;
 }
 
 
@@ -1211,7 +1213,7 @@ st_manager_flush_frontbuffer(struct st_context *st)
       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;
    }
 }
 
index fc8bc37..1bd71f3 100644 (file)
@@ -1173,9 +1173,9 @@ fail:
    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;
 }
index de1cc4e..75c00ae 100644 (file)
@@ -269,31 +269,33 @@ delete_variant(struct st_context *st, struct st_variant *v, GLenum target)
 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");
@@ -1311,27 +1313,28 @@ st_serialize_nir(struct gl_program *prog)
 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;
       }
    }