nouveau/nir: Disable bitfield ops pre-nvc0.
authorEmma Anholt <emma@anholt.net>
Mon, 28 Mar 2022 18:21:26 +0000 (11:21 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 20 Apr 2022 21:58:33 +0000 (21:58 +0000)
There's no hardware instructions for them until then.  These chips don't
expose the extension provinding the GLSL builtins for operations like
bfrev, but NIR can recognize the construct and optimize it to
bitfield_reverse, which pre-nvc0 would then fail to codegen.  Prevents a
regression when moving to nir-to-tgsi.  Other lower_bitfield flags are set
as well for when someone comes along and adds optimizations for them too.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16063>

src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp

index 603c36c..40f02cf 100644 (file)
@@ -3257,14 +3257,14 @@ nvir_nir_shader_compiler_options(int chipset)
    op.lower_sincos = false;
    op.lower_fmod = true;
    op.lower_bitfield_extract = false;
-   op.lower_bitfield_extract_to_shifts = (chipset >= NVISA_GV100_CHIPSET);
+   op.lower_bitfield_extract_to_shifts = (chipset >= NVISA_GV100_CHIPSET || chipset < NVISA_GF100_CHIPSET);
    op.lower_bitfield_insert = false;
-   op.lower_bitfield_insert_to_shifts = (chipset >= NVISA_GV100_CHIPSET);
+   op.lower_bitfield_insert_to_shifts = (chipset >= NVISA_GV100_CHIPSET || chipset < NVISA_GF100_CHIPSET);
    op.lower_bitfield_insert_to_bitfield_select = false;
-   op.lower_bitfield_reverse = false;
-   op.lower_bit_count = false;
-   op.lower_ifind_msb = false;
-   op.lower_find_lsb = false;
+   op.lower_bitfield_reverse = (chipset < NVISA_GF100_CHIPSET);
+   op.lower_bit_count = (chipset < NVISA_GF100_CHIPSET);
+   op.lower_ifind_msb = (chipset < NVISA_GF100_CHIPSET);
+   op.lower_find_lsb = (chipset < NVISA_GF100_CHIPSET);
    op.lower_uadd_carry = true; // TODO
    op.lower_usub_borrow = true; // TODO
    op.lower_mul_high = false;