[Mesa-dev] [PATCH 1/7] tgsi/ureg: cleanup local temporary emission
Christian König
deathsimple at vodafone.de
Mon Mar 11 05:44:48 PDT 2013
From: Christian König <christian.koenig at amd.com>
Instead of emitting each temporary separately, emit them in a chunk.
Signed-off-by: Christian König <christian.koenig at amd.com>
---
src/gallium/auxiliary/tgsi/tgsi_ureg.c | 53 ++++++++++----------------------
1 file changed, 17 insertions(+), 36 deletions(-)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 3c2a923..9303dc7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1260,30 +1260,11 @@ emit_decl_fs(struct ureg_program *ureg,
out[3].decl_semantic.Index = semantic_index;
}
-
-static void emit_decl( struct ureg_program *ureg,
- unsigned file,
- unsigned index,
- boolean local )
-{
- union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 );
-
- out[0].value = 0;
- out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION;
- out[0].decl.NrTokens = 2;
- out[0].decl.File = file;
- out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW;
- out[0].decl.Local = local;
-
- out[1].value = 0;
- out[1].decl_range.First = index;
- out[1].decl_range.Last = index;
-}
-
static void emit_decl_range( struct ureg_program *ureg,
unsigned file,
unsigned first,
- unsigned count )
+ unsigned count,
+ boolean local )
{
union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 );
@@ -1293,6 +1274,7 @@ static void emit_decl_range( struct ureg_program *ureg,
out[0].decl.File = file;
out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW;
out[0].decl.Semantic = 0;
+ out[0].decl.Local = local;
out[1].value = 0;
out[1].decl_range.First = first;
@@ -1450,7 +1432,7 @@ static void emit_decls( struct ureg_program *ureg )
if (ureg->processor == TGSI_PROCESSOR_VERTEX) {
for (i = 0; i < UREG_MAX_INPUT; i++) {
if (ureg->vs_inputs[i/32] & (1 << (i%32))) {
- emit_decl_range( ureg, TGSI_FILE_INPUT, i, 1 );
+ emit_decl_range( ureg, TGSI_FILE_INPUT, i, 1, FALSE );
}
}
} else if (ureg->processor == TGSI_PROCESSOR_FRAGMENT) {
@@ -1496,7 +1478,7 @@ static void emit_decls( struct ureg_program *ureg )
for (i = 0; i < ureg->nr_samplers; i++) {
emit_decl_range( ureg,
TGSI_FILE_SAMPLER,
- ureg->sampler[i].Index, 1 );
+ ureg->sampler[i].Index, 1, FALSE );
}
for (i = 0; i < ureg->nr_sampler_views; i++) {
@@ -1514,7 +1496,8 @@ static void emit_decls( struct ureg_program *ureg )
emit_decl_range(ureg,
TGSI_FILE_CONSTANT,
ureg->const_decls.constant_range[i].first,
- ureg->const_decls.constant_range[i].last - ureg->const_decls.constant_range[i].first + 1);
+ ureg->const_decls.constant_range[i].last - ureg->const_decls.constant_range[i].first + 1,
+ FALSE);
}
}
@@ -1535,30 +1518,28 @@ static void emit_decls( struct ureg_program *ureg )
}
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) );
- }
+ for (i = 0; i < ureg->nr_temps;) {
+ boolean local = util_bitmask_get(ureg->local_temps, i);
+ unsigned first = i++;
+ while (i < ureg->nr_temps && local == util_bitmask_get(ureg->local_temps, i))
+ ++i;
+
+ emit_decl_range( ureg, TGSI_FILE_TEMPORARY, first,
+ i - first, local );
}
}
if (ureg->nr_addrs) {
emit_decl_range( ureg,
TGSI_FILE_ADDRESS,
- 0, ureg->nr_addrs );
+ 0, ureg->nr_addrs, FALSE );
}
if (ureg->nr_preds) {
emit_decl_range(ureg,
TGSI_FILE_PREDICATE,
0,
- ureg->nr_preds);
+ ureg->nr_preds, FALSE);
}
for (i = 0; i < ureg->nr_immediates; i++) {
--
1.7.9.5
More information about the mesa-dev
mailing list