Merge remote branch 'origin/7.8'
[mesa.git] / src / mesa / state_tracker / st_atom.c
index fc8587f459836db1a98a7e598af47040ddc2fc7d..cf391f1f91f593d27e561991f0a02560401fb0ce 100644 (file)
 #include "st_atom.h"
 #include "st_cb_bitmap.h"
 #include "st_program.h"
+#include "st_manager.h"
 
-       
 
-/* This is used to initialize st->atoms[].  We could use this list
- * directly except for a single atom, st_update_constants, which has a
- * .dirty value which changes according to the parameters of the
- * current fragment and vertex programs, and so cannot be a static
- * value.
+/**
+ * This is used to initialize st->atoms[].
  */
 static const struct st_tracked_state *atoms[] =
 {
@@ -49,7 +46,8 @@ static const struct st_tracked_state *atoms[] =
    &st_update_clip,
 
    &st_finalize_textures,
-   &st_update_shader,
+   &st_update_fp,
+   &st_update_vp,
 
    &st_update_rasterizer,
    &st_update_polygon_stipple,
@@ -67,34 +65,13 @@ static const struct st_tracked_state *atoms[] =
 
 void st_init_atoms( struct st_context *st )
 {
-   GLuint i;
-
-   st->atoms = malloc(sizeof(atoms));
-   st->nr_atoms = sizeof(atoms)/sizeof(*atoms);
-   memcpy(st->atoms, atoms, sizeof(atoms));
-
-   /* Patch in a pointer to the dynamic state atom:
-    */
-   for (i = 0; i < st->nr_atoms; i++) {
-      if (st->atoms[i] == &st_update_vs_constants) {
-        st->atoms[i] = &st->constants.tracked_state[PIPE_SHADER_VERTEX];
-        st->atoms[i][0] = st_update_vs_constants;
-      }
-
-      if (st->atoms[i] == &st_update_fs_constants) {
-        st->atoms[i] = &st->constants.tracked_state[PIPE_SHADER_FRAGMENT];
-        st->atoms[i][0] = st_update_fs_constants;
-      }
-   }
+   /* no-op */
 }
 
 
 void st_destroy_atoms( struct st_context *st )
 {
-   if (st->atoms) {
-      free(st->atoms);
-      st->atoms = NULL;
-   }
+   /* no-op */
 }
 
 
@@ -158,10 +135,12 @@ void st_validate_state( struct st_context *st )
 
    check_program_state( st );
 
+   st_manager_validate_framebuffers(st);
+
    if (state->st == 0)
       return;
 
-//   _mesa_printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);
+   /*printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);*/
 
    if (1) {
       /* Debug version which enforces various sanity checks on the
@@ -172,21 +151,21 @@ void st_validate_state( struct st_context *st )
       memset(&examined, 0, sizeof(examined));
       prev = *state;
 
-      for (i = 0; i < st->nr_atoms; i++) {      
-        const struct st_tracked_state *atom = st->atoms[i];
+      for (i = 0; i < Elements(atoms); i++) {   
+        const struct st_tracked_state *atom = atoms[i];
         struct st_state_flags generated;
         
-//      _mesa_printf("atom %s %x/%x\n", atom->name, atom->dirty.mesa, atom->dirty.st);
+        /*printf("atom %s %x/%x\n", atom->name, atom->dirty.mesa, atom->dirty.st);*/
 
         if (!(atom->dirty.mesa || atom->dirty.st) ||
             !atom->update) {
-           _mesa_printf("malformed atom %s\n", atom->name);
+           printf("malformed atom %s\n", atom->name);
            assert(0);
         }
 
         if (check_state(state, &atom->dirty)) {
-           st->atoms[i]->update( st );
-//         _mesa_printf("after: %x\n", atom->dirty.mesa);
+           atoms[i]->update( st );
+           /*printf("after: %x\n", atom->dirty.mesa);*/
         }
 
         accumulate_state(&examined, &atom->dirty);
@@ -199,15 +178,13 @@ void st_validate_state( struct st_context *st )
         assert(!check_state(&examined, &generated));
         prev = *state;
       }
-//      _mesa_printf("\n");
+      /*printf("\n");*/
 
    }
    else {
-      const GLuint nr = st->nr_atoms;
-
-      for (i = 0; i < nr; i++) {        
-        if (check_state(state, &st->atoms[i]->dirty))
-           st->atoms[i]->update( st );
+      for (i = 0; i < Elements(atoms); i++) {   
+        if (check_state(state, &atoms[i]->dirty))
+           atoms[i]->update( st );
       }
    }