[965] Replace the always_update dirty flag with BRW_NEW_BATCH.

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).
This commit is contained in:
Eric Anholt 2008-01-09 14:08:12 -08:00
parent 5f86ae057a
commit dc1608ae9d
5 changed files with 27 additions and 15 deletions

View 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.

View 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 */
};

View 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,
};

View 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 );
}
}

View 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);