st/mesa: completely rewrite state atoms
authorMarek Olšák <marek.olsak@amd.com>
Sun, 17 Jul 2016 16:38:38 +0000 (18:38 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 30 Jul 2016 13:02:14 +0000 (15:02 +0200)
The goal is to do this in st_validate_state:
   while (dirty)
      atoms[u_bit_scan(&dirty)]->update(st);

That implies that atoms can't specify which flags they consume.
There is exactly one ST_NEW_* flag for each atom. (58 flags in total)

There are macros that combine multiple flags into one for easier use.

All _NEW_* flags are translated into ST_NEW_* flags in st_invalidate_state.
st/mesa doesn't keep the _NEW_* flags after that.

torcs is 2% faster between the previous patch and the end of this series.

v2: - add st_atom_list.h to Makefile.sources

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
33 files changed:
src/mesa/Makefile.sources
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_atom.h
src/mesa/state_tracker/st_atom_array.c
src/mesa/state_tracker/st_atom_atomicbuf.c
src/mesa/state_tracker/st_atom_blend.c
src/mesa/state_tracker/st_atom_clip.c
src/mesa/state_tracker/st_atom_constbuf.c
src/mesa/state_tracker/st_atom_depth.c
src/mesa/state_tracker/st_atom_framebuffer.c
src/mesa/state_tracker/st_atom_image.c
src/mesa/state_tracker/st_atom_list.h [new file with mode: 0644]
src/mesa/state_tracker/st_atom_msaa.c
src/mesa/state_tracker/st_atom_pixeltransfer.c
src/mesa/state_tracker/st_atom_rasterizer.c
src/mesa/state_tracker/st_atom_sampler.c
src/mesa/state_tracker/st_atom_scissor.c
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_atom_stipple.c
src/mesa/state_tracker/st_atom_storagebuf.c
src/mesa/state_tracker/st_atom_tess.c
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_atom_viewport.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/state_tracker/st_cb_compute.c
src/mesa/state_tracker/st_cb_feedback.c
src/mesa/state_tracker/st_cb_program.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

index a16968d7e872ed00a0795cd590444e2ed52dccc1..472e767d844f49f9f170cafde0767f072a920ce9 100644 (file)
@@ -409,6 +409,7 @@ STATETRACKER_FILES = \
        state_tracker/st_atom_depth.c \
        state_tracker/st_atom_framebuffer.c \
        state_tracker/st_atom.h \
+       state_tracker/st_atom_list.h \
        state_tracker/st_atom_image.c \
        state_tracker/st_atom_msaa.c \
        state_tracker/st_atom_pixeltransfer.c \
index 9d5cc0f3010d9ec648c7bafa79bc2454d3d2b8ac..32b8602a9d4ecfad6788785c7bbe345822b637b9 100644 (file)
 #include "st_manager.h"
 
 
-/**
- * This is used to initialize st->render_atoms[].
- */
-static const struct st_tracked_state *render_atoms[] =
-{
-   &st_update_depth_stencil_alpha,
-   &st_update_clip,
-
-   &st_update_fp,
-   &st_update_gp,
-   &st_update_tep,
-   &st_update_tcp,
-   &st_update_vp,
-
-   &st_update_rasterizer,
-   &st_update_polygon_stipple,
-   &st_update_viewport,
-   &st_update_scissor,
-   &st_update_window_rectangles,
-   &st_update_blend,
-   &st_update_vertex_texture,
-   &st_update_fragment_texture,
-   &st_update_geometry_texture,
-   &st_update_tessctrl_texture,
-   &st_update_tesseval_texture,
-   &st_update_sampler, /* depends on update_*_texture for swizzle */
-   &st_bind_vs_images,
-   &st_bind_tcs_images,
-   &st_bind_tes_images,
-   &st_bind_gs_images,
-   &st_bind_fs_images,
-   &st_update_framebuffer, /* depends on update_*_texture and bind_*_images */
-   &st_update_msaa,
-   &st_update_sample_shading,
-   &st_update_vs_constants,
-   &st_update_tcs_constants,
-   &st_update_tes_constants,
-   &st_update_gs_constants,
-   &st_update_fs_constants,
-   &st_bind_vs_ubos,
-   &st_bind_tcs_ubos,
-   &st_bind_tes_ubos,
-   &st_bind_fs_ubos,
-   &st_bind_gs_ubos,
-   &st_bind_vs_atomics,
-   &st_bind_tcs_atomics,
-   &st_bind_tes_atomics,
-   &st_bind_fs_atomics,
-   &st_bind_gs_atomics,
-   &st_bind_vs_ssbos,
-   &st_bind_tcs_ssbos,
-   &st_bind_tes_ssbos,
-   &st_bind_fs_ssbos,
-   &st_bind_gs_ssbos,
-   &st_update_pixel_transfer,
-   &st_update_tess,
-
-   /* this must be done after the vertex program update */
-   &st_update_array
-};
-
-
-/**
- * This is used to initialize st->compute_atoms[].
- */
-static const struct st_tracked_state *compute_atoms[] =
+/* The list state update functions. */
+static const struct st_tracked_state *atoms[] =
 {
-   &st_update_cp,
-   &st_update_compute_texture,
-   &st_update_sampler, /* depends on update_compute_texture for swizzle */
-   &st_update_cs_constants,
-   &st_bind_cs_ubos,
-   &st_bind_cs_atomics,
-   &st_bind_cs_ssbos,
-   &st_bind_cs_images,
+#define ST_STATE(FLAG, st_update) &st_update,
+#include "st_atom_list.h"
+#undef ST_STATE
 };
 
 
 void st_init_atoms( struct st_context *st )
 {
-   /* no-op */
+   STATIC_ASSERT(ARRAY_SIZE(atoms) <= 64);
 }
 
 
@@ -127,13 +58,6 @@ void st_destroy_atoms( struct st_context *st )
 }
 
 
-
-static bool
-check_state(const struct st_state_flags *a, const struct st_state_flags *b)
-{
-   return (a->mesa & b->mesa) || (a->st & b->st);
-}
-
 /* Too complex to figure out, just check every time:
  */
 static void check_program_state( struct st_context *st )
@@ -141,13 +65,13 @@ static void check_program_state( struct st_context *st )
    struct gl_context *ctx = st->ctx;
 
    if (ctx->VertexProgram._Current != &st->vp->Base)
-      st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+      st->dirty |= ST_NEW_VERTEX_PROGRAM;
 
    if (ctx->FragmentProgram._Current != &st->fp->Base)
-      st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
+      st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
 
    if (ctx->GeometryProgram._Current != &st->gp->Base)
-      st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
+      st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
 }
 
 static void check_attrib_edgeflag(struct st_context *st)
@@ -165,14 +89,14 @@ static void check_attrib_edgeflag(struct st_context *st)
                         arrays[VERT_ATTRIB_EDGEFLAG]->StrideB != 0;
    if (vertdata_edgeflags != st->vertdata_edgeflags) {
       st->vertdata_edgeflags = vertdata_edgeflags;
-      st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+      st->dirty |= ST_NEW_VERTEX_PROGRAM;
    }
 
    edgeflag_culls_prims = edgeflags_enabled && !vertdata_edgeflags &&
                           !st->ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0];
    if (edgeflag_culls_prims != st->edgeflag_culls_prims) {
       st->edgeflag_culls_prims = edgeflag_culls_prims;
-      st->dirty.st |= ST_NEW_RASTERIZER;
+      st->dirty |= ST_NEW_RASTERIZER;
    }
 }
 
