summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2012-01-05 16:59:24 +0000
committerDave Airlie <[email protected]>2012-01-11 07:13:35 +0000
commit34a78b7ef6b0edf217acf221eab4b63542be5552 (patch)
tree8c2ee9200fe4b1ed720bec572c722aefd6c40106 /src
parent02932f37fa030f2d438b599106651cb938c3edc9 (diff)
tgsi/softpipe: add VertexID support.
This required changing the system value semantics, so we stored a system value per vertex, instance id is the only other system value we currently support, so I span it across the channels. This passes the 3 vertexid-* piglit tests + lots of instanceid tests. Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c9
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c14
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.h2
3 files changed, 19 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 3f89881534b..bfe7aea737b 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -103,7 +103,8 @@ vs_exec_run_linear( struct draw_vertex_shader *shader,
if (shader->info.uses_instanceid) {
unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_INSTANCEID];
assert(i < Elements(machine->SystemValue));
- machine->SystemValue[i][0] = shader->draw->instance_id;
+ for (j = 0; j < QUAD_SIZE; j++)
+ machine->SystemValue[i].i[j] = shader->draw->instance_id;
}
for (i = 0; i < count; i += MAX_TGSI_VERTICES) {
@@ -123,6 +124,12 @@ vs_exec_run_linear( struct draw_vertex_shader *shader,
}
#endif
+ if (shader->info.uses_vertexid) {
+ unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_VERTEXID];
+ assert(vid < Elements(machine->SystemValue));
+ machine->SystemValue[vid].i[j] = i + j;
+ }
+
for (slot = 0; slot < shader->info.num_inputs; slot++) {
#if 0
assert(!util_is_inf_or_nan(input[slot][0]));
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 52d4ff4e80b..3046656faeb 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -1037,6 +1037,7 @@ micro_sub(union tgsi_exec_channel *dst,
static void
fetch_src_file_channel(const struct tgsi_exec_machine *mach,
+ const uint chan_index,
const uint file,
const uint swizzle,
const union tgsi_exec_channel *index,
@@ -1097,7 +1098,7 @@ fetch_src_file_channel(const struct tgsi_exec_machine *mach,
* gl_FragCoord, for example, in a sys value register.
*/
for (i = 0; i < QUAD_SIZE; i++) {
- chan->f[i] = mach->SystemValue[index->i[i]][0];
+ chan->u[i] = mach->SystemValue[index->i[i]].u[i];
}
break;
@@ -1221,6 +1222,7 @@ fetch_source(const struct tgsi_exec_machine *mach,
/* get current value of address register[swizzle] */
swizzle = tgsi_util_get_src_register_swizzle( &reg->Indirect, CHAN_X );
fetch_src_file_channel(mach,
+ chan_index,
reg->Indirect.File,
swizzle,
&index2,
@@ -1280,6 +1282,7 @@ fetch_source(const struct tgsi_exec_machine *mach,
swizzle = tgsi_util_get_src_register_swizzle( &reg->DimIndirect, CHAN_X );
fetch_src_file_channel(mach,
+ chan_index,
reg->DimIndirect.File,
swizzle,
&index2,
@@ -1314,6 +1317,7 @@ fetch_source(const struct tgsi_exec_machine *mach,
swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index );
fetch_src_file_channel(mach,
+ chan_index,
reg->Register.File,
swizzle,
&index,
@@ -1384,6 +1388,7 @@ store_dest(struct tgsi_exec_machine *mach,
/* fetch values from the address/indirection register */
fetch_src_file_channel(mach,
+ chan_index,
reg->Indirect.File,
swizzle,
&index,
@@ -1433,6 +1438,7 @@ store_dest(struct tgsi_exec_machine *mach,
swizzle = tgsi_util_get_src_register_swizzle( &reg->DimIndirect, CHAN_X );
fetch_src_file_channel(mach,
+ chan_index,
reg->DimIndirect.File,
swizzle,
&index2,
@@ -1995,11 +2001,11 @@ exec_txf(struct tgsi_exec_machine *mach,
if (inst->Texture.NumOffsets == 1) {
union tgsi_exec_channel index;
index.i[0] = index.i[1] = index.i[2] = index.i[3] = inst->TexOffsets[0].Index;
- fetch_src_file_channel(mach, inst->TexOffsets[0].File,
+ fetch_src_file_channel(mach, 0, inst->TexOffsets[0].File,
inst->TexOffsets[0].SwizzleX, &index, &ZeroVec, &offset[0]);
- fetch_src_file_channel(mach, inst->TexOffsets[0].File,
+ fetch_src_file_channel(mach, 0, inst->TexOffsets[0].File,
inst->TexOffsets[0].SwizzleY, &index, &ZeroVec, &offset[1]);
- fetch_src_file_channel(mach, inst->TexOffsets[0].File,
+ fetch_src_file_channel(mach, 0, inst->TexOffsets[0].File,
inst->TexOffsets[0].SwizzleZ, &index, &ZeroVec, &offset[2]);
offsets[0] = offset[0].i[0];
offsets[1] = offset[1].i[0];
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index 0817e14101b..2fd1f97d06f 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -239,7 +239,7 @@ struct tgsi_exec_machine
/* System values */
unsigned SysSemanticToIndex[TGSI_SEMANTIC_COUNT];
- float SystemValue[TGSI_MAX_MISC_INPUTS][4];
+ union tgsi_exec_channel SystemValue[TGSI_MAX_MISC_INPUTS];
struct tgsi_exec_vector *Addrs;
struct tgsi_exec_vector *Predicates;