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 <christian.koenig@amd.com>
This commit is contained in:
Christian König 2013-03-13 14:58:15 +01:00
parent d3e07bed90
commit 16caeff2a5
6 changed files with 66 additions and 4 deletions

View file

@ -272,6 +272,12 @@ iter_declaration(
ctx,
decl->Declaration.UsageMask );
if (decl->Declaration.Array) {
TXT( ", ARRAY(" );
SID(decl->Array.ArrayID);
CHR(')');
}
if (decl->Declaration.Local)
TXT( ", LOCAL" );

View file

@ -129,6 +129,10 @@ tgsi_parse_token(
next_token(ctx, &decl->SamplerView);
}
if( decl->Declaration.Array ) {
next_token(ctx, &decl->Array);
}
break;
}

View file

@ -66,6 +66,7 @@ struct tgsi_full_declaration
struct tgsi_declaration_semantic Semantic;
struct tgsi_declaration_resource Resource;
struct tgsi_declaration_sampler_view SamplerView;
struct tgsi_declaration_array Array;
};
struct tgsi_full_immediate

View file

@ -1114,6 +1114,28 @@ static boolean parse_declaration( struct translate_ctx *ctx )
cur = ctx->cur;
eat_opt_white( &cur );
if (*cur == ',') {
cur2 = cur;
cur2++;
eat_opt_white( &cur2 );
if (str_match_nocase_whole( &cur2, "ARRAY(" )) {
int arrayid;
eat_opt_white( &cur2 );
if (!parse_int( &cur2, &arrayid )) {
report_error( ctx, "Expected `,'" );
return FALSE;
}
eat_opt_white( &cur2 );
if (*cur2 != ')') {
report_error( ctx, "Expected `,'" );
return FALSE;
}
decl.Declaration.Array = 1;
decl.Array.ArrayID = arrayid;
cur = cur2;
}
}
if (*cur == ',' && !is_vs_input) {
uint i, j;

View file

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

View file

@ -119,7 +119,8 @@ struct tgsi_declaration
unsigned Interpolate : 1; /**< any interpolation info? */
unsigned Invariant : 1; /**< invariant optimization? */
unsigned Local : 1; /**< optimize as subroutine local variable? */
unsigned Padding : 7;
unsigned Array : 1; /**< extra array info? */
unsigned Padding : 6;
};
struct tgsi_declaration_range
@ -185,6 +186,11 @@ struct tgsi_declaration_sampler_view {
unsigned ReturnTypeW : 6; /**< one of enum pipe_type */
};
struct tgsi_declaration_array {
unsigned ArrayID : 10;
unsigned Padding : 22;
};
/*
* Special resources that don't need to be declared. They map to the
* GLOBAL/LOCAL/PRIVATE/INPUT compute memory spaces.