@@ -183,49 +107,45 @@ static void check_attrib_edgeflag(struct st_context *st)
 
 void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
 {
-   const struct st_tracked_state **atoms;
-   struct st_state_flags *state;
-   GLuint num_atoms;
-   GLuint i;
+   uint64_t dirty, pipeline_mask;
+   uint32_t dirty_lo, dirty_hi;
+
+   /* Get Mesa driver state. */
+   st->dirty |= st->ctx->NewDriverState & ST_ALL_STATES_MASK;
+   st->ctx->NewDriverState = 0;
 
    /* Get pipeline state. */
    switch (pipeline) {
-    case ST_PIPELINE_RENDER:
-      atoms     = render_atoms;
-      num_atoms = ARRAY_SIZE(render_atoms);
-      state     = &st->dirty;
+   case ST_PIPELINE_RENDER:
+      check_attrib_edgeflag(st);
+      check_program_state(st);
+      st_manager_validate_framebuffers(st);
+
+      pipeline_mask = ST_PIPELINE_RENDER_STATE_MASK;
       break;
    case ST_PIPELINE_COMPUTE:
-      atoms     = compute_atoms;
-      num_atoms = ARRAY_SIZE(compute_atoms);
-      state     = &st->dirty_cp;
+      pipeline_mask = ST_PIPELINE_COMPUTE_STATE_MASK;
       break;
    default:
       unreachable("Invalid pipeline specified");
    }
 
-   /* Get Mesa driver state. */
-   st->dirty.st |= st->ctx->NewDriverState;
-   st->dirty_cp.st |= st->ctx->NewDriverState;
-   st->ctx->NewDriverState = 0;
-
-   if (pipeline == ST_PIPELINE_RENDER) {
-      check_attrib_edgeflag(st);
-
-      check_program_state(st);
-
-      st_manager_validate_framebuffers(st);
-   }
-
-   if (state->st == 0 && state->mesa == 0)
+   dirty = st->dirty & pipeline_mask;
+   if (!dirty)
       return;
 
-   /*printf("%s %x/%x\n", __func__, state->mesa, state->st);*/
+   dirty_lo = dirty;
+   dirty_hi = dirty >> 32;
 
-   for (i = 0; i < num_atoms; i++) {
-      if (check_state(state, &atoms[i]->dirty))
-         atoms[i]->update( st );
-   }
+   /* Update states.
+    *
+    * Don't use u_bit_scan64, it may be slower on 32-bit.
+    */
+   while (dirty_lo)
+      atoms[u_bit_scan(&dirty_lo)]->update(st);
+   while (dirty_hi)
+      atoms[32 + u_bit_scan(&dirty_hi)]->update(st);
 
-   memset(state, 0, sizeof(*state));
+   /* Clear the render or compute state bits. */
+   st->dirty &= ~pipeline_mask;
 }
index d5fb94141caab7cf55f3832aaeb0b1cc0d402fc0..871afc6ead569e969dbb1d341e15d6f3802712f5 100644 (file)
 
 #include "main/glheader.h"
 
-#include "state_tracker/st_api.h"
-#include "state_tracker/st_context.h"
-
 struct st_context;
-struct st_tracked_state;
+
+/**
+ * Enumeration of state tracker pipelines.
+ */
+enum st_pipeline {
+   ST_PIPELINE_RENDER,
+   ST_PIPELINE_COMPUTE,
+};
+
+struct st_tracked_state {
+   void (*update)( struct st_context *st );
+};
+
 
 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 );
+GLuint st_compare_func_to_pipe(GLenum func);
 
+enum pipe_format
+st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
+                      GLboolean normalized, GLboolean integer);
 
-void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
 
+/* Define ST_NEW_xxx_INDEX */
+enum {
+#define ST_STATE(FLAG, st_update) FLAG##_INDEX,
+#include "st_atom_list.h"
+#undef ST_STATE
+};
 
-extern const struct st_tracked_state st_update_array;
-extern const struct st_tracked_state st_update_framebuffer;
-extern const struct st_tracked_state st_update_clip;
-extern const struct st_tracked_state st_update_depth_stencil_alpha;
-extern const struct st_tracked_state st_update_fp;
-extern const struct st_tracked_state st_update_gp;
-extern const struct st_tracked_state st_update_tep;
-extern const struct st_tracked_state st_update_tcp;
-extern const struct st_tracked_state st_update_vp;
-extern const struct st_tracked_state st_update_cp;
-extern const struct st_tracked_state st_update_rasterizer;
-extern const struct st_tracked_state st_update_polygon_stipple;
-extern const struct st_tracked_state st_update_viewport;
-extern const struct st_tracked_state st_update_scissor;
-extern const struct st_tracked_state st_update_window_rectangles;
-extern const struct st_tracked_state st_update_blend;
-extern const struct st_tracked_state st_update_msaa;
-extern const struct st_tracked_state st_update_sample_shading;
-extern const struct st_tracked_state st_update_sampler;
-extern const struct st_tracked_state st_update_fragment_texture;
-extern const struct st_tracked_state st_update_vertex_texture;
-extern const struct st_tracked_state st_update_geometry_texture;
-extern const struct st_tracked_state st_update_tessctrl_texture;
-extern const struct st_tracked_state st_update_tesseval_texture;
-extern const struct st_tracked_state st_update_compute_texture;
-extern const struct st_tracked_state st_update_fs_constants;
-extern const struct st_tracked_state st_update_gs_constants;
-extern const struct st_tracked_state st_update_tes_constants;
-extern const struct st_tracked_state st_update_tcs_constants;
-extern const struct st_tracked_state st_update_vs_constants;
-extern const struct st_tracked_state st_update_cs_constants;
-extern const struct st_tracked_state st_bind_fs_ubos;
-extern const struct st_tracked_state st_bind_vs_ubos;
-extern const struct st_tracked_state st_bind_gs_ubos;
-extern const struct st_tracked_state st_bind_tcs_ubos;
-extern const struct st_tracked_state st_bind_tes_ubos;
-extern const struct st_tracked_state st_bind_cs_ubos;
-extern const struct st_tracked_state st_bind_fs_atomics;
-extern const struct st_tracked_state st_bind_vs_atomics;
-extern const struct st_tracked_state st_bind_gs_atomics;
-extern const struct st_tracked_state st_bind_tcs_atomics;
-extern const struct st_tracked_state st_bind_tes_atomics;
-extern const struct st_tracked_state st_bind_cs_atomics;
-extern const struct st_tracked_state st_bind_fs_ssbos;
-extern const struct st_tracked_state st_bind_vs_ssbos;
-extern const struct st_tracked_state st_bind_gs_ssbos;
-extern const struct st_tracked_state st_bind_tcs_ssbos;
-extern const struct st_tracked_state st_bind_tes_ssbos;
-extern const struct st_tracked_state st_bind_cs_ssbos;
-extern const struct st_tracked_state st_bind_fs_images;
-extern const struct st_tracked_state st_bind_vs_images;
-extern const struct st_tracked_state st_bind_gs_images;
-extern const struct st_tracked_state st_bind_tcs_images;
-extern const struct st_tracked_state st_bind_tes_images;
-extern const struct st_tracked_state st_bind_cs_images;
-extern const struct st_tracked_state st_update_pixel_transfer;
-extern const struct st_tracked_state st_update_tess;
+/* Define ST_NEW_xxx */
+enum {
+#define ST_STATE(FLAG, st_update) FLAG = 1llu << FLAG##_INDEX,
+#include "st_atom_list.h"
+#undef ST_STATE
+};
 
+/* Add extern struct declarations. */
+#define ST_STATE(FLAG, st_update) extern const struct st_tracked_state st_update;
+#include "st_atom_list.h"
+#undef ST_STATE
 
-GLuint st_compare_func_to_pipe(GLenum func);
+/* Combined state flags. */
+#define ST_NEW_SAMPLERS         (ST_NEW_RENDER_SAMPLERS | \
+                                 ST_NEW_CS_SAMPLERS)
 
