From a0b1e07976a1549fea44b426c1c652185d19791d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 3 Jan 2025 03:47:52 -0800 Subject: [PATCH] brw: Make get_nir_src_imm() usable for non-32-bit-sizes. We return an immediate for 32-bit constant values, but fall back to calling get_nir_src() for other values, as 64-bit, and even 8-bit immediates have odd restrictions. We could probably support 16-bit here without too many issues, but we leave it be for now. This makes it usable for case where we'd like to get constants for 32-bit values but where it may be a different bit-size too. Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/brw_fs_nir.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index d87d591bc1f..9cd910f1464 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -1969,19 +1969,12 @@ get_nir_src(nir_to_brw_state &ntb, const nir_src &src, int channel) } /** - * Return an IMM for constants; otherwise call get_nir_src() as normal. - * - * This function should not be called on any value which may be 64 bits. - * We could theoretically support 64-bit on gfx8+ but we choose not to - * because it wouldn't work in general (no gfx7 support) and there are - * enough restrictions in 64-bit immediates that you can't take the return - * value and treat it the same as the result of get_nir_src(). + * Return an IMM for 32-bit constants; otherwise call get_nir_src() as normal. */ static brw_reg get_nir_src_imm(nir_to_brw_state &ntb, const nir_src &src) { - assert(nir_src_bit_size(src) == 32); - return nir_src_is_const(src) ? + return nir_src_is_const(src) && nir_src_bit_size(src) == 32 ? brw_reg(brw_imm_d(nir_src_as_int(src))) : get_nir_src(ntb, src); }