summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-10-07 12:07:21 +0200
committerNicolai Hähnle <[email protected]>2016-10-12 18:50:10 +0200
commit047a7c7a0b419ac9e6deb4ff885a08c684495ce4 (patch)
tree8cc13f571ece499e68c324bb3b71569e7b0c94b3 /src/gallium/auxiliary/tgsi
parentf9a01f3872fa854c316b36351b166e2e4ebb5570 (diff)
tgsi/ureg: add layout/component input declarations
v2: change the order of parameters (Dave) Reviewed-by: Edward O'Callaghan <[email protected]> (v1) Reviewed-by: Dave Airlie <[email protected]> (v1)
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c67
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h21
2 files changed, 76 insertions, 12 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 6ad514d959a..348c3719fe2 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -77,9 +77,9 @@ struct ureg_tokens {
unsigned count;
};
-#define UREG_MAX_INPUT PIPE_MAX_SHADER_INPUTS
+#define UREG_MAX_INPUT (4 * PIPE_MAX_SHADER_INPUTS)
#define UREG_MAX_SYSTEM_VALUE PIPE_MAX_ATTRIBS
-#define UREG_MAX_OUTPUT PIPE_MAX_SHADER_OUTPUTS
+#define UREG_MAX_OUTPUT (4 * PIPE_MAX_SHADER_OUTPUTS)
#define UREG_MAX_CONSTANT_RANGE 32
#define UREG_MAX_IMMEDIATE 4096
#define UREG_MAX_ADDR 3
@@ -108,6 +108,7 @@ struct ureg_program
unsigned semantic_index;
unsigned interp;
unsigned char cylindrical_wrap;
+ unsigned char usage_mask;
unsigned interp_location;
unsigned first;
unsigned last;
@@ -269,25 +270,33 @@ ureg_property(struct ureg_program *ureg, unsigned name, unsigned value)
}
struct ureg_src
-ureg_DECL_fs_input_cyl_centroid(struct ureg_program *ureg,
+ureg_DECL_fs_input_cyl_centroid_layout(struct ureg_program *ureg,
unsigned semantic_name,
unsigned semantic_index,
unsigned interp_mode,
unsigned cylindrical_wrap,
unsigned interp_location,
+ unsigned index,
+ unsigned usage_mask,
unsigned array_id,
unsigned array_size)
{
unsigned i;
+ assert(usage_mask != 0);
+ assert(usage_mask <= TGSI_WRITEMASK_XYZW);
+
for (i = 0; i < ureg->nr_inputs; i++) {
if (ureg->input[i].semantic_name == semantic_name &&
ureg->input[i].semantic_index == semantic_index) {
assert(ureg->input[i].interp == interp_mode);
assert(ureg->input[i].cylindrical_wrap == cylindrical_wrap);
assert(ureg->input[i].interp_location == interp_location);
- assert(ureg->input[i].array_id == array_id);
- goto out;
+ if (ureg->input[i].array_id == array_id) {
+ ureg->input[i].usage_mask |= usage_mask;
+ goto out;
+ }
+ assert((ureg->input[i].usage_mask & usage_mask) == 0);
}
}
@@ -298,10 +307,11 @@ ureg_DECL_fs_input_cyl_centroid(struct ureg_program *ureg,
ureg->input[i].interp = interp_mode;
ureg->input[i].cylindrical_wrap = cylindrical_wrap;
ureg->input[i].interp_location = interp_location;
- ureg->input[i].first = ureg->nr_input_regs;
- ureg->input[i].last = ureg->nr_input_regs + array_size - 1;
+ ureg->input[i].first = index;
+ ureg->input[i].last = index + array_size - 1;
ureg->input[i].array_id = array_id;
- ureg->nr_input_regs += array_size;
+ ureg->input[i].usage_mask = usage_mask;
+ ureg->nr_input_regs = MAX2(ureg->nr_input_regs, index + array_size);
ureg->nr_inputs++;
} else {
set_bad(ureg);
@@ -312,6 +322,21 @@ out:
array_id);
}
+struct ureg_src
+ureg_DECL_fs_input_cyl_centroid(struct ureg_program *ureg,
+ unsigned semantic_name,
+ unsigned semantic_index,
+ unsigned interp_mode,
+ unsigned cylindrical_wrap,
+ unsigned interp_location,
+ unsigned array_id,
+ unsigned array_size)
+{
+ return ureg_DECL_fs_input_cyl_centroid_layout(ureg,
+ semantic_name, semantic_index, interp_mode, cylindrical_wrap, interp_location,
+ ureg->nr_input_regs, TGSI_WRITEMASK_XYZW, array_id, array_size);
+}
+
struct ureg_src
ureg_DECL_vs_input( struct ureg_program *ureg,
@@ -326,6 +351,21 @@ ureg_DECL_vs_input( struct ureg_program *ureg,
struct ureg_src
+ureg_DECL_input_layout(struct ureg_program *ureg,
+ unsigned semantic_name,
+ unsigned semantic_index,
+ unsigned index,
+ unsigned usage_mask,
+ unsigned array_id,
+ unsigned array_size)
+{
+ return ureg_DECL_fs_input_cyl_centroid_layout(ureg,
+ semantic_name, semantic_index, 0, 0, 0,
+ index, usage_mask, array_id, array_size);
+}
+
+
+struct ureg_src
ureg_DECL_input(struct ureg_program *ureg,
unsigned semantic_name,
unsigned semantic_index,
@@ -1536,7 +1576,8 @@ emit_decl_fs(struct ureg_program *ureg,
unsigned interpolate,
unsigned cylindrical_wrap,
unsigned interpolate_location,
- unsigned array_id)
+ unsigned array_id,
+ unsigned usage_mask)
{
union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL,
array_id ? 5 : 4);
@@ -1545,7 +1586,7 @@ emit_decl_fs(struct ureg_program *ureg,
out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION;
out[0].decl.NrTokens = 4;
out[0].decl.File = file;
- out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; /* FIXME! */
+ out[0].decl.UsageMask = usage_mask;
out[0].decl.Interpolate = 1;
out[0].decl.Semantic = 1;
out[0].decl.Array = array_id != 0;
@@ -1792,7 +1833,8 @@ static void emit_decls( struct ureg_program *ureg )
ureg->input[i].interp,
ureg->input[i].cylindrical_wrap,
ureg->input[i].interp_location,
- ureg->input[i].array_id);
+ ureg->input[i].array_id,
+ ureg->input[i].usage_mask);
}
}
else {
@@ -1806,7 +1848,8 @@ static void emit_decls( struct ureg_program *ureg )
(j - ureg->input[i].first),
ureg->input[i].interp,
ureg->input[i].cylindrical_wrap,
- ureg->input[i].interp_location, 0);
+ ureg->input[i].interp_location, 0,
+ ureg->input[i].usage_mask);
}
}
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index c2c2f1ac202..0fa35bfce86 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -173,6 +173,18 @@ ureg_property(struct ureg_program *ureg, unsigned name, unsigned value);
*/
struct ureg_src
+ureg_DECL_fs_input_cyl_centroid_layout(struct ureg_program *,
+ unsigned semantic_name,
+ unsigned semantic_index,
+ unsigned interp_mode,
+ unsigned cylindrical_wrap,
+ unsigned interp_location,
+ unsigned index,
+ unsigned usage_mask,
+ unsigned array_id,
+ unsigned array_size);
+
+struct ureg_src
ureg_DECL_fs_input_cyl_centroid(struct ureg_program *,
unsigned semantic_name,
unsigned semantic_index,
@@ -215,6 +227,15 @@ ureg_DECL_vs_input( struct ureg_program *,
unsigned index );
struct ureg_src
+ureg_DECL_input_layout(struct ureg_program *,
+ unsigned semantic_name,
+ unsigned semantic_index,
+ unsigned index,
+ unsigned usage_mask,
+ unsigned array_id,
+ unsigned array_size);
+
+struct ureg_src
ureg_DECL_input(struct ureg_program *,
unsigned semantic_name,
unsigned semantic_index,