-enum pipe_format
-st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
-                      GLboolean normalized, GLboolean integer);
+#define ST_NEW_FRAMEBUFFER      (ST_NEW_FB_STATE | \
+                                 ST_NEW_SAMPLE_MASK | \
+                                 ST_NEW_SAMPLE_SHADING)
+
+#define ST_NEW_VERTEX_PROGRAM   (ST_NEW_VS_STATE | \
+                                 ST_NEW_VS_SAMPLER_VIEWS | \
+                                 ST_NEW_VS_IMAGES | \
+                                 ST_NEW_VS_CONSTANTS | \
+                                 ST_NEW_VS_UBOS | \
+                                 ST_NEW_VS_ATOMICS | \
+                                 ST_NEW_VS_SSBOS | \
+                                 ST_NEW_VERTEX_ARRAYS | \
+                                 ST_NEW_CLIP_STATE | \
+                                 ST_NEW_RASTERIZER)
+
+#define ST_NEW_TESSCTRL_PROGRAM (ST_NEW_TCS_STATE | \
+                                 ST_NEW_TCS_SAMPLER_VIEWS | \
+                                 ST_NEW_TCS_IMAGES | \
+                                 ST_NEW_TCS_CONSTANTS | \
+                                 ST_NEW_TCS_UBOS | \
+                                 ST_NEW_TCS_ATOMICS | \
+                                 ST_NEW_TCS_SSBOS)
+
+#define ST_NEW_TESSEVAL_PROGRAM (ST_NEW_TES_STATE | \
+                                 ST_NEW_TES_SAMPLER_VIEWS | \
+                                 ST_NEW_TES_IMAGES | \
+                                 ST_NEW_TES_CONSTANTS | \
+                                 ST_NEW_TES_UBOS | \
+                                 ST_NEW_TES_ATOMICS | \
+                                 ST_NEW_TES_SSBOS | \
+                                 ST_NEW_RASTERIZER)
+
+#define ST_NEW_GEOMETRY_PROGRAM (ST_NEW_GS_STATE | \
+                                 ST_NEW_GS_SAMPLER_VIEWS | \
+                                 ST_NEW_GS_IMAGES | \
+                                 ST_NEW_GS_CONSTANTS | \
+                                 ST_NEW_GS_UBOS | \
+                                 ST_NEW_GS_ATOMICS | \
+                                 ST_NEW_GS_SSBOS | \
+                                 ST_NEW_RASTERIZER)
+
+#define ST_NEW_FRAGMENT_PROGRAM (ST_NEW_FS_STATE | \
+                                 ST_NEW_FS_SAMPLER_VIEWS | \
+                                 ST_NEW_FS_IMAGES | \
+                                 ST_NEW_FS_CONSTANTS | \
+                                 ST_NEW_FS_UBOS | \
+                                 ST_NEW_FS_ATOMICS | \
+                                 ST_NEW_FS_SSBOS | \
+                                 ST_NEW_SAMPLE_SHADING)
+
+#define ST_NEW_COMPUTE_PROGRAM  (ST_NEW_CS_STATE | \
+                                 ST_NEW_CS_SAMPLER_VIEWS | \
+                                 ST_NEW_CS_IMAGES | \
+                                 ST_NEW_CS_CONSTANTS | \
+                                 ST_NEW_CS_UBOS | \
+                                 ST_NEW_CS_ATOMICS | \
+                                 ST_NEW_CS_SSBOS)
+
+#define ST_NEW_CONSTANTS        (ST_NEW_VS_CONSTANTS | \
+                                 ST_NEW_TCS_CONSTANTS | \
+                                 ST_NEW_TES_CONSTANTS | \
+                                 ST_NEW_FS_CONSTANTS | \
+                                 ST_NEW_GS_CONSTANTS | \
+                                 ST_NEW_CS_CONSTANTS)
+
+#define ST_NEW_UNIFORM_BUFFER   (ST_NEW_VS_UBOS | \
+                                 ST_NEW_TCS_UBOS | \
+                                 ST_NEW_TES_UBOS | \
+                                 ST_NEW_FS_UBOS | \
+                                 ST_NEW_GS_UBOS | \
+                                 ST_NEW_CS_UBOS)
+
+#define ST_NEW_SAMPLER_VIEWS    (ST_NEW_VS_SAMPLER_VIEWS | \
+                                 ST_NEW_FS_SAMPLER_VIEWS | \
+                                 ST_NEW_GS_SAMPLER_VIEWS | \
+                                 ST_NEW_TCS_SAMPLER_VIEWS | \
+                                 ST_NEW_TES_SAMPLER_VIEWS | \
+                                 ST_NEW_CS_SAMPLER_VIEWS)
+
+#define ST_NEW_ATOMIC_BUFFER    (ST_NEW_VS_ATOMICS | \
+                                 ST_NEW_TCS_ATOMICS | \
+                                 ST_NEW_TES_ATOMICS | \
+                                 ST_NEW_FS_ATOMICS | \
+                                 ST_NEW_GS_ATOMICS | \
+                                 ST_NEW_CS_ATOMICS)
+
+#define ST_NEW_STORAGE_BUFFER   (ST_NEW_VS_SSBOS | \
+                                 ST_NEW_TCS_SSBOS | \
+                                 ST_NEW_TES_SSBOS | \
+                                 ST_NEW_FS_SSBOS | \
+                                 ST_NEW_GS_SSBOS | \
+                                 ST_NEW_CS_SSBOS)
+
+#define ST_NEW_IMAGE_UNITS      (ST_NEW_VS_IMAGES | \
+                                 ST_NEW_TCS_IMAGES | \
+                                 ST_NEW_TES_IMAGES | \
+                                 ST_NEW_GS_IMAGES | \
+                                 ST_NEW_FS_IMAGES | \
+                                 ST_NEW_CS_IMAGES)
+
+/* All state flags within each group: */
+#define ST_PIPELINE_RENDER_STATE_MASK  (ST_NEW_CS_STATE - 1)
+#define ST_PIPELINE_COMPUTE_STATE_MASK (ST_NEW_COMPUTE_PROGRAM | \
+                                        ST_NEW_CS_SAMPLERS)
+
+#define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
+                            ST_PIPELINE_COMPUTE_STATE_MASK)
 
 #endif
index 992d6a961efa6e375e54155b051fad0ee33620bd..dcead27ea3640354aafd3cc0b0381b9da506293f 100644 (file)
@@ -690,9 +690,5 @@ static void update_array(struct st_context *st)
 
 
 const struct st_tracked_state st_update_array = {
-   {                                                   /* dirty */
-      _NEW_CURRENT_ATTRIB,                              /* mesa */
-      ST_NEW_VERTEX_ARRAYS | ST_NEW_VERTEX_PROGRAM,     /* st */
-   },
    update_array                                                /* update */
 };
