summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi/tgsi_ureg.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2016-01-16 23:08:55 +0100
committerSamuel Pitoiset <[email protected]>2016-02-13 15:51:17 +0100
commita8328e3a50169c3c74656df7f63f56f061d9e751 (patch)
treea03a8e4e909d5a601992dd162dc34bb794326b96 /src/gallium/auxiliary/tgsi/tgsi_ureg.c
parent5e09ac78e5c25972fecf02e10363052a7b90f79f (diff)
tgsi/ureg: add shared variables support for compute shaders
This introduces TGSI_FILE_MEMORY for shared, global and local memory. Only shared memory is currently supported. Changes from v2: - introduce TGSI_FILE_MEMORY Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_ureg.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 9654ac52bf2..e1a72786476 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -189,6 +189,8 @@ struct ureg_program
unsigned nr_instructions;
struct ureg_tokens domain[2];
+
+ bool use_shared_memory;
};
static union tgsi_any_token error_tokens[32];
@@ -727,6 +729,16 @@ struct ureg_src ureg_DECL_buffer(struct ureg_program *ureg, unsigned nr,
return reg;
}
+/* Allocate a shared memory area.
+ */
+struct ureg_src ureg_DECL_shared_memory(struct ureg_program *ureg)
+{
+ struct ureg_src reg = ureg_src_register(TGSI_FILE_MEMORY, 0);
+
+ ureg->use_shared_memory = true;
+ return reg;
+}
+
static int
match_or_expand_immediate64( const unsigned *v,
int type,
@@ -1654,6 +1666,23 @@ emit_decl_buffer(struct ureg_program *ureg,
}
static void
+emit_decl_shared_memory(struct ureg_program *ureg)
+{
+ union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 2);
+
+ out[0].value = 0;
+ out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION;
+ out[0].decl.NrTokens = 2;
+ out[0].decl.File = TGSI_FILE_MEMORY;
+ out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW;
+ out[0].decl.Shared = true;
+
+ out[1].value = 0;
+ out[1].decl_range.First = 0;
+ out[1].decl_range.Last = 0;
+}
+
+static void
emit_immediate( struct ureg_program *ureg,
const unsigned *v,
unsigned type )
@@ -1825,6 +1854,9 @@ static void emit_decls( struct ureg_program *ureg )
emit_decl_buffer(ureg, ureg->buffer[i].index, ureg->buffer[i].atomic);
}
+ if (ureg->use_shared_memory)
+ emit_decl_shared_memory(ureg);
+
if (ureg->const_decls.nr_constant_ranges) {
for (i = 0; i < ureg->const_decls.nr_constant_ranges; i++) {
emit_decl_range(ureg,