summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi/tgsi_ureg.c
diff options
context:
space:
mode:
authorChristian König <[email protected]>2013-03-13 14:58:15 +0100
committerChristian König <[email protected]>2013-03-19 13:38:32 +0100
commit16caeff2a5cc1237d30de9487b48b1cd775d9ae1 (patch)
treed4e7d56d7ff611afaa754a6fb7958816c3a0674b /src/gallium/auxiliary/tgsi/tgsi_ureg.c
parentd3e07bed90d6b94ac37a7f48417bf8962408fa47 (diff)
tgsi: add ArrayID to declarations
Remember which declarations are declared as "arrays" and so can be indirectly addressed. ArrayIDs start at 1, cause for compatibility reasons zero is treaded as no array present. Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_ureg.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 88acdcb12cd..1e862cb2198 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -50,6 +50,7 @@ union tgsi_any_token {
struct tgsi_declaration_interp decl_interp;
struct tgsi_declaration_semantic decl_semantic;
struct tgsi_declaration_sampler_view decl_sampler_view;
+ struct tgsi_declaration_array array;
struct tgsi_immediate imm;
union tgsi_immediate_data imm_data;
struct tgsi_instruction insn;
@@ -78,6 +79,7 @@ struct ureg_tokens {
#define UREG_MAX_IMMEDIATE 256
#define UREG_MAX_ADDR 2
#define UREG_MAX_PRED 1
+#define UREG_MAX_ARRAY_TEMPS 256
struct const_decl {
struct {
@@ -156,6 +158,9 @@ struct ureg_program
struct util_bitmask *decl_temps;
unsigned nr_temps;
+ unsigned array_temps[UREG_MAX_ARRAY_TEMPS];
+ unsigned nr_array_temps;
+
struct const_decl const_decls;
struct const_decl const_decls2D[PIPE_MAX_CONSTANT_BUFFERS];
@@ -584,11 +589,17 @@ struct ureg_dst ureg_DECL_array_temporary( struct ureg_program *ureg,
if (local)
util_bitmask_set(ureg->local_temps, i);
+ /* Always start a new declaration at the start */
util_bitmask_set(ureg->decl_temps, i);
ureg->nr_temps += size;
+
+ /* and also at the end of the array */
util_bitmask_set(ureg->decl_temps, ureg->nr_temps);
+ if (ureg->nr_array_temps < UREG_MAX_ARRAY_TEMPS)
+ ureg->array_temps[ureg->nr_array_temps++] = i;
+
return dst;
}
@@ -1284,9 +1295,11 @@ emit_decl_fs(struct ureg_program *ureg,
static void
emit_decl_temps( struct ureg_program *ureg,
unsigned first, unsigned last,
- boolean local )
+ boolean local,
+ unsigned arrayid )
{
- union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 );
+ union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL,
+ arrayid ? 3 : 2 );
out[0].value = 0;
out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION;
@@ -1298,6 +1311,12 @@ emit_decl_temps( struct ureg_program *ureg,
out[1].value = 0;
out[1].decl_range.First = first;
out[1].decl_range.Last = last;
+
+ if (arrayid) {
+ out[0].decl.Array = 1;
+ out[2].value = 0;
+ out[2].array.ArrayID = arrayid;
+ }
}
static void emit_decl_range( struct ureg_program *ureg,
@@ -1555,6 +1574,7 @@ static void emit_decls( struct ureg_program *ureg )
}
if (ureg->nr_temps) {
+ unsigned array = 0;
for (i = 0; i < ureg->nr_temps;) {
boolean local = util_bitmask_get(ureg->local_temps, i);
unsigned first = i;
@@ -1562,7 +1582,10 @@ static void emit_decls( struct ureg_program *ureg )
if (i == UTIL_BITMASK_INVALID_INDEX)
i = ureg->nr_temps;
- emit_decl_temps( ureg, first, i - 1, local );
+ if (array < ureg->nr_array_temps && ureg->array_temps[array] == first)
+ emit_decl_temps( ureg, first, i - 1, local, ++array );
+ else
+ emit_decl_temps( ureg, first, i - 1, local, 0 );
}
}