index d4380710af944b4c40f894247490edbed6b44acd..7dde76a77f1ab8980f95f2ba3e217b384f034053 100644 (file)
@@ -79,10 +79,6 @@ bind_vs_atomics(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_vs_atomics = {
-   {
-      0,
-      ST_NEW_VERTEX_PROGRAM | ST_NEW_ATOMIC_BUFFER,
-   },
    bind_vs_atomics
 };
 
@@ -96,10 +92,6 @@ bind_fs_atomics(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_fs_atomics = {
-   {
-      0,
-      ST_NEW_FRAGMENT_PROGRAM | ST_NEW_ATOMIC_BUFFER,
-   },
    bind_fs_atomics
 };
 
@@ -113,10 +105,6 @@ bind_gs_atomics(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_gs_atomics = {
-   {
-      0,
-      ST_NEW_GEOMETRY_PROGRAM | ST_NEW_ATOMIC_BUFFER,
-   },
    bind_gs_atomics
 };
 
@@ -130,10 +118,6 @@ bind_tcs_atomics(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_tcs_atomics = {
-   {
-      0,
-      ST_NEW_TESSCTRL_PROGRAM | ST_NEW_ATOMIC_BUFFER,
-   },
    bind_tcs_atomics
 };
 
@@ -147,10 +131,6 @@ bind_tes_atomics(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_tes_atomics = {
-   {
-      0,
-      ST_NEW_TESSEVAL_PROGRAM | ST_NEW_ATOMIC_BUFFER,
-   },
    bind_tes_atomics
 };
 
@@ -164,9 +144,5 @@ bind_cs_atomics(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_cs_atomics = {
-   {
-      0,
-      ST_NEW_COMPUTE_PROGRAM | ST_NEW_ATOMIC_BUFFER,
-   },
    bind_cs_atomics
 };
index 8adda10c6b823425173c3dea2266ebc52d6162f6..65de67bb6c406caab6f698d7a75da2c138640a12 100644 (file)
@@ -283,9 +283,5 @@ update_blend( struct st_context *st )
 
 
 const struct st_tracked_state st_update_blend = {
-   {                                                   /* dirty */
-      (_NEW_COLOR | _NEW_MULTISAMPLE),  /* XXX _NEW_BLEND someday? */  /* mesa */
-      0,                                               /* st */
-   },
    update_blend,                                       /* update */
 };
index 657aa84ed32609f29973eb15ef80566d39261c2b..9d2870fa3f5724a7a45cc45a724bc2cc1cc52b19 100644 (file)
@@ -71,9 +71,5 @@ static void update_clip( struct st_context *st )
 
 
 const struct st_tracked_state st_update_clip = {
-   {                                                   /* dirty */
-      _NEW_TRANSFORM | _NEW_PROJECTION,                 /* mesa */
-      ST_NEW_VERTEX_PROGRAM,                           /* st */
-   },
    update_clip                                         /* update */
 };
index a9ec19581c68ab040f0cfadcc3a0ff0077c61d89..8ffb6c3db4ffb09fde37ab56362aa5efd3b8e8b3 100644 (file)
@@ -145,10 +145,6 @@ static void update_vs_constants(struct st_context *st )
 
 
 const struct st_tracked_state st_update_vs_constants = {
-   {                                                   /* dirty */
-      _NEW_PROGRAM_CONSTANTS,                           /* mesa */
-      ST_NEW_VERTEX_PROGRAM,                           /* st */
-   },
    update_vs_constants                                 /* update */
 };
 
@@ -167,10 +163,6 @@ static void update_fs_constants(struct st_context *st )
 
 
 const struct st_tracked_state st_update_fs_constants = {
-   {                                                   /* dirty */
-      _NEW_PROGRAM_CONSTANTS,                           /* mesa */
-      ST_NEW_FRAGMENT_PROGRAM,                         /* st */
-   },
    update_fs_constants                                 /* update */
 };
 
@@ -188,10 +180,6 @@ static void update_gs_constants(struct st_context *st )
 }
 
 const struct st_tracked_state st_update_gs_constants = {
-   {                                                   /* dirty */
-      _NEW_PROGRAM_CONSTANTS,                           /* mesa */
-      ST_NEW_GEOMETRY_PROGRAM,                         /* st */
-   },
    update_gs_constants                                 /* update */
 };
 
@@ -209,10 +197,6 @@ static void update_tcs_constants(struct st_context *st )
 }
 
 const struct st_tracked_state st_update_tcs_constants = {
-   {                                                   /* dirty */
-      _NEW_PROGRAM_CONSTANTS,                           /* mesa */
-      ST_NEW_TESSCTRL_PROGRAM,                         /* st */
-   },
    update_tcs_constants                                        /* update */
 };
 
@@ -230,10 +214,6 @@ static void update_tes_constants(struct st_context *st )
 }
 
 const struct st_tracked_state st_update_tes_constants = {
-   {                                                   /* dirty */
-      _NEW_PROGRAM_CONSTANTS,                           /* mesa */
-      ST_NEW_TESSEVAL_PROGRAM,                         /* st */
-   },
    update_tes_constants                                        /* update */
 };
 
@@ -251,10 +231,6 @@ static void update_cs_constants(struct st_context *st )
 }
 
 const struct st_tracked_state st_update_cs_constants = {
-   {                                                   /* dirty */
-      _NEW_PROGRAM_CONSTANTS,                           /* mesa */
-      ST_NEW_COMPUTE_PROGRAM,                          /* st */
-   },
    update_cs_constants                                 /* update */
 };
 
@@ -308,10 +284,6 @@ static void bind_vs_ubos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_vs_ubos = {
-   {
-      0,
-      ST_NEW_VERTEX_PROGRAM | ST_NEW_UNIFORM_BUFFER,
-   },
    bind_vs_ubos
 };
 
@@ -327,10 +299,6 @@ static void bind_fs_ubos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_fs_ubos = {
-   {
-      0,
-      ST_NEW_FRAGMENT_PROGRAM | ST_NEW_UNIFORM_BUFFER,
-   },
    bind_fs_ubos
 };
 
@@ -346,10 +314,6 @@ static void bind_gs_ubos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_gs_ubos = {
-   {
-      0,
-      ST_NEW_GEOMETRY_PROGRAM | ST_NEW_UNIFORM_BUFFER,
-   },
    bind_gs_ubos
 };
 
@@ -365,10 +329,6 @@ static void bind_tcs_ubos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_tcs_ubos = {
-   {
-      0,
-      ST_NEW_TESSCTRL_PROGRAM | ST_NEW_UNIFORM_BUFFER,
-   },
    bind_tcs_ubos
 };
 
@@ -384,10 +344,6 @@ static void bind_tes_ubos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_tes_ubos = {
-   {
-      0,
-      ST_NEW_TESSEVAL_PROGRAM | ST_NEW_UNIFORM_BUFFER,
-   },
    bind_tes_ubos
 };
 
@@ -404,9 +360,5 @@ static void bind_cs_ubos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_cs_ubos = {
-   {
-      0,
-      ST_NEW_COMPUTE_PROGRAM | ST_NEW_UNIFORM_BUFFER,
-   },
    bind_cs_ubos
 };
index ec8480bfd83c8f7952d087a597bef3189450a763..267b42c539f50709f223d1116de2c9de5aca3215 100644 (file)
@@ -161,9 +161,5 @@ update_depth_stencil_alpha(struct st_context *st)
 
 
 const struct st_tracked_state st_update_depth_stencil_alpha = {
-   {                                                   /* dirty */
-      (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR|_NEW_BUFFERS),/* mesa */
-      0,                                               /* st */
-   },
    update_depth_stencil_alpha                          /* update */
 };
index 5d91704a05c3fb1eba1ec259d69b5f1b7f3b9f43..ea41d9dcd763b94ddd137fb04a337e10887a84fe 100644 (file)
@@ -215,10 +215,6 @@ update_framebuffer_state( struct st_context *st )
 
 
 const struct st_tracked_state st_update_framebuffer = {
-   {                                                   /* dirty */
-      _NEW_BUFFERS,                                    /* mesa */
-      ST_NEW_FRAMEBUFFER,                              /* st */
-   },
    update_framebuffer_state                            /* update */
 };
 
index a170de0dd8a575d125ebaee4b68137135d48dde6..e80fc14bf4163685ff0e5c5bce3aa66d895dadc0 100644 (file)
@@ -146,10 +146,6 @@ static void bind_vs_images(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_vs_images = {
-   {
-      _NEW_TEXTURE,
-      ST_NEW_VERTEX_PROGRAM | ST_NEW_IMAGE_UNITS,
-   },
    bind_vs_images
 };
 
@@ -165,10 +161,6 @@ static void bind_fs_images(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_fs_images = {
-   {
-      _NEW_TEXTURE,
-      ST_NEW_FRAGMENT_PROGRAM | ST_NEW_IMAGE_UNITS,
-   },
    bind_fs_images
 };
 
@@ -184,10 +176,6 @@ static void bind_gs_images(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_gs_images = {
-   {
-      _NEW_TEXTURE,
-      ST_NEW_GEOMETRY_PROGRAM | ST_NEW_IMAGE_UNITS,
-   },
    bind_gs_images
 };
 
@@ -203,10 +191,6 @@ static void bind_tcs_images(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_tcs_images = {
-   {
-      _NEW_TEXTURE,
-      ST_NEW_TESSCTRL_PROGRAM | ST_NEW_IMAGE_UNITS,
-   },
    bind_tcs_images
 };
 
@@ -222,10 +206,6 @@ static void bind_tes_images(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_tes_images = {
-   {
-      _NEW_TEXTURE,
-      ST_NEW_TESSEVAL_PROGRAM | ST_NEW_IMAGE_UNITS,
-   },
    bind_tes_images
 };
 
@@ -241,9 +221,5 @@ static void bind_cs_images(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_cs_images = {
-   {
-      _NEW_TEXTURE,
-      ST_NEW_COMPUTE_PROGRAM | ST_NEW_IMAGE_UNITS,
-   },
    bind_cs_images
 };
diff --git a/src/mesa/state_tracker/st_atom_list.h b/src/mesa/state_tracker/st_atom_list.h
new file mode 100644 (file)
index 0000000..d0d5a05
--- /dev/null
@@ -0,0 +1,75 @@
+/* Render (non-compute) states must be first. */
+ST_STATE(ST_NEW_DSA, st_update_depth_stencil_alpha)
+ST_STATE(ST_NEW_CLIP_STATE, st_update_clip)
+
+ST_STATE(ST_NEW_FS_STATE, st_update_fp)
+ST_STATE(ST_NEW_GS_STATE, st_update_gp)
+ST_STATE(ST_NEW_TES_STATE, st_update_tep)
+ST_STATE(ST_NEW_TCS_STATE, st_update_tcp)
+ST_STATE(ST_NEW_VS_STATE, st_update_vp)
+
+ST_STATE(ST_NEW_RASTERIZER, st_update_rasterizer)
+ST_STATE(ST_NEW_POLY_STIPPLE, st_update_polygon_stipple)
+ST_STATE(ST_NEW_VIEWPORT, st_update_viewport)
+ST_STATE(ST_NEW_SCISSOR, st_update_scissor)
+ST_STATE(ST_NEW_WINDOW_RECTANGLES, st_update_window_rectangles)
+ST_STATE(ST_NEW_BLEND, st_update_blend)
+
+ST_STATE(ST_NEW_VS_SAMPLER_VIEWS, st_update_vertex_texture)
+ST_STATE(ST_NEW_FS_SAMPLER_VIEWS, st_update_fragment_texture)
+ST_STATE(ST_NEW_GS_SAMPLER_VIEWS, st_update_geometry_texture)
+ST_STATE(ST_NEW_TCS_SAMPLER_VIEWS, st_update_tessctrl_texture)
+ST_STATE(ST_NEW_TES_SAMPLER_VIEWS, st_update_tesseval_texture)
+
+/* Non-compute samplers. */
+ST_STATE(ST_NEW_RENDER_SAMPLERS, st_update_sampler) /* depends on update_*_texture for swizzle */
+
+ST_STATE(ST_NEW_VS_IMAGES, st_bind_vs_images)
+ST_STATE(ST_NEW_TCS_IMAGES, st_bind_tcs_images)
+ST_STATE(ST_NEW_TES_IMAGES, st_bind_tes_images)
+ST_STATE(ST_NEW_GS_IMAGES, st_bind_gs_images)
+ST_STATE(ST_NEW_FS_IMAGES, st_bind_fs_images)
+
+ST_STATE(ST_NEW_FB_STATE, st_update_framebuffer) /* depends on update_*_texture and bind_*_images */
+ST_STATE(ST_NEW_SAMPLE_MASK, st_update_msaa)
+ST_STATE(ST_NEW_SAMPLE_SHADING, st_update_sample_shading)
+
+ST_STATE(ST_NEW_VS_CONSTANTS, st_update_vs_constants)
+ST_STATE(ST_NEW_TCS_CONSTANTS, st_update_tcs_constants)
+ST_STATE(ST_NEW_TES_CONSTANTS, st_update_tes_constants)
+ST_STATE(ST_NEW_GS_CONSTANTS, st_update_gs_constants)
+ST_STATE(ST_NEW_FS_CONSTANTS, st_update_fs_constants)
+
+ST_STATE(ST_NEW_VS_UBOS, st_bind_vs_ubos)
+ST_STATE(ST_NEW_TCS_UBOS, st_bind_tcs_ubos)
+ST_STATE(ST_NEW_TES_UBOS, st_bind_tes_ubos)
+ST_STATE(ST_NEW_FS_UBOS, st_bind_fs_ubos)
+ST_STATE(ST_NEW_GS_UBOS, st_bind_gs_ubos)
+
+ST_STATE(ST_NEW_VS_ATOMICS, st_bind_vs_atomics)
+ST_STATE(ST_NEW_TCS_ATOMICS, st_bind_tcs_atomics)
+ST_STATE(ST_NEW_TES_ATOMICS, st_bind_tes_atomics)
+ST_STATE(ST_NEW_FS_ATOMICS, st_bind_fs_atomics)
+ST_STATE(ST_NEW_GS_ATOMICS, st_bind_gs_atomics)
+
+ST_STATE(ST_NEW_VS_SSBOS, st_bind_vs_ssbos)
+ST_STATE(ST_NEW_TCS_SSBOS, st_bind_tcs_ssbos)
+ST_STATE(ST_NEW_TES_SSBOS, st_bind_tes_ssbos)
+ST_STATE(ST_NEW_FS_SSBOS, st_bind_fs_ssbos)
+ST_STATE(ST_NEW_GS_SSBOS, st_bind_gs_ssbos)
+
+ST_STATE(ST_NEW_PIXEL_TRANSFER, st_update_pixel_transfer)
+ST_STATE(ST_NEW_TESS_STATE, st_update_tess)
+
+/* this must be done after the vertex program update */
+ST_STATE(ST_NEW_VERTEX_ARRAYS, st_update_array)
+
+/* Compute states must be last. */
+ST_STATE(ST_NEW_CS_STATE, st_update_cp)
+ST_STATE(ST_NEW_CS_SAMPLER_VIEWS, st_update_compute_texture)
+ST_STATE(ST_NEW_CS_SAMPLERS, st_update_sampler) /* depends on update_compute_texture for swizzle */
+ST_STATE(ST_NEW_CS_CONSTANTS, st_update_cs_constants)
+ST_STATE(ST_NEW_CS_UBOS, st_bind_cs_ubos)
+ST_STATE(ST_NEW_CS_ATOMICS, st_bind_cs_atomics)
+ST_STATE(ST_NEW_CS_SSBOS, st_bind_cs_ssbos)
+ST_STATE(ST_NEW_CS_IMAGES, st_bind_cs_images)
index 3025534b2c9eaf1c141ab4ad646ace9ca1e65e13..8442a2860f6c46427ab2c80bb71414e6c421470a 100644 (file)
@@ -86,17 +86,9 @@ static void update_sample_shading( struct st_context *st )
 }
 
 const struct st_tracked_state st_update_msaa = {
-   {                                                   /* dirty */
-      (_NEW_MULTISAMPLE | _NEW_BUFFERS),               /* mesa */
-      ST_NEW_FRAMEBUFFER,                              /* st */
-   },
    update_sample_mask                                  /* update */
 };
 
 const struct st_tracked_state st_update_sample_shading = {
-   {                                                   /* dirty */
-      (_NEW_MULTISAMPLE | _NEW_PROGRAM | _NEW_BUFFERS),        /* mesa */
-      ST_NEW_FRAGMENT_PROGRAM | ST_NEW_FRAMEBUFFER,    /* st */
-   },
    update_sample_shading                               /* update */
 };
index a56ff10954cb10bd99271eb9a650063302627df2..26d8adec3a2cf4c78d98fd51a4c5aa921bb0c9d4 100644 (file)
@@ -102,9 +102,5 @@ update_pixel_transfer(struct st_context *st)
 
 
 const struct st_tracked_state st_update_pixel_transfer = {
-   {                                                   /* dirty */
-      _NEW_PIXEL,                                      /* mesa */
-      0,                                               /* st */
-   },
    update_pixel_transfer                               /* update */
 };
index 463a210516a014e5fd14ecffa589377b513f51f1..ca975aafddee8edf2338281172d96cc2077107b6 100644 (file)
@@ -290,21 +290,5 @@ static void update_raster_state( struct st_context *st )
 }
 
 const struct st_tracked_state st_update_rasterizer = {
-   {
-      (_NEW_BUFFERS |
-       _NEW_LIGHT |
-       _NEW_LINE |
-       _NEW_MULTISAMPLE |
-       _NEW_POINT |
-       _NEW_POLYGON |
-       _NEW_PROGRAM |
-       _NEW_SCISSOR |
-       _NEW_FRAG_CLAMP |
-       _NEW_TRANSFORM),     /* mesa state dependencies*/
-      (ST_NEW_VERTEX_PROGRAM |
-       ST_NEW_TESSEVAL_PROGRAM |
-       ST_NEW_GEOMETRY_PROGRAM |
-       ST_NEW_RASTERIZER),  /* state tracker dependencies */
-   },
    update_raster_state     /* update function */
 };
index a9e14f8efbccdf268db7dffb8a4d7482a77e5959..88ae7a09e464d7525761b05ca4ba3ecd2ba020a2 100644 (file)
@@ -334,9 +334,5 @@ update_samplers(struct st_context *st)
 
 
 const struct st_tracked_state st_update_sampler = {
-   {                                                   /* dirty */
-      _NEW_TEXTURE,                                    /* mesa */
-      0,                                               /* st */
-   },
    update_samplers                                     /* update */
 };
index fb13077b55ecd9bedf37500e039de0a3c9ef1044..fb478a3987c37db5bb76ece6f6f3593beee9fec2 100644 (file)
@@ -141,17 +141,9 @@ update_window_rectangles(struct st_context *st)
 }
 
 const struct st_tracked_state st_update_scissor = {
-   {                                                   /* dirty */
-      (_NEW_SCISSOR | _NEW_BUFFERS),                   /* mesa */
-      0,                                               /* st */
-   },
    update_scissor                                      /* update */
 };
 
 const struct st_tracked_state st_update_window_rectangles = {
-   {                                                   /* dirty */
-      (_NEW_SCISSOR | _NEW_BUFFERS),                   /* mesa */
-      0,                                               /* st */
-   },
    update_window_rectangles                            /* update */
 };
index 0bb229579263d1a57c5c2680a4544978407f8e8a..b3401c48d52b2adc81b55fadb6206f5103f2f8bb 100644 (file)
@@ -152,10 +152,6 @@ update_fp( struct st_context *st )
 
 
 const struct st_tracked_state st_update_fp = {
-   {                                                   /* dirty */
-      _NEW_BUFFERS | _NEW_MULTISAMPLE | _NEW_FOG,      /* mesa */
-      ST_NEW_FRAGMENT_PROGRAM                           /* st */
-   },
    update_fp                                   /* update */
 };
 
@@ -209,10 +205,6 @@ update_vp( struct st_context *st )
 
 
 const struct st_tracked_state st_update_vp = {
-   {                                                   /* dirty */
-      0,                                                /* mesa */
-      ST_NEW_VERTEX_PROGRAM                             /* st */
-   },
    update_vp                                           /* update */
 };
 
@@ -241,10 +233,6 @@ update_gp( struct st_context *st )
 }
 
 const struct st_tracked_state st_update_gp = {
-   {                                   /* dirty */
-      0,                               /* mesa */
-      ST_NEW_GEOMETRY_PROGRAM           /* st */
-   },
    update_gp                           /* update */
 };
 
@@ -273,10 +261,6 @@ update_tcp( struct st_context *st )
 }
 
 const struct st_tracked_state st_update_tcp = {
-   {                                   /* dirty */
-      0,                               /* mesa */
-      ST_NEW_TESSCTRL_PROGRAM           /* st */
-   },
    update_tcp                                  /* update */
 };
 
@@ -305,10 +289,6 @@ update_tep( struct st_context *st )
 }
 
 const struct st_tracked_state st_update_tep = {
-   {                                   /* dirty */
-      0,                               /* mesa */
-      ST_NEW_TESSEVAL_PROGRAM           /* st */
-   },
    update_tep                                  /* update */
 };
 
@@ -336,9 +316,5 @@ update_cp( struct st_context *st )
 }
 
 const struct st_tracked_state st_update_cp = {
-   {                                   /* dirty */
-      0,                               /* mesa */
-      ST_NEW_COMPUTE_PROGRAM           /* st */
-   },
    update_cp                           /* update */
 };
index b059ca97776a63e8d27505387278ad27f45a1261..a30215ff326ab4163fbdb1f66ac277a45763a888 100644 (file)
@@ -84,10 +84,5 @@ update_stipple( struct st_context *st )
 
 /** Update the stipple when the pattern or window height changes */
 const struct st_tracked_state st_update_polygon_stipple = {
-   {                                                   /* dirty */
-      (_NEW_POLYGONSTIPPLE |
-       _NEW_BUFFERS),                                  /* mesa */
-      0,                                               /* st */
-   },
    update_stipple                                      /* update */
 };
index 2ee57657435542f6913d5de92a33ac6057eb9a42..a5a760e5ac0bca863586baf1541e31701b7b726d 100644 (file)
@@ -103,10 +103,6 @@ static void bind_vs_ssbos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_vs_ssbos = {
-   {
-      0,
-      ST_NEW_VERTEX_PROGRAM | ST_NEW_STORAGE_BUFFER,
-   },
    bind_vs_ssbos
 };
 
@@ -123,10 +119,6 @@ static void bind_fs_ssbos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_fs_ssbos = {
-   {
-      0,
-      ST_NEW_FRAGMENT_PROGRAM | ST_NEW_STORAGE_BUFFER,
-   },
    bind_fs_ssbos
 };
 
@@ -143,10 +135,6 @@ static void bind_gs_ssbos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_gs_ssbos = {
-   {
-      0,
-      ST_NEW_GEOMETRY_PROGRAM | ST_NEW_STORAGE_BUFFER,
-   },
    bind_gs_ssbos
 };
 
@@ -163,10 +151,6 @@ static void bind_tcs_ssbos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_tcs_ssbos = {
-   {
-      0,
-      ST_NEW_TESSCTRL_PROGRAM | ST_NEW_STORAGE_BUFFER,
-   },
    bind_tcs_ssbos
 };
 
@@ -183,10 +167,6 @@ static void bind_tes_ssbos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_tes_ssbos = {
-   {
-      0,
-      ST_NEW_TESSEVAL_PROGRAM | ST_NEW_STORAGE_BUFFER,
-   },
    bind_tes_ssbos
 };
 
@@ -203,9 +183,5 @@ static void bind_cs_ssbos(struct st_context *st)
 }
 
 const struct st_tracked_state st_bind_cs_ssbos = {
-   {
-      0,
-      ST_NEW_COMPUTE_PROGRAM | ST_NEW_STORAGE_BUFFER,
-   },
    bind_cs_ssbos
 };
