[965] Replace the always_update dirty flag with BRW_NEW_BATCH.
authorEric Anholt <eric@anholt.net>
Wed, 9 Jan 2008 22:08:12 +0000 (14:08 -0800)
committerEric Anholt <eric@anholt.net>
Wed, 9 Jan 2008 22:41:53 +0000 (14:41 -0800)
This allows us to avoid re-emitting some state when validate_state happens
multiple times per batchbuffer.  Even though we flush batch per primitive
currently, that may still happen already if the primitive changed (this should
probably be fixed as well).

src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_curbe.c
src/mesa/drivers/dri/i965/brw_misc_state.c
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/brw_vtbl.c

index a4645effd432bdf50180c20257e23dc54893e932..0ffc9f623892537a70eede88276e0e7e107b65ef 100644 (file)
@@ -135,8 +135,13 @@ struct brw_context;
 #define BRW_NEW_METAOPS                 0x1000
 #define BRW_NEW_FENCE                   0x2000
 #define BRW_NEW_LOCK                    0x4000
-
-
+/**
+ * Used for any batch entry with a relocated pointer that will be used
+ * by any 3D rendering.
+ */
+#define BRW_NEW_BATCH                  0x8000
+/** brw->depth_region updated */
+#define BRW_NEW_DEPTH_BUFFER           0x10000
 
 struct brw_state_flags {
    /** State update flags signalled by mesa internals */
@@ -328,7 +333,6 @@ struct brw_state_pointers {
 struct brw_tracked_state {
    struct brw_state_flags dirty;
    void (*update)( struct brw_context *brw );
-   GLboolean always_update;
 };
 
 /* Flags for brw->state.cache.
index 5d81703d3610cade85adeb44dce647727294c867..3841c0a9cd0a68e69648176ee37ec2a9e3e905ed 100644 (file)
@@ -342,10 +342,10 @@ const struct brw_tracked_state brw_constant_buffer = {
               BRW_NEW_VERTEX_PROGRAM |
               BRW_NEW_URB_FENCE | /* Implicit - hardware requires this, not used above */
               BRW_NEW_PSP | /* Implicit - hardware requires this, not used above */
-              BRW_NEW_CURBE_OFFSETS),
+              BRW_NEW_CURBE_OFFSETS |
+              BRW_NEW_BATCH),
       .cache = (CACHE_NEW_WM_PROG) 
    },
    .update = upload_constant_buffer,
-   .always_update = GL_TRUE, /* Has a relocation in the batchbuffer */
 };
 
index 37650dd94501a6fdc02a6a2e55c6019fe6998332..eefd22ecb23785ac19550272ce3f2cb9692ebd60 100644 (file)
@@ -93,8 +93,12 @@ static void upload_binding_table_pointers(struct brw_context *brw)
 }
 
 const struct brw_tracked_state brw_binding_table_pointers = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_BATCH,
+      .cache = CACHE_NEW_SURF_BIND,
+   },
    .update = upload_binding_table_pointers,
-   .always_update = GL_TRUE, /* Has a relocation in the batchbuffer */
 };
 
 
@@ -132,7 +136,7 @@ static void upload_pipelined_state_pointers(struct brw_context *brw )
 const struct brw_tracked_state brw_pipelined_state_pointers = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_METAOPS,
+      .brw = BRW_NEW_METAOPS | BRW_NEW_BATCH,
       .cache = (CACHE_NEW_VS_UNIT | 
                CACHE_NEW_GS_UNIT | 
                CACHE_NEW_GS_PROG | 
@@ -142,7 +146,6 @@ const struct brw_tracked_state brw_pipelined_state_pointers = {
                CACHE_NEW_CC_UNIT)
    },
    .update = upload_pipelined_state_pointers
-   .always_update = GL_TRUE, /* Has a relocation in the batchbuffer */
 };
 #endif
 
@@ -157,7 +160,7 @@ static void upload_psp_urb_cbs(struct brw_context *brw )
 const struct brw_tracked_state brw_psp_urb_cbs = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_URB_FENCE | BRW_NEW_METAOPS,
+      .brw = BRW_NEW_URB_FENCE | BRW_NEW_METAOPS | BRW_NEW_BATCH,
       .cache = (CACHE_NEW_VS_UNIT | 
                CACHE_NEW_GS_UNIT | 
                CACHE_NEW_GS_PROG | 
@@ -167,7 +170,6 @@ const struct brw_tracked_state brw_psp_urb_cbs = {
                CACHE_NEW_CC_UNIT)
    },
    .update = upload_psp_urb_cbs,
-   .always_update = GL_TRUE, /* psp has relocations. */
 };
 
 /**
@@ -226,8 +228,12 @@ static void upload_depthbuffer(struct brw_context *brw)
 }
 
 const struct brw_tracked_state brw_depthbuffer = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_DEPTH_BUFFER | BRW_NEW_BATCH,
+      .cache = 0,
+   },
    .update = upload_depthbuffer,
-   .always_update = GL_TRUE,
 };
 
 
index 46ae49262d11e51fc3eb335c8208fd1136477af4..1c818a2cb2dc5b9201844e29addbd62ee497d953 100644 (file)
@@ -222,11 +222,10 @@ void brw_validate_state( struct brw_context *brw )
 
         assert(atom->dirty.mesa ||
                atom->dirty.brw ||
-               atom->dirty.cache ||
-               atom->always_update);
+               atom->dirty.cache);
         assert(atom->update);
 
-        if (check_state(state, &atom->dirty) || atom->always_update) {
+        if (check_state(state, &atom->dirty)) {
            atom->update( brw );
            
 /*         emit_foo(brw); */
@@ -247,7 +246,7 @@ void brw_validate_state( struct brw_context *brw )
       for (i = 0; i < Elements(atoms); i++) {   
         const struct brw_tracked_state *atom = brw->state.atoms[i];
 
-        if (check_state(state, &atom->dirty) || atom->always_update)
+        if (check_state(state, &atom->dirty))
            atom->update( brw );
       }
    }
index 4575ff03218daf2d5420da6b3c00991f98db8a0f..277c8dca8b25512f940cdf8646b5a59ab1d12927 100644 (file)
@@ -75,6 +75,9 @@ static void brw_set_draw_region( struct intel_context *intel,
 {
    struct brw_context *brw = brw_context(&intel->ctx);
 
+   if (brw->state.depth_region != depth_region)
+      brw->state.dirty.brw |= BRW_NEW_DEPTH_BUFFER;
+
    intel_region_release(&brw->state.draw_region);
    intel_region_release(&brw->state.depth_region);
    intel_region_reference(&brw->state.draw_region, draw_region);