diff options
author | Christian König <[email protected]> | 2013-03-13 14:58:15 +0100 |
---|---|---|
committer | Christian König <[email protected]> | 2013-03-19 13:38:32 +0100 |
commit | 16caeff2a5cc1237d30de9487b48b1cd775d9ae1 (patch) | |
tree | d4e7d56d7ff611afaa754a6fb7958816c3a0674b /src | |
parent | d3e07bed90d6b94ac37a7f48417bf8962408fa47 (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')
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_dump.c | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_parse.c | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_parse.h | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_text.c | 22 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_ureg.c | 29 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_shader_tokens.h | 8 |
6 files changed, 66 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 177be0f30c2..adca6af2a29 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -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" ); diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c index 720d68d1f22..29079ef2140 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_parse.c +++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c @@ -129,6 +129,10 @@ tgsi_parse_token( next_token(ctx, &decl->SamplerView); } + if( decl->Declaration.Array ) { + next_token(ctx, &decl->Array); + } + break; } diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.h b/src/gallium/auxiliary/tgsi/tgsi_parse.h index 78210ed7219..ae40f13affc 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_parse.h +++ b/src/gallium/auxiliary/tgsi/tgsi_parse.h @@ -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 diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 7d580e6e3d8..8a2a760ef59 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -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; 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 ); } } diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index 81e4a6b52ce..eac75e69e5d 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -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. |