index 5c1e3a9870eaf3fb819c65216feaeb7e673443a8..103e41d1ea21e04e3e6f64d55ae02c25f83df298 100644 (file)
@@ -53,9 +53,5 @@ update_tess(struct st_context *st)
 
 
 const struct st_tracked_state st_update_tess = {
-   {                           /* dirty */
-      0,                       /* mesa */
-      ST_NEW_TESS_STATE,       /* st */
-   },
    update_tess                  /* update */
 };
index ed8c2d3e078223b75c10964dc1df426a8bc817fa..923cb93fefd3f6d392b5380b08256a8caafd5a7e 100644 (file)
@@ -565,54 +565,30 @@ update_compute_textures(struct st_context *st)
 
 
 const struct st_tracked_state st_update_fragment_texture = {
-   {                                                   /* dirty */
-      _NEW_TEXTURE,                                    /* mesa */
-      ST_NEW_FRAGMENT_PROGRAM | ST_NEW_SAMPLER_VIEWS,  /* st */
-   },
    update_fragment_textures                            /* update */
 };
 
 
 const struct st_tracked_state st_update_vertex_texture = {
-   {                                                   /* dirty */
-      _NEW_TEXTURE,                                    /* mesa */
-      ST_NEW_VERTEX_PROGRAM | ST_NEW_SAMPLER_VIEWS,    /* st */
-   },
    update_vertex_textures                              /* update */
 };
 
 
 const struct st_tracked_state st_update_geometry_texture = {
-   {                                                   /* dirty */
-      _NEW_TEXTURE,                                    /* mesa */
-      ST_NEW_GEOMETRY_PROGRAM | ST_NEW_SAMPLER_VIEWS,  /* st */
-   },
    update_geometry_textures                            /* update */
 };
 
 
 const struct st_tracked_state st_update_tessctrl_texture = {
-   {                                                   /* dirty */
-      _NEW_TEXTURE,                                    /* mesa */
-      ST_NEW_TESSCTRL_PROGRAM | ST_NEW_SAMPLER_VIEWS,  /* st */
-   },
    update_tessctrl_textures                            /* update */
 };
 
 
 const struct st_tracked_state st_update_tesseval_texture = {
-   {                                                   /* dirty */
-      _NEW_TEXTURE,                                    /* mesa */
-      ST_NEW_TESSEVAL_PROGRAM | ST_NEW_SAMPLER_VIEWS,  /* st */
-   },
    update_tesseval_textures                            /* update */
 };
 
 
 const struct st_tracked_state st_update_compute_texture = {
-   {                                                   /* dirty */
-      _NEW_TEXTURE,                                    /* mesa */
-      ST_NEW_COMPUTE_PROGRAM | ST_NEW_SAMPLER_VIEWS,   /* st */
-   },
    update_compute_textures                             /* update */
 };
