From 155789c8e7cfa31084807a6f005413660dccf30a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 31 Jul 2019 21:30:22 -0400 Subject: [PATCH] tgsi_to_nir: add basic compute shader support MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-By: Timur Kristóf Reviewed-by: Eric Anholt Reviewed-by: Connor Abbott --- src/gallium/auxiliary/nir/tgsi_to_nir.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index 2d8ff251a30..1195d522239 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -620,6 +620,14 @@ ttn_src_for_file_and_index(struct ttn_compile *c, unsigned file, unsigned index, op = nir_intrinsic_load_point_coord; load = nir_load_point_coord(b); break; + case TGSI_SEMANTIC_THREAD_ID: + op = nir_intrinsic_load_local_invocation_id; + load = nir_load_local_invocation_id(b); + break; + case TGSI_SEMANTIC_BLOCK_ID: + op = nir_intrinsic_load_work_group_id; + load = nir_load_work_group_id(b); + break; default: unreachable("bad system value"); } @@ -2438,6 +2446,15 @@ ttn_compile_init(const void *tgsi_tokens, case TGSI_PROPERTY_VS_BLIT_SGPRS_AMD: s->info.vs.blit_sgprs_amd = value; break; + case TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH: + s->info.cs.local_size[0] = value; + break; + case TGSI_PROPERTY_CS_FIXED_BLOCK_HEIGHT: + s->info.cs.local_size[1] = value; + break; + case TGSI_PROPERTY_CS_FIXED_BLOCK_DEPTH: + s->info.cs.local_size[2] = value; + break; default: if (value) { fprintf(stderr, "tgsi_to_nir: unhandled TGSI property %u = %u\n", @@ -2447,6 +2464,12 @@ ttn_compile_init(const void *tgsi_tokens, } } + if (s->info.stage == MESA_SHADER_COMPUTE && + (!s->info.cs.local_size[0] || + !s->info.cs.local_size[1] || + !s->info.cs.local_size[2])) + s->info.cs.local_size_variable = true; + c->inputs = rzalloc_array(c, struct nir_variable *, s->num_inputs); c->outputs = rzalloc_array(c, struct nir_variable *, s->num_outputs); -- 2.30.2