diff options
author | José Fonseca <[email protected]> | 2012-06-29 21:18:24 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2012-07-02 12:14:53 +0100 |
commit | f5c41e16d7b09e7c342bff8ec5888db88c071be3 (patch) | |
tree | 57fea8954eb687832cb665c4646a8e65d90a2144 | |
parent | e75fe7ba088fbdc0bdf07e074fee94d52cdd4868 (diff) |
gallium/tgsi: Don't declare temps individually when they are all similar.
tgsi_ureg was recently enhanced to support local temporaries, and as result
temps are declared individually.
This change avoids many TEMP register declarations on common shaders.
(And fixes performance regression due to mismatches against performance
sensitive shaders.)
Reviewed-by: Brian Paul <[email protected]>
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_ureg.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index e427585db19..3fe78e0b7f0 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -1534,9 +1534,18 @@ static void emit_decls( struct ureg_program *ureg ) } } - for (i = 0; i < ureg->nr_temps; i++) { - emit_decl( ureg, TGSI_FILE_TEMPORARY, i, - util_bitmask_get(ureg->local_temps, i) ); + if (ureg->nr_temps) { + if (util_bitmask_get_first_index(ureg->local_temps) == UTIL_BITMASK_INVALID_INDEX) { + emit_decl_range( ureg, + TGSI_FILE_TEMPORARY, + 0, ureg->nr_temps ); + + } else { + for (i = 0; i < ureg->nr_temps; i++) { + emit_decl( ureg, TGSI_FILE_TEMPORARY, i, + util_bitmask_get(ureg->local_temps, i) ); + } + } } if (ureg->nr_addrs) { @@ -1687,7 +1696,7 @@ struct ureg_program *ureg_create( unsigned processor ) { struct ureg_program *ureg = CALLOC_STRUCT( ureg_program ); if (ureg == NULL) - return NULL; + goto no_ureg; ureg->processor = processor; ureg->property_gs_input_prim = ~0; @@ -1696,17 +1705,19 @@ struct ureg_program *ureg_create( unsigned processor ) ureg->free_temps = util_bitmask_create(); if (ureg->free_temps == NULL) - goto fail; + goto no_free_temps; ureg->local_temps = util_bitmask_create(); if (ureg->local_temps == NULL) - goto fail; + goto no_local_temps; return ureg; -fail: - FREE(ureg->free_temps); +no_local_temps: + util_bitmask_destroy(ureg->free_temps); +no_free_temps: FREE(ureg); +no_ureg: return NULL; } |