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 <alyssa@rosenzweig.io>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32210>
This commit is contained in:
Alyssa Rosenzweig 2024-11-19 01:15:44 -04:00 committed by Marge Bot
parent f682982e53
commit 0aaf174e31
2 changed files with 3 additions and 0 deletions

View File

@ -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.
*/

View File

@ -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;
}