summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/tgsi
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c16
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c49
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ppc.c3
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sanity.c8
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c3
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c116
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h49
7 files changed, 200 insertions, 44 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index e2e5394f86..c254a7274f 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -123,7 +123,8 @@ static const char *semantic_names[] =
"NORMAL",
"FACE",
"EDGEFLAG",
- "PRIM_ID"
+ "PRIM_ID",
+ "INSTANCEID"
};
static const char *immediate_type_names[] =
@@ -218,8 +219,13 @@ _dump_register_src(
struct dump_ctx *ctx,
const struct tgsi_full_src_register *src )
{
+ ENM(src->Register.File, file_names);
+ if (src->Register.Dimension) {
+ CHR('[');
+ SID(src->Dimension.Index);
+ CHR(']');
+ }
if (src->Register.Indirect) {
- ENM( src->Register.File, file_names );
CHR( '[' );
ENM( src->Indirect.File, file_names );
CHR( '[' );
@@ -233,16 +239,10 @@ _dump_register_src(
}
CHR( ']' );
} else {
- ENM( src->Register.File, file_names );
CHR( '[' );
SID( src->Register.Index );
CHR( ']' );
}
- if (src->Register.Dimension) {
- CHR( '[' );
- SID( src->Dimension.Index );
- CHR( ']' );
- }
}
static void
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 2bcb33392a..83646b73c1 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -1041,11 +1041,19 @@ fetch_src_file_channel(
default:
assert( 0 );
+ chan->u[0] = 0;
+ chan->u[1] = 0;
+ chan->u[2] = 0;
+ chan->u[3] = 0;
}
break;
default:
assert( 0 );
+ chan->u[0] = 0;
+ chan->u[1] = 0;
+ chan->u[2] = 0;
+ chan->u[3] = 0;
}
}
@@ -1121,11 +1129,14 @@ fetch_source(const struct tgsi_exec_machine *mach,
* subscript to a register file. Effectively it means that
* the register file is actually a 2D array of registers.
*
- * file[1][3] == file[1*sizeof(file[1])+3],
+ * file[3][1] == file[3*sizeof(file[1])+1],
* where:
* [3] = Dimension.Index
*/
if (reg->Register.Dimension) {
+ int array_size;
+ union tgsi_exec_channel dim_index;
+
/* The size of the first-order array depends on the register file type.
* We need to multiply the index to the first array to get an effective,
* "flat" index that points to the beginning of the second-order array.
@@ -1133,32 +1144,27 @@ fetch_source(const struct tgsi_exec_machine *mach,
switch (reg->Register.File) {
case TGSI_FILE_INPUT:
case TGSI_FILE_SYSTEM_VALUE:
- index.i[0] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
- index.i[1] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
- index.i[2] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
- index.i[3] *= TGSI_EXEC_MAX_INPUT_ATTRIBS;
+ array_size = TGSI_EXEC_MAX_INPUT_ATTRIBS;
break;
case TGSI_FILE_CONSTANT:
- index.i[0] *= TGSI_EXEC_MAX_CONST_BUFFER;
- index.i[1] *= TGSI_EXEC_MAX_CONST_BUFFER;
- index.i[2] *= TGSI_EXEC_MAX_CONST_BUFFER;
- index.i[3] *= TGSI_EXEC_MAX_CONST_BUFFER;
+ array_size = TGSI_EXEC_MAX_CONST_BUFFER;
break;
default:
assert( 0 );
+ array_size = 0;
}
- index.i[0] += reg->Dimension.Index;
- index.i[1] += reg->Dimension.Index;
- index.i[2] += reg->Dimension.Index;
- index.i[3] += reg->Dimension.Index;
+ dim_index.i[0] =
+ dim_index.i[1] =
+ dim_index.i[2] =
+ dim_index.i[3] = reg->Dimension.Index;
/* Again, the second subscript index can be addressed indirectly
* identically to the first one.
* Nothing stops us from indirectly addressing the indirect register,
* but there is no need for that, so we won't exercise it.
*
- * file[1][ind[4].y+3],
+ * file[ind[4].y+3][1],
* where:
* ind = DimIndirect.File
* [4] = DimIndirect.Index
@@ -1183,20 +1189,25 @@ fetch_source(const struct tgsi_exec_machine *mach,
&index2,
&indir_index );
- index.i[0] += indir_index.i[0];
- index.i[1] += indir_index.i[1];
- index.i[2] += indir_index.i[2];
- index.i[3] += indir_index.i[3];
+ dim_index.i[0] += indir_index.i[0];
+ dim_index.i[1] += indir_index.i[1];
+ dim_index.i[2] += indir_index.i[2];
+ dim_index.i[3] += indir_index.i[3];
/* for disabled execution channels, zero-out the index to
* avoid using a potential garbage value.
*/
for (i = 0; i < QUAD_SIZE; i++) {
if ((execmask & (1 << i)) == 0)
- index.i[i] = 0;
+ dim_index.i[i] = 0;
}
}
+ index.i[0] += dim_index.i[0] * array_size;
+ index.i[1] += dim_index.i[1] * array_size;
+ index.i[2] += dim_index.i[2] * array_size;
+ index.i[3] += dim_index.i[3] * array_size;
+
/* If by any chance there was a need for a 3D array of register
* files, we would have to check whether Dimension is followed
* by a dimension register and continue the saga.
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ppc.c b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
index 138d2d095b..ad553c71a5 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ppc.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
@@ -51,7 +51,8 @@
* Since it's pretty much impossible to form PPC vector immediates, load
* them from memory here:
*/
-const float ppc_builtin_constants[] ALIGN16_ATTRIB = {
+PIPE_ALIGN_VAR(16) const float
+ppc_builtin_constants[] = {
1.0f, -128.0f, 128.0, 0.0
};
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c
index 7f1c8e5dd6..431c3ffb14 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c
@@ -335,13 +335,9 @@ iter_instruction(
fill_scan_register1d(ind_reg,
inst->Src[i].Indirect.File,
inst->Src[i].Indirect.Index);
- if (!(reg->file == TGSI_FILE_ADDRESS || reg->file == TGSI_FILE_LOOP) ||
- reg->indices[0] != 0) {
- report_warning(ctx, "Indirect register neither ADDR[0] nor LOOP[0]");
- }
check_register_usage(
ctx,
- reg,
+ ind_reg,
"indirect",
FALSE );
}
@@ -412,7 +408,7 @@ iter_declaration(
uint vert;
for (vert = 0; vert < ctx->implied_array_size; ++vert) {
scan_register *reg = MALLOC(sizeof(scan_register));
- fill_scan_register2d(reg, file, vert, i);
+ fill_scan_register2d(reg, file, i, vert);
check_and_declare(ctx, reg);
}
} else {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 9fcffeda36..7fe5dad5ff 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -933,7 +933,8 @@ static const char *semantic_names[TGSI_SEMANTIC_COUNT] =
"NORMAL",
"FACE",
"EDGEFLAG",
- "PRIM_ID"
+ "PRIM_ID",
+ "INSTANCEID"
};
static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index e64e2b731d..ab557a23f9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -40,6 +40,8 @@ union tgsi_any_token {
struct tgsi_header header;
struct tgsi_processor processor;
struct tgsi_token token;
+ struct tgsi_property prop;
+ struct tgsi_property_data prop_data;
struct tgsi_declaration decl;
struct tgsi_declaration_range decl_range;
struct tgsi_declaration_semantic decl_semantic;
@@ -64,6 +66,7 @@ struct ureg_tokens {
};
#define UREG_MAX_INPUT PIPE_MAX_ATTRIBS
+#define UREG_MAX_SYSTEM_VALUE PIPE_MAX_ATTRIBS
#define UREG_MAX_OUTPUT PIPE_MAX_ATTRIBS
#define UREG_MAX_CONSTANT_RANGE 32
#define UREG_MAX_IMMEDIATE 32
@@ -95,6 +98,13 @@ struct ureg_program
unsigned nr_gs_inputs;
struct {
+ unsigned index;
+ unsigned semantic_name;
+ unsigned semantic_index;
+ } system_value[UREG_MAX_SYSTEM_VALUE];
+ unsigned nr_system_values;
+
+ struct {
unsigned semantic_name;
unsigned semantic_index;
} output[UREG_MAX_OUTPUT];
@@ -123,6 +133,8 @@ struct ureg_program
} constant_range[UREG_MAX_CONSTANT_RANGE];
unsigned nr_constant_ranges;
+ unsigned property_gs_input_prim;
+
unsigned nr_addrs;
unsigned nr_preds;
unsigned nr_loops;
@@ -234,19 +246,29 @@ ureg_src_register( unsigned file,
src.SwizzleY = TGSI_SWIZZLE_Y;
src.SwizzleZ = TGSI_SWIZZLE_Z;
src.SwizzleW = TGSI_SWIZZLE_W;
- src.Pad = 0;
src.Indirect = 0;
+ src.IndirectFile = TGSI_FILE_NULL;
src.IndirectIndex = 0;
src.IndirectSwizzle = 0;
src.Absolute = 0;
src.Index = index;
src.Negate = 0;
+ src.Dimension = 0;
+ src.DimensionIndex = 0;
return src;
}
+void
+ureg_property_gs_input_prim(struct ureg_program *ureg,
+ unsigned gs_input_prim)
+{
+ ureg->property_gs_input_prim = gs_input_prim;
+}
+
+
struct ureg_src
ureg_DECL_fs_input( struct ureg_program *ureg,
@@ -304,6 +326,25 @@ ureg_DECL_gs_input(struct ureg_program *ureg,
}
+struct ureg_src
+ureg_DECL_system_value(struct ureg_program *ureg,
+ unsigned index,
+ unsigned semantic_name,
+ unsigned semantic_index)
+{
+ if (ureg->nr_system_values < UREG_MAX_SYSTEM_VALUE) {
+ ureg->system_value[ureg->nr_system_values].index = index;
+ ureg->system_value[ureg->nr_system_values].semantic_name = semantic_name;
+ ureg->system_value[ureg->nr_system_values].semantic_index = semantic_index;
+ ureg->nr_system_values++;
+ } else {
+ set_bad(ureg);
+ }
+
+ return ureg_src_register(TGSI_FILE_SYSTEM_VALUE, index);
+}
+
+
struct ureg_dst
ureg_DECL_output( struct ureg_program *ureg,
unsigned name,
@@ -616,6 +657,35 @@ ureg_DECL_immediate_uint( struct ureg_program *ureg,
struct ureg_src
+ureg_DECL_immediate_block_uint( struct ureg_program *ureg,
+ const unsigned *v,
+ unsigned nr )
+{
+ uint index;
+ uint i;
+
+ if (ureg->nr_immediates + (nr + 3) / 4 > UREG_MAX_IMMEDIATE) {
+ set_bad(ureg);
+ return ureg_src_register(TGSI_FILE_IMMEDIATE, 0);
+ }
+
+ index = ureg->nr_immediates;
+ ureg->nr_immediates += (nr + 3) / 4;
+
+ for (i = index; i < ureg->nr_immediates; i++) {
+ ureg->immediate[i].type = TGSI_IMM_UINT32;
+ ureg->immediate[i].nr = nr > 4 ? 4 : nr;
+ memcpy(ureg->immediate[i].value.u,
+ &v[(i - index) * 4],
+ ureg->immediate[i].nr * sizeof(uint));
+ nr -= 4;
+ }
+
+ return ureg_src_register(TGSI_FILE_IMMEDIATE, index);
+}
+
+
+struct ureg_src
ureg_DECL_immediate_int( struct ureg_program *ureg,
const int *v,
unsigned nr )
@@ -628,7 +698,7 @@ void
ureg_emit_src( struct ureg_program *ureg,
struct ureg_src src )
{
- unsigned size = 1 + (src.Indirect ? 1 : 0);
+ unsigned size = 1 + (src.Indirect ? 1 : 0) + (src.Dimension ? 1 : 0);
union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
unsigned n = 0;
@@ -651,7 +721,7 @@ ureg_emit_src( struct ureg_program *ureg,
if (src.Indirect) {
out[0].src.Indirect = 1;
out[n].value = 0;
- out[n].src.File = TGSI_FILE_ADDRESS;
+ out[n].src.File = src.IndirectFile;
out[n].src.SwizzleX = src.IndirectSwizzle;
out[n].src.SwizzleY = src.IndirectSwizzle;
out[n].src.SwizzleZ = src.IndirectSwizzle;
@@ -660,6 +730,15 @@ ureg_emit_src( struct ureg_program *ureg,
n++;
}
+ if (src.Dimension) {
+ out[0].src.Dimension = 1;
+ out[n].dim.Indirect = 0;
+ out[n].dim.Dimension = 0;
+ out[n].dim.Padding = 0;
+ out[n].dim.Index = src.DimensionIndex;
+ n++;
+ }
+
assert(n == size);
}
@@ -1027,13 +1106,34 @@ emit_immediate( struct ureg_program *ureg,
out[4].imm_data.Uint = v[3];
}
+static void
+emit_property(struct ureg_program *ureg,
+ unsigned name,
+ unsigned data)
+{
+ union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 2);
+
+ out[0].value = 0;
+ out[0].prop.Type = TGSI_TOKEN_TYPE_PROPERTY;
+ out[0].prop.NrTokens = 2;
+ out[0].prop.PropertyName = name;
+ out[1].prop_data.Data = data;
+}
static void emit_decls( struct ureg_program *ureg )
{
unsigned i;
+ if (ureg->property_gs_input_prim != ~0) {
+ assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY);
+
+ emit_property(ureg,
+ TGSI_PROPERTY_GS_INPUT_PRIM,
+ ureg->property_gs_input_prim);
+ }
+
if (ureg->processor == TGSI_PROCESSOR_VERTEX) {
for (i = 0; i < UREG_MAX_INPUT; i++) {
if (ureg->vs_inputs[i/32] & (1 << (i%32))) {
@@ -1058,6 +1158,15 @@ static void emit_decls( struct ureg_program *ureg )
}
}
+ for (i = 0; i < ureg->nr_system_values; i++) {
+ emit_decl(ureg,
+ TGSI_FILE_SYSTEM_VALUE,
+ ureg->system_value[i].index,
+ ureg->system_value[i].semantic_name,
+ ureg->system_value[i].semantic_index,
+ TGSI_INTERPOLATE_CONSTANT);
+ }
+
for (i = 0; i < ureg->nr_outputs; i++) {
emit_decl( ureg,
TGSI_FILE_OUTPUT,
@@ -1234,6 +1343,7 @@ struct ureg_program *ureg_create( unsigned processor )
return NULL;
ureg->processor = processor;
+ ureg->property_gs_input_prim = ~0;
return ureg;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 6f11273320..8c8a6bbce6 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -47,13 +47,15 @@ struct ureg_src
unsigned SwizzleY : 2; /* TGSI_SWIZZLE_ */
unsigned SwizzleZ : 2; /* TGSI_SWIZZLE_ */
unsigned SwizzleW : 2; /* TGSI_SWIZZLE_ */
- unsigned Pad : 1; /* BOOL */
unsigned Indirect : 1; /* BOOL */
+ unsigned Dimension : 1; /* BOOL */
unsigned Absolute : 1; /* BOOL */
- int Index : 16; /* SINT */
unsigned Negate : 1; /* BOOL */
+ int Index : 16; /* SINT */
+ unsigned IndirectFile : 4; /* TGSI_FILE_ */
int IndirectIndex : 16; /* SINT */
- int IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */
+ unsigned IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */
+ int DimensionIndex : 16; /* SINT */
};
/* Very similar to a tgsi_dst_register, removing unsupported fields
@@ -118,6 +120,14 @@ ureg_create_shader_and_destroy( struct ureg_program *p,
}
+/***********************************************************************
+ * Build shader properties:
+ */
+
+void
+ureg_property_gs_input_prim(struct ureg_program *ureg,
+ unsigned gs_input_prim);
+
/***********************************************************************
* Build shader declarations:
@@ -137,6 +147,12 @@ struct ureg_src
ureg_DECL_gs_input(struct ureg_program *,
unsigned index);
+struct ureg_src
+ureg_DECL_system_value(struct ureg_program *,
+ unsigned index,
+ unsigned semantic_name,
+ unsigned semantic_index);
+
struct ureg_dst
ureg_DECL_output( struct ureg_program *,
unsigned semantic_name,
@@ -153,6 +169,11 @@ ureg_DECL_immediate_uint( struct ureg_program *,
unsigned nr );
struct ureg_src
+ureg_DECL_immediate_block_uint( struct ureg_program *,
+ const unsigned *v,
+ unsigned nr );
+
+struct ureg_src
ureg_DECL_immediate_int( struct ureg_program *,
const int *v,
unsigned nr );
@@ -753,18 +774,30 @@ static INLINE struct ureg_src
ureg_src_indirect( struct ureg_src reg, struct ureg_src addr )
{
assert(reg.File != TGSI_FILE_NULL);
- assert(addr.File == TGSI_FILE_ADDRESS);
+ assert(addr.File == TGSI_FILE_ADDRESS || addr.File == TGSI_FILE_TEMPORARY);
reg.Indirect = 1;
+ reg.IndirectFile = addr.File;
reg.IndirectIndex = addr.Index;
reg.IndirectSwizzle = addr.SwizzleX;
return reg;
}
+static INLINE struct ureg_src
+ureg_src_dimension( struct ureg_src reg, int index )
+{
+ assert(reg.File != TGSI_FILE_NULL);
+ reg.Dimension = 1;
+ reg.DimensionIndex = index;
+ return reg;
+}
+
static INLINE struct ureg_dst
ureg_dst( struct ureg_src src )
{
struct ureg_dst dst;
+ assert(!src.Indirect || src.IndirectFile == TGSI_FILE_ADDRESS);
+
dst.File = src.File;
dst.WriteMask = TGSI_WRITEMASK_XYZW;
dst.Indirect = src.Indirect;
@@ -792,13 +825,15 @@ ureg_src( struct ureg_dst dst )
src.SwizzleY = TGSI_SWIZZLE_Y;
src.SwizzleZ = TGSI_SWIZZLE_Z;
src.SwizzleW = TGSI_SWIZZLE_W;
- src.Pad = 0;
src.Indirect = dst.Indirect;
+ src.IndirectFile = TGSI_FILE_ADDRESS;
src.IndirectIndex = dst.IndirectIndex;
src.IndirectSwizzle = dst.IndirectSwizzle;
src.Absolute = 0;
src.Index = dst.Index;
src.Negate = 0;
+ src.Dimension = 0;
+ src.DimensionIndex = 0;
return src;
}
@@ -837,13 +872,15 @@ ureg_src_undef( void )
src.SwizzleY = 0;
src.SwizzleZ = 0;
src.SwizzleW = 0;
- src.Pad = 0;
src.Indirect = 0;
+ src.IndirectFile = TGSI_FILE_NULL;
src.IndirectIndex = 0;
src.IndirectSwizzle = 0;
src.Absolute = 0;
src.Index = 0;
src.Negate = 0;
+ src.Dimension = 0;
+ src.DimensionIndex = 0;
return src;
}