s/Tungsten Graphics/VMware/
[mesa.git] / src / mesa / state_tracker / st_atom.c
index 73df44d1988ef8cf6e94fde0019193b700fecdbd..32ce1eaaa07a81cb6b079e201c2f3999ff20f0d3 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  * 
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2003 VMware, Inc.
  * All Rights Reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -34,8 +34,8 @@
 #include "st_atom.h"
 #include "st_cb_bitmap.h"
 #include "st_program.h"
+#include "st_manager.h"
 
-       
 
 /**
  * This is used to initialize st->atoms[].
@@ -47,6 +47,7 @@ static const struct st_tracked_state *atoms[] =
 
    &st_finalize_textures,
    &st_update_fp,
+   &st_update_gp,
    &st_update_vp,
 
    &st_update_rasterizer,
@@ -54,12 +55,22 @@ static const struct st_tracked_state *atoms[] =
    &st_update_viewport,
    &st_update_scissor,
    &st_update_blend,
-   &st_update_sampler,
-   &st_update_texture,
+   &st_update_vertex_texture,
+   &st_update_fragment_texture,
+   &st_update_geometry_texture,
+   &st_update_sampler, /* depends on update_*_texture for swizzle */
    &st_update_framebuffer,
+   &st_update_msaa,
    &st_update_vs_constants,
+   &st_update_gs_constants,
    &st_update_fs_constants,
-   &st_update_pixel_transfer
+   &st_bind_vs_ubos,
+   &st_bind_fs_ubos,
+   &st_bind_gs_ubos,
+   &st_update_pixel_transfer,
+
+   /* this must be done after the vertex program update */
+   &st_update_array
 };
 
 
@@ -106,7 +117,7 @@ static void xor_states( struct st_state_flags *result,
  */
 static void check_program_state( struct st_context *st )
 {
-   GLcontext *ctx = st->ctx;
+   struct gl_context *ctx = st->ctx;
 
    if (ctx->VertexProgram._Current != &st->vp->Base)
       st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
@@ -114,6 +125,24 @@ static void check_program_state( struct st_context *st )
    if (ctx->FragmentProgram._Current != &st->fp->Base)
       st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
 
+   if (ctx->GeometryProgram._Current != &st->gp->Base)
+      st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
+}
+
+static void check_attrib_edgeflag(struct st_context *st)
+{
+   const struct gl_client_array **arrays = st->ctx->Array._DrawArrays;
+   GLboolean vertDataEdgeFlags;
+
+   if (!arrays)
+      return;
+
+   vertDataEdgeFlags = arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj &&
+                       arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj->Name;
+   if (vertDataEdgeFlags != st->vertdata_edgeflags) {
+      st->vertdata_edgeflags = vertDataEdgeFlags;
+      st->dirty.st |= ST_NEW_EDGEFLAGS_DATA;
+   }
 }
 
 
@@ -126,21 +155,29 @@ void st_validate_state( struct st_context *st )
    struct st_state_flags *state = &st->dirty;
    GLuint i;
 
-   /* The bitmap cache is immune to pixel unpack changes.
-    * Note that GLUT makes several calls to glPixelStore for each
-    * bitmap char it draws so this is an important check.
-    */
-   if (state->mesa & ~_NEW_PACKUNPACK)
+   /* Get Mesa driver state. */
+   st->dirty.st |= st->ctx->NewDriverState;
+   st->ctx->NewDriverState = 0;
+
+   check_attrib_edgeflag(st);
+
+   if (state->mesa)
       st_flush_bitmap_cache(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);*/
 
+#ifdef DEBUG
    if (1) {
+#else
+   if (0) {
+#endif
       /* Debug version which enforces various sanity checks on the
        * state flags which are generated and checked to help ensure
        * state atoms are ordered correctly in the list.
@@ -153,17 +190,17 @@ void st_validate_state( struct st_context *st )
         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)) {
            atoms[i]->update( st );
-           /*_mesa_printf("after: %x\n", atom->dirty.mesa);*/
+           /*printf("after: %x\n", atom->dirty.mesa);*/
         }
 
         accumulate_state(&examined, &atom->dirty);
@@ -176,7 +213,7 @@ void st_validate_state( struct st_context *st )
         assert(!check_state(&examined, &generated));
         prev = *state;
       }
-      /*_mesa_printf("\n");*/
+      /*printf("\n");*/
 
    }
    else {