From 0aaf174e31a960cfdc568c472bce76394b389997 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 19 Nov 2024 01:15:44 -0400 Subject: [PATCH] nir/lower_system_values: add ID to 32-bit lowering OpenCL has 64-bit global IDs, but for driver-internal OpenCL we only need 32-bit. Might as well lower in nir_lower_system_values instead of bringing up a whole new pass just for this. Will be used for asahi precomp Signed-off-by: Alyssa Rosenzweig Reviewed-by: Lionel Landwerlin Part-of: --- src/compiler/nir/nir.h | 1 + src/compiler/nir/nir_lower_system_values.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 2b10a977901..963ec4d19bc 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -6174,6 +6174,7 @@ typedef struct nir_lower_compute_system_values_options { bool lower_local_invocation_index : 1; bool lower_cs_local_id_to_index : 1; bool lower_workgroup_id_to_index : 1; + bool global_id_is_32bit : 1; /* At shader execution time, check if WorkGroupId should be 1D * and compute it quickly. Fall back to slow computation if not. */ diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c index cb4ed2a4c94..d20829a9bcf 100644 --- a/src/compiler/nir/nir_lower_system_values.c +++ b/src/compiler/nir/nir_lower_system_values.c @@ -719,6 +719,8 @@ lower_compute_system_value_instr(nir_builder *b, base_group_id), nir_u2uN(b, group_size, bit_size)), nir_u2uN(b, local_id, bit_size)); + } else if (options && options->global_id_is_32bit && bit_size > 32) { + return nir_u2uN(b, nir_load_global_invocation_id(b, 32), bit_size); } else { return NULL; }