diff options
author | Ian Romanick <[email protected]> | 2014-11-11 14:51:29 +0000 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2015-01-14 17:01:27 -0800 |
commit | 14aadbe8270845750ce0c62cf511fb5b1bcefd0f (patch) | |
tree | 18087ce72ddd239129d1a755ccc5705a155be17c | |
parent | 6ed53c27efc1b3eeb987b84b997633bc9456e5aa (diff) |
i965: Store the atoms directly in the context
Instead of having an extra pointer indirection in one of the hottest
loops in the driver.
On Bay Trail-D using Fedora 20 compile flags (-m64 -O2 -mtune=generic
for 64-bit and -m32 -march=i686 -mtune=atom for 32-bit), affects
Gl32Batch7:
32-bit: Difference at 95.0% confidence 1.98515% +/- 0.20814% (n=40)
64-bit: Difference at 95.0% confidence 1.5163% +/- 0.811016% (n=60)
v2 (Ken): Cut size of array from 64 to 57 to save memory.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_state_upload.c | 19 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 0e7bd21b019..a4b29fa43d1 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1383,7 +1383,7 @@ struct brw_context } perfmon; int num_atoms; - const struct brw_tracked_state **atoms; + const struct brw_tracked_state atoms[57]; /* If (INTEL_DEBUG & DEBUG_BATCH) */ struct { diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 7a25ef541bf..52d96f40413 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -357,6 +357,11 @@ void brw_init_state( struct brw_context *brw ) const struct brw_tracked_state **atoms; int num_atoms; + STATIC_ASSERT(ARRAY_SIZE(gen4_atoms) <= ARRAY_SIZE(brw->atoms)); + STATIC_ASSERT(ARRAY_SIZE(gen6_atoms) <= ARRAY_SIZE(brw->atoms)); + STATIC_ASSERT(ARRAY_SIZE(gen7_atoms) <= ARRAY_SIZE(brw->atoms)); + STATIC_ASSERT(ARRAY_SIZE(gen8_atoms) <= ARRAY_SIZE(brw->atoms)); + brw_init_caches(brw); if (brw->gen >= 8) { @@ -373,9 +378,17 @@ void brw_init_state( struct brw_context *brw ) num_atoms = ARRAY_SIZE(gen4_atoms); } - brw->atoms = atoms; brw->num_atoms = num_atoms; + /* This is to work around brw_context::atoms being declared const. We want + * it to be const, but it needs to be initialized somehow! + */ + struct brw_tracked_state *context_atoms = + (struct brw_tracked_state *) &brw->atoms[0]; + + for (int i = 0; i < num_atoms; i++) + context_atoms[i] = *atoms[i]; + while (num_atoms--) { assert((*atoms)->dirty.mesa | (*atoms)->dirty.brw); assert((*atoms)->emit); @@ -609,7 +622,7 @@ void brw_upload_state(struct brw_context *brw) prev = *state; for (i = 0; i < brw->num_atoms; i++) { - const struct brw_tracked_state *atom = brw->atoms[i]; + const struct brw_tracked_state *atom = &brw->atoms[i]; struct brw_state_flags generated; if (check_state(state, &atom->dirty)) { @@ -629,7 +642,7 @@ void brw_upload_state(struct brw_context *brw) } else { for (i = 0; i < brw->num_atoms; i++) { - const struct brw_tracked_state *atom = brw->atoms[i]; + const struct brw_tracked_state *atom = &brw->atoms[i]; if (check_state(state, &atom->dirty)) { atom->emit(brw); |