zink: Add mapping for nir_op_ldexp, but disable it for 64-bit's sake.
authorEmma Anholt <emma@anholt.net>
Wed, 22 Mar 2023 20:11:16 +0000 (13:11 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 6 Apr 2023 02:32:00 +0000 (02:32 +0000)
We previously had GLSL do ldexp lowering to bitops, but NIR can do it
instead.  It's tempting to just pass the NIR op through to the host Vulkan
driver, but to do that we'd need to split up NIR's flag between 32 and
64-bit support, and that's not worth anyone's time for an op we've never
seen used.

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22083>

src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
src/gallium/drivers/zink/zink_compiler.c
src/gallium/drivers/zink/zink_screen.c

index 4339443..7a97c8a 100644 (file)
@@ -2253,6 +2253,7 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu)
    BUILTIN_BINOP(nir_op_imax, GLSLstd450SMax)
    BUILTIN_BINOP(nir_op_umin, GLSLstd450UMin)
    BUILTIN_BINOP(nir_op_umax, GLSLstd450UMax)
+   BUILTIN_BINOP(nir_op_ldexp, GLSLstd450Ldexp)
 #undef BUILTIN_BINOP
 
    case nir_op_fdot2:
index 468b21f..ed6d7d3 100644 (file)
@@ -1252,6 +1252,15 @@ zink_screen_init_compiler(struct zink_screen *screen)
       .lower_extract_word = true,
       .lower_insert_byte = true,
       .lower_insert_word = true,
+
+      /* We can only support 32-bit ldexp, but NIR doesn't have a flag
+       * distinguishing 64-bit ldexp support (radeonsi *does* support 64-bit
+       * ldexp, so we don't just always lower it in NIR).  Given that ldexp is
+       * effectively unused (no instances in shader-db), it's not worth the
+       * effort to do so.
+       * */
+      .lower_ldexp = true,
+
       .lower_mul_high = true,
       .lower_rotate = true,
       .lower_uadd_carry = true,
index 5ff786c..39f08ee 100644 (file)
@@ -1243,6 +1243,8 @@ zink_get_shader_param(struct pipe_screen *pscreen,
       return 0;
 
    case PIPE_SHADER_CAP_LDEXP_SUPPORTED:
+      return 1;
+
    case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS:
    case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS:
       return 0; /* not implemented */