index f5e09e26aa6d641b9498bd2686e0eb902714614e..8f750a9ff610efd074700d4dc35e7f57e688877f 100644 (file)
@@ -83,9 +83,5 @@ update_viewport( struct st_context *st )
 
 
 const struct st_tracked_state st_update_viewport = {
-   {                                                   /* dirty */
-      _NEW_BUFFERS | _NEW_VIEWPORT,                    /* mesa */
-      0,                                               /* st */
-   },
    update_viewport                                     /* update */
 };
index a1091207f3bb811ebb765bd13c0ceaf016a94d66..5765ed28cef046546c5ad9d00639e8483b77a2d2 100644 (file)
@@ -347,7 +347,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.mesa |= _NEW_PROGRAM_CONSTANTS;
+   st->dirty |= ST_NEW_FS_CONSTANTS;
 }
 
 
@@ -642,12 +642,12 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
       init_bitmap_state(st);
    }
 
-   /* We only need to validate state of the st dirty flags are set or
-    * any non-_NEW_PROGRAM_CONSTANTS mesa flags are set.  The VS we use
+   /* We only need to validate any non-ST_NEW_CONSTANTS state. The VS we use
     * for bitmap drawing uses no constants and the FS constants are
     * explicitly uploaded in the draw_bitmap_quad() function.
     */
-   if ((st->dirty.mesa & ~_NEW_PROGRAM_CONSTANTS) || st->dirty.st) {
+   if ((st->dirty | ctx->NewDriverState) & ~ST_NEW_CONSTANTS &
+       ST_PIPELINE_RENDER_STATE_MASK) {
       st_validate_state(st, ST_PIPELINE_RENDER);
    }
 
@@ -803,7 +803,7 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
    pipe_sampler_view_reference(&sv, NULL);
 
    /* We uploaded modified constants, need to invalidate them. */
-   st->dirty.mesa |= _NEW_PROGRAM_CONSTANTS;
+   st->dirty |= ST_NEW_FS_CONSTANTS;
 }
 
 
