aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2015-05-20 11:11:43 +0200
committerMarek Olšák <[email protected]>2015-06-05 19:44:32 +0200
commita015b3952f568ad3da1ddfe42ff7ce6568f52780 (patch)
treea09654adaa7d9f4a0ba70323656460eec154b946 /src
parent1fa6c99e24890359e9cee2a9da02f21ea77b9f15 (diff)
tgsi/ureg: add support for output array declarations
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c52
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h38
-rw-r--r--src/gallium/state_trackers/nine/nine_ff.c6
-rw-r--r--src/gallium/state_trackers/nine/nine_shader.c13
4 files changed, 78 insertions, 31 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index b1aebfa1cb9..76ffe9f79a2 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -123,8 +123,11 @@ struct ureg_program
unsigned semantic_name;
unsigned semantic_index;
unsigned usage_mask; /* = TGSI_WRITEMASK_* */
+ unsigned first;
+ unsigned last;
+ unsigned array_id;
} output[UREG_MAX_OUTPUT];
- unsigned nr_outputs;
+ unsigned nr_outputs, nr_output_regs;
struct {
union {
@@ -332,10 +335,12 @@ ureg_DECL_system_value(struct ureg_program *ureg,
struct ureg_dst
-ureg_DECL_output_masked( struct ureg_program *ureg,
- unsigned name,
- unsigned index,
- unsigned usage_mask )
+ureg_DECL_output_masked(struct ureg_program *ureg,
+ unsigned name,
+ unsigned index,
+ unsigned usage_mask,
+ unsigned array_id,
+ unsigned array_size)
{
unsigned i;
@@ -343,7 +348,8 @@ ureg_DECL_output_masked( struct ureg_program *ureg,
for (i = 0; i < ureg->nr_outputs; i++) {
if (ureg->output[i].semantic_name == name &&
- ureg->output[i].semantic_index == index) {
+ ureg->output[i].semantic_index == index) {
+ assert(ureg->output[i].array_id == array_id);
ureg->output[i].usage_mask |= usage_mask;
goto out;
}
@@ -353,6 +359,10 @@ ureg_DECL_output_masked( struct ureg_program *ureg,
ureg->output[i].semantic_name = name;
ureg->output[i].semantic_index = index;
ureg->output[i].usage_mask = usage_mask;
+ ureg->output[i].first = ureg->nr_output_regs;
+ ureg->output[i].last = ureg->nr_output_regs + array_size - 1;
+ ureg->output[i].array_id = array_id;
+ ureg->nr_output_regs += array_size;
ureg->nr_outputs++;
}
else {
@@ -360,16 +370,30 @@ ureg_DECL_output_masked( struct ureg_program *ureg,
}
out:
- return ureg_dst_register( TGSI_FILE_OUTPUT, i );
+ return ureg_dst_array_register(TGSI_FILE_OUTPUT, ureg->output[i].first,
+ array_id);
}
struct ureg_dst
-ureg_DECL_output( struct ureg_program *ureg,
- unsigned name,
- unsigned index )
+ureg_DECL_output(struct ureg_program *ureg,
+ unsigned name,
+ unsigned index)
+{
+ return ureg_DECL_output_masked(ureg, name, index, TGSI_WRITEMASK_XYZW,
+ 0, 1);
+}
+
+struct ureg_dst
+ureg_DECL_output_array(struct ureg_program *ureg,
+ unsigned semantic_name,
+ unsigned semantic_index,
+ unsigned array_id,
+ unsigned array_size)
{
- return ureg_DECL_output_masked(ureg, name, index, TGSI_WRITEMASK_XYZW);
+ return ureg_DECL_output_masked(ureg, semantic_name, semantic_index,
+ TGSI_WRITEMASK_XYZW,
+ array_id, array_size);
}
@@ -1516,10 +1540,12 @@ static void emit_decls( struct ureg_program *ureg )
for (i = 0; i < ureg->nr_outputs; i++) {
emit_decl_semantic(ureg,
TGSI_FILE_OUTPUT,
- i, i,
+ ureg->output[i].first,
+ ureg->output[i].last,
ureg->output[i].semantic_name,
ureg->output[i].semantic_index,
- ureg->output[i].usage_mask, 0);
+ ureg->output[i].usage_mask,
+ ureg->output[i].array_id);
}
for (i = 0; i < ureg->nr_samplers; i++) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index e6304697938..e20f96d5674 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -222,15 +222,24 @@ ureg_DECL_system_value(struct ureg_program *,
unsigned semantic_index);
struct ureg_dst
-ureg_DECL_output_masked( struct ureg_program *,
- unsigned semantic_name,
- unsigned semantic_index,
- unsigned usage_mask );
+ureg_DECL_output_masked(struct ureg_program *,
+ unsigned semantic_name,
+ unsigned semantic_index,
+ unsigned usage_mask,
+ unsigned array_id,
+ unsigned array_size);
struct ureg_dst
-ureg_DECL_output( struct ureg_program *,
- unsigned semantic_name,
- unsigned semantic_index );
+ureg_DECL_output(struct ureg_program *,
+ unsigned semantic_name,
+ unsigned semantic_index);
+
+struct ureg_dst
+ureg_DECL_output_array(struct ureg_program *ureg,
+ unsigned semantic_name,
+ unsigned semantic_index,
+ unsigned array_id,
+ unsigned array_size);
struct ureg_src
ureg_DECL_immediate( struct ureg_program *,
@@ -1175,14 +1184,14 @@ ureg_src_array_offset(struct ureg_src reg, int offset)
static INLINE struct ureg_dst
ureg_dst_array_offset( struct ureg_dst reg, int offset )
{
- assert(reg.File == TGSI_FILE_TEMPORARY);
reg.Index += offset;
return reg;
}
static INLINE struct ureg_dst
-ureg_dst_register( unsigned file,
- unsigned index )
+ureg_dst_array_register(unsigned file,
+ unsigned index,
+ unsigned array_id)
{
struct ureg_dst dst;
@@ -1206,12 +1215,19 @@ ureg_dst_register( unsigned file,
dst.DimIndFile = TGSI_FILE_NULL;
dst.DimIndIndex = 0;
dst.DimIndSwizzle = 0;
- dst.ArrayID = 0;
+ dst.ArrayID = array_id;
return dst;
}
static INLINE struct ureg_dst
+ureg_dst_register(unsigned file,
+ unsigned index)
+{
+ return ureg_dst_array_register(file, index, 0);
+}
+
+static INLINE struct ureg_dst
ureg_dst( struct ureg_src src )
{
struct ureg_dst dst;
diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c
index e6f2b21dd4d..c2213e6bf11 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -422,13 +422,15 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
oCol[1] = ureg_saturate(ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 1));
if (key->vertexpointsize || key->pointscale) {
- oPsz = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_PSIZE, 0, TGSI_WRITEMASK_X);
+ oPsz = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_PSIZE, 0,
+ TGSI_WRITEMASK_X, 0, 1);
oPsz = ureg_writemask(oPsz, TGSI_WRITEMASK_X);
}
if (key->fog_mode) {
/* We apply fog to the vertex colors, oFog is for programmable shaders only ?
*/
- oFog = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_FOG, 0, TGSI_WRITEMASK_X);
+ oFog = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_FOG, 0,
+ TGSI_WRITEMASK_X, 0, 1);
oFog = ureg_writemask(oFog, TGSI_WRITEMASK_X);
}
diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c
index cdd4918530b..22a58825f78 100644
--- a/src/gallium/state_trackers/nine/nine_shader.c
+++ b/src/gallium/state_trackers/nine/nine_shader.c
@@ -1098,7 +1098,7 @@ _tx_dst_param(struct shader_translator *tx, const struct sm1_dst_param *param)
if (ureg_dst_is_undef(tx->regs.oDepth))
tx->regs.oDepth =
ureg_DECL_output_masked(tx->ureg, TGSI_SEMANTIC_POSITION, 0,
- TGSI_WRITEMASK_Z);
+ TGSI_WRITEMASK_Z, 0, 1);
dst = tx->regs.oDepth; /* XXX: must write .z component */
break;
case D3DSPR_PREDICATE:
@@ -1966,7 +1966,7 @@ DECL_SPECIAL(DCL)
tx->info->position_t = TRUE;
assert(sem.reg.idx < Elements(tx->regs.o));
tx->regs.o[sem.reg.idx] = ureg_DECL_output_masked(
- ureg, tgsi.Name, tgsi.Index, sem.reg.mask);
+ ureg, tgsi.Name, tgsi.Index, sem.reg.mask, 0, 1);
if (tgsi.Name == TGSI_SEMANTIC_PSIZE)
tx->regs.oPts = tx->regs.o[sem.reg.idx];
@@ -1984,7 +1984,8 @@ DECL_SPECIAL(DCL)
if (!is_input && 0) { /* declare in COLOROUT/DEPTHOUT case */
/* FragColor or FragDepth */
assert(sem.reg.mask != 0);
- ureg_DECL_output_masked(ureg, tgsi.Name, tgsi.Index, sem.reg.mask);
+ ureg_DECL_output_masked(ureg, tgsi.Name, tgsi.Index, sem.reg.mask,
+ 0, 1);
}
}
return D3D_OK;
@@ -2312,7 +2313,8 @@ DECL_SPECIAL(TEXM3x2DEPTH)
ureg_CMP(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_negate(ureg_abs(ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y))),
ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), ureg_imm1f(ureg, 1.0f));
/* replace the depth for depth testing with the result */
- tx->regs.oDepth = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_POSITION, 0, TGSI_WRITEMASK_Z);
+ tx->regs.oDepth = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_POSITION, 0,
+ TGSI_WRITEMASK_Z, 0, 1);
ureg_MOV(ureg, tx->regs.oDepth, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X));
/* note that we write nothing to the destination, since it's disallowed to use it afterward */
return D3D_OK;
@@ -2410,7 +2412,8 @@ DECL_SPECIAL(TEXDEPTH)
ureg_CMP(ureg, ureg_writemask(r5, TGSI_WRITEMASK_X), ureg_negate(ureg_abs(r5g)),
r5r, ureg_imm1f(ureg, 1.0f));
/* replace the depth for depth testing with the result */
- tx->regs.oDepth = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_POSITION, 0, TGSI_WRITEMASK_Z);
+ tx->regs.oDepth = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_POSITION, 0,
+ TGSI_WRITEMASK_Z, 0, 1);
ureg_MOV(ureg, tx->regs.oDepth, r5r);
return D3D_OK;