mesa/formats: add more MESA_FORMAT_LAYOUTs
[mesa.git] / src / mesa / state_tracker / st_atom.c
index 32bcc266a344725a376e6b9831716345edecc4d9..43dbadd4a7e65b048f3547b3a6fcfacafad462c4 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.
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 
+#include <stdio.h>
 #include "main/glheader.h"
 #include "main/context.h"
 
@@ -45,9 +46,10 @@ static const struct st_tracked_state *atoms[] =
    &st_update_depth_stencil_alpha,
    &st_update_clip,
 
-   &st_finalize_textures,
    &st_update_fp,
    &st_update_gp,
+   &st_update_tep,
+   &st_update_tcp,
    &st_update_vp,
 
    &st_update_rasterizer,
@@ -55,18 +57,27 @@ static const struct st_tracked_state *atoms[] =
    &st_update_viewport,
    &st_update_scissor,
    &st_update_blend,
-   &st_update_sampler,
    &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_update_framebuffer,
    &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_update_pixel_transfer,
+   &st_update_tess,
 
    /* this must be done after the vertex program update */
    &st_update_array
@@ -131,16 +142,26 @@ static void check_program_state( struct st_context *st )
 static void check_attrib_edgeflag(struct st_context *st)
 {
    const struct gl_client_array **arrays = st->ctx->Array._DrawArrays;
-   GLboolean vertDataEdgeFlags;
+   GLboolean vertdata_edgeflags, edgeflag_culls_prims, edgeflags_enabled;
 
    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;
+   edgeflags_enabled = st->ctx->Polygon.FrontMode != GL_FILL ||
+                       st->ctx->Polygon.BackMode != GL_FILL;
+
+   vertdata_edgeflags = edgeflags_enabled &&
+                        arrays[VERT_ATTRIB_EDGEFLAG]->StrideB != 0;
+   if (vertdata_edgeflags != st->vertdata_edgeflags) {
+      st->vertdata_edgeflags = vertdata_edgeflags;
+      st->dirty.st |= 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;
    }
 }
 
@@ -160,11 +181,7 @@ void st_validate_state( struct st_context *st )
 
    check_attrib_edgeflag(st);
 
-   /* 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)
+   if (state->mesa)
       st_flush_bitmap_cache(st);
 
    check_program_state( st );
@@ -174,7 +191,7 @@ void st_validate_state( struct st_context *st )
    if (state->st == 0)
       return;
 
-   /*printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);*/
+   /*printf("%s %x/%x\n", __func__, state->mesa, state->st);*/
 
 #ifdef DEBUG
    if (1) {
@@ -189,7 +206,7 @@ void st_validate_state( struct st_context *st )
       memset(&examined, 0, sizeof(examined));
       prev = *state;
 
-      for (i = 0; i < Elements(atoms); i++) {   
+      for (i = 0; i < ARRAY_SIZE(atoms); i++) {         
         const struct st_tracked_state *atom = atoms[i];
         struct st_state_flags generated;
         
@@ -220,7 +237,7 @@ void st_validate_state( struct st_context *st )
 
    }
    else {
-      for (i = 0; i < Elements(atoms); i++) {   
+      for (i = 0; i < ARRAY_SIZE(atoms); i++) {         
         if (check_state(state, &atoms[i]->dirty))
            atoms[i]->update( st );
       }