index 2d4c82148c8dd9ab458e11bfd75873e0eaa54178..6d54326d1a04fd4e027711181c5fdeb97fee77ce 100644 (file)
@@ -333,15 +333,15 @@ st_bufferobj_data(struct gl_context *ctx,
     * might be using it.
     */
    /* TODO: Add arrays to usage history */
-   st->dirty.st |= ST_NEW_VERTEX_ARRAYS;
+   st->dirty |= ST_NEW_VERTEX_ARRAYS;
    if (st_obj->Base.UsageHistory & USAGE_UNIFORM_BUFFER)
-      st->dirty.st |= ST_NEW_UNIFORM_BUFFER;
+      st->dirty |= ST_NEW_UNIFORM_BUFFER;
    if (st_obj->Base.UsageHistory & USAGE_SHADER_STORAGE_BUFFER)
-      st->dirty.st |= ST_NEW_STORAGE_BUFFER;
+      st->dirty |= ST_NEW_STORAGE_BUFFER;
    if (st_obj->Base.UsageHistory & USAGE_TEXTURE_BUFFER)
-      st->dirty.st |= ST_NEW_SAMPLER_VIEWS | ST_NEW_IMAGE_UNITS;
+      st->dirty |= ST_NEW_SAMPLER_VIEWS | ST_NEW_IMAGE_UNITS;
    if (st_obj->Base.UsageHistory & USAGE_ATOMIC_COUNTER_BUFFER)
-      st->dirty.st |= ST_NEW_ATOMIC_BUFFER;
+      st->dirty |= ST_NEW_ATOMIC_BUFFER;
 
    return GL_TRUE;
 }
index c057a781026697b0e055215db27e01d11fb97f5d..677507da2b8adf7900d8564b7c8aa5e604d4967c 100644 (file)
@@ -51,7 +51,7 @@ static void st_dispatch_compute_common(struct gl_context *ctx,
    if (ctx->NewState)
       _mesa_update_state(ctx);
 
-   if (st->dirty_cp.st || st->dirty_cp.mesa || ctx->NewDriverState)
+   if ((st->dirty | ctx->NewDriverState) & ST_PIPELINE_COMPUTE_STATE_MASK)
       st_validate_state(st, ST_PIPELINE_COMPUTE);
 
    for (unsigned i = 0; i < 3; i++) {
index c5410886a90c01dbfb1ffb50b1aca93f6f37e882..735e268be870faf8ed93e3137b111a53339ddab1 100644 (file)
@@ -294,7 +294,7 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
       /* Plug in new vbo draw function */
       vbo_set_draw_func(ctx, st_feedback_draw_vbo);
       /* need to generate/use a vertex program that emits pos/color/tex */
-      st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+      st->dirty |= ST_NEW_VERTEX_PROGRAM;
    }
 }
 
index d79cfe239e43d9712dcd3adb99d47073d6947220..62648964f55b43ca0ebcdd35598538a3ffc5f867 100644 (file)
@@ -61,22 +61,22 @@ st_bind_program(struct gl_context *ctx, GLenum target, struct gl_program *prog)
 
    switch (target) {
    case GL_VERTEX_PROGRAM_ARB: 
-      st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+      st->dirty |= ST_NEW_VERTEX_PROGRAM;
       break;
    case GL_FRAGMENT_PROGRAM_ARB:
-      st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
+      st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
       break;
    case GL_GEOMETRY_PROGRAM_NV:
-      st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
+      st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
       break;
    case GL_TESS_CONTROL_PROGRAM_NV:
-      st->dirty.st |= ST_NEW_TESSCTRL_PROGRAM;
+      st->dirty |= ST_NEW_TESSCTRL_PROGRAM;
       break;
    case GL_TESS_EVALUATION_PROGRAM_NV:
-      st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
+      st->dirty |= ST_NEW_TESSEVAL_PROGRAM;
       break;
    case GL_COMPUTE_PROGRAM_NV:
-      st->dirty_cp.st |= ST_NEW_COMPUTE_PROGRAM;
+      st->dirty |= ST_NEW_COMPUTE_PROGRAM;
       break;
    }
 }
@@ -91,12 +91,12 @@ st_use_program(struct gl_context *ctx, struct gl_shader_program *shProg)
 {
    struct st_context *st = st_context(ctx);
 
-   st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
-   st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
-   st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
-   st->dirty.st |= ST_NEW_TESSCTRL_PROGRAM;
-   st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
-   st->dirty_cp.st |= ST_NEW_COMPUTE_PROGRAM;
+   st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
+   st->dirty |= ST_NEW_VERTEX_PROGRAM;
+   st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
+   st->dirty |= ST_NEW_TESSCTRL_PROGRAM;
+   st->dirty |= ST_NEW_TESSEVAL_PROGRAM;
+   st->dirty |= ST_NEW_COMPUTE_PROGRAM;
 }
 
 
@@ -245,7 +245,7 @@ st_program_string_notify( struct gl_context *ctx,
          return false;
 
       if (st->fp == stfp)
-        st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
+        st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
    }
    else if (target == GL_GEOMETRY_PROGRAM_NV) {
       struct st_geometry_program *stgp = (struct st_geometry_program *) prog;
@@ -256,7 +256,7 @@ st_program_string_notify( struct gl_context *ctx,
          return false;
 
       if (st->gp == stgp)
-        st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
+        st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
    }
    else if (target == GL_VERTEX_PROGRAM_ARB) {
       struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
@@ -266,7 +266,7 @@ st_program_string_notify( struct gl_context *ctx,
          return false;
 
       if (st->vp == stvp)
-        st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+        st->dirty |= ST_NEW_VERTEX_PROGRAM;
    }
    else if (target == GL_TESS_CONTROL_PROGRAM_NV) {
       struct st_tessctrl_program *sttcp =
@@ -278,7 +278,7 @@ st_program_string_notify( struct gl_context *ctx,
          return false;
 
       if (st->tcp == sttcp)
-         st->dirty.st |= ST_NEW_TESSCTRL_PROGRAM;
+         st->dirty |= ST_NEW_TESSCTRL_PROGRAM;
    }
    else if (target == GL_TESS_EVALUATION_PROGRAM_NV) {
       struct st_tesseval_program *sttep =
@@ -290,7 +290,7 @@ st_program_string_notify( struct gl_context *ctx,
          return false;
 
       if (st->tep == sttep)
-         st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
+         st->dirty |= ST_NEW_TESSEVAL_PROGRAM;
    }
    else if (target == GL_COMPUTE_PROGRAM_NV) {
       struct st_compute_program *stcp =
@@ -301,7 +301,7 @@ st_program_string_notify( struct gl_context *ctx,
          return false;
 
       if (st->cp == stcp)
-         st->dirty_cp.st |= ST_NEW_COMPUTE_PROGRAM;
+         st->dirty |= ST_NEW_COMPUTE_PROGRAM;
    }
    else if (target == GL_FRAGMENT_SHADER_ATI) {
       assert(prog);
@@ -317,7 +317,7 @@ st_program_string_notify( struct gl_context *ctx,
          return false;
 
       if (st->fp == stfp)
-         st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
+         st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
    }
 
    if (ST_DEBUG & DEBUG_PRECOMPILE ||
index d2acc71b81c8ae18101595be6c533b053c21de82..ab061956f8524d11dbf38ab2e45a999b6cd65891 100644 (file)
@@ -2540,7 +2540,7 @@ st_finalize_texture(struct gl_context *ctx,
           */
          pipe_resource_reference(&stObj->pt, NULL);
          st_texture_release_all_sampler_views(st, stObj);
-         st->dirty.st |= ST_NEW_FRAMEBUFFER;
+         st->dirty |= ST_NEW_FRAMEBUFFER;
       }
    }
 
index f1d2084d6bbfecc0cd2d21f559e0f94f96491cf4..911bec6c52bae28f46354f4e2f466dc233de147d 100644 (file)
@@ -130,20 +130,94 @@ void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state)
 {
    struct st_context *st = st_context(ctx);
 
-   /* Replace _NEW_FRAG_CLAMP with ST_NEW_FRAGMENT_PROGRAM for the fallback. */
-   if (st->clamp_frag_color_in_shader && (new_state & _NEW_FRAG_CLAMP)) {
-      new_state &= ~_NEW_FRAG_CLAMP;
-      st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
+   if (new_state & _NEW_BUFFERS) {
+      st->dirty |= ST_NEW_DSA |
+                   ST_NEW_FB_STATE |
+                   ST_NEW_SAMPLE_MASK |
+                   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;
+   } else {
+      /* These set a subset of flags set by _NEW_BUFFERS, so we only have to
+       * check them when _NEW_BUFFERS isn't set.
+       */
+      if (new_state & (_NEW_DEPTH |
+                       _NEW_STENCIL))
+         st->dirty |= ST_NEW_DSA;
+
+      if (new_state & _NEW_PROGRAM)
+         st->dirty |= ST_NEW_SAMPLE_SHADING |
+                      ST_NEW_RASTERIZER;
+
+      if (new_state & _NEW_SCISSOR)
+         st->dirty |= ST_NEW_RASTERIZER |
+                      ST_NEW_SCISSOR |
+                      ST_NEW_WINDOW_RECTANGLES;
+
+      if (new_state & _NEW_FOG)
+         st->dirty |= ST_NEW_FS_STATE;
+
+      if (new_state & _NEW_POLYGONSTIPPLE)
+         st->dirty |= ST_NEW_POLY_STIPPLE;
+
+      if (new_state & _NEW_VIEWPORT)
+         st->dirty |= ST_NEW_VIEWPORT;
+
+      if (new_state & _NEW_FRAG_CLAMP) {
+         if (st->clamp_frag_color_in_shader)
+            st->dirty |= ST_NEW_FS_STATE;
+         else
+            st->dirty |= ST_NEW_RASTERIZER;
+      }
    }
 
-   /* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
-   if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT)) {
-      st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+   if (new_state & _NEW_MULTISAMPLE) {
+      st->dirty |= ST_NEW_BLEND |
+                   ST_NEW_SAMPLE_MASK |
+                   ST_NEW_SAMPLE_SHADING |
+                   ST_NEW_RASTERIZER |
+                   ST_NEW_FS_STATE;
+   } else {
+      /* These set a subset of flags set by _NEW_MULTISAMPLE, so we only
+       * have to check them when _NEW_MULTISAMPLE isn't set.
+       */
+      if (new_state & (_NEW_LIGHT |
+                       _NEW_LINE |
+                       _NEW_POINT |
+                       _NEW_POLYGON |
+                       _NEW_TRANSFORM))
+         st->dirty |= ST_NEW_RASTERIZER;
    }
 
-   /* Invalidate render and compute pipelines. */
-   st->dirty.mesa |= new_state;
-   st->dirty_cp.mesa |= new_state;
+   if (new_state & (_NEW_PROJECTION |
+                    _NEW_TRANSFORM))
+      st->dirty |= ST_NEW_CLIP_STATE;
+
+   if (new_state & _NEW_COLOR)
+      st->dirty |= ST_NEW_BLEND |
+                   ST_NEW_DSA;
+
+   if (new_state & _NEW_PIXEL)
+      st->dirty |= ST_NEW_PIXEL_TRANSFER;
+
+   if (new_state & _NEW_TEXTURE)
+      st->dirty |= ST_NEW_SAMPLER_VIEWS |
+                   ST_NEW_SAMPLERS |
+                   ST_NEW_IMAGE_UNITS;
+
+   if (new_state & _NEW_CURRENT_ATTRIB)
+      st->dirty |= ST_NEW_VERTEX_ARRAYS;
+
+   if (new_state & _NEW_PROGRAM_CONSTANTS)
+      st->dirty |= ST_NEW_CONSTANTS;
+
+   /* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
+   if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT))
+      st->dirty |= ST_NEW_VS_STATE;
 
    /* This is the only core Mesa module we depend upon.
     * No longer use swrast, swsetup, tnl.
@@ -214,11 +288,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
    /* state tracker needs the VBO module */
    _vbo_CreateContext(ctx);
 
-   /* Initialize render and compute pipelines flags */
-   st->dirty.mesa = ~0;
-   st->dirty.st = ~0;
-   st->dirty_cp.mesa = ~0;
-   st->dirty_cp.st = ~0;
+   st->dirty = ST_ALL_STATES_MASK;
 
    /* Create upload manager for vertex data for glBitmap, glDrawPixels,
     * glClear, etc.
index b3cf285984ff057d425ffa01edc4d9caec0dbb6a..b9ad2a92433cc95da1c0335cc5d8a4034d2b6787 100644 (file)
@@ -32,6 +32,7 @@
 #include "pipe/p_state.h"
 #include "state_tracker/st_api.h"
 #include "main/fbobject.h"
+#include "state_tracker/st_atom.h"
 
 
 #ifdef __cplusplus
@@ -50,44 +51,6 @@ struct st_perf_monitor_group;
 struct u_upload_mgr;
 
 
-/* gap  */
-#define ST_NEW_FRAGMENT_PROGRAM        (1 << 1)
-#define ST_NEW_VERTEX_PROGRAM          (1 << 2)
-#define ST_NEW_FRAMEBUFFER             (1 << 3)
-#define ST_NEW_TESS_STATE              (1 << 4)
-#define ST_NEW_GEOMETRY_PROGRAM        (1 << 5)
-#define ST_NEW_VERTEX_ARRAYS           (1 << 6)
-#define ST_NEW_RASTERIZER              (1 << 7)
-#define ST_NEW_UNIFORM_BUFFER          (1 << 8)
-#define ST_NEW_TESSCTRL_PROGRAM        (1 << 9)
-#define ST_NEW_TESSEVAL_PROGRAM        (1 << 10)
-#define ST_NEW_SAMPLER_VIEWS           (1 << 11)
-#define ST_NEW_ATOMIC_BUFFER           (1 << 12)
-#define ST_NEW_STORAGE_BUFFER          (1 << 13)
-#define ST_NEW_COMPUTE_PROGRAM         (1 << 14)
-#define ST_NEW_IMAGE_UNITS             (1 << 15)
-
-
-struct st_state_flags {
-   GLbitfield mesa;  /**< Mask of _NEW_x flags */
-   uint32_t st;      /**< Mask of ST_NEW_x flags */
-};
-
-struct st_tracked_state {
-   struct st_state_flags dirty;
-   void (*update)( struct st_context *st );
-};
-
-
-/**
- * Enumeration of state tracker pipelines.
- */
-enum st_pipeline {
-   ST_PIPELINE_RENDER,
-   ST_PIPELINE_COMPUTE,
-};
-
-
 /** For drawing quads for glClear, glDraw/CopyPixels, glBitmap, etc. */
 struct st_util_vertex
 {
@@ -175,8 +138,7 @@ struct st_context
    char vendor[100];
    char renderer[100];
 
-   struct st_state_flags dirty;
-   struct st_state_flags dirty_cp;
+   uint64_t dirty; /**< dirty states */
 
    GLboolean vertdata_edgeflags;
    GLboolean edgeflag_culls_prims;
index d12d77f501505c2da076996c11b66f51d9067af6..92eb4a39e9b653b4978ab9d8fb37cadc3a917840 100644 (file)
@@ -173,7 +173,7 @@ st_draw_vbo(struct gl_context *ctx,
    st_invalidate_readpix_cache(st);
 
    /* Validate state. */
-   if (st->dirty.st || st->dirty.mesa || ctx->NewDriverState) {
+   if ((st->dirty | ctx->NewDriverState) & ST_PIPELINE_RENDER_STATE_MASK) {
       st_validate_state(st, ST_PIPELINE_RENDER);
    }
 
@@ -278,7 +278,7 @@ st_indirect_draw_vbo(struct gl_context *ctx,
    assert(stride);
 
    /* Validate state. */
-   if (st->dirty.st || st->dirty.mesa || ctx->NewDriverState) {
+   if ((st->dirty | ctx->NewDriverState) & ST_PIPELINE_RENDER_STATE_MASK) {
       st_validate_state(st, ST_PIPELINE_RENDER);
    }
 
index d323c87de7dfee7996c673e3871ed0417becd071..e2da054d2a5cf8eb137948d0168db771efff5927 100644 (file)
@@ -153,7 +153,7 @@ st_context_validate(struct st_context *st,
                     struct st_framebuffer *stread)
 {
     if (stdraw && stdraw->stamp != st->draw_stamp) {
-       st->dirty.st |= ST_NEW_FRAMEBUFFER;
+       st->dirty |= ST_NEW_FRAMEBUFFER;
        _mesa_resize_framebuffer(st->ctx, &stdraw->Base,
                                 stdraw->Base.Width,
                                 stdraw->Base.Height);
@@ -162,7 +162,7 @@ st_context_validate(struct st_context *st,
 
     if (stread && stread->stamp != st->read_stamp) {
        if (stread != stdraw) {
-          st->dirty.st |= ST_NEW_FRAMEBUFFER;
+          st->dirty |= ST_NEW_FRAMEBUFFER;
           _mesa_resize_framebuffer(st->ctx, &stread->Base,
                                    stread->Base.Width,
                                    stread->Base.Height);