Module: Mesa Branch: main Commit: 675f4ff596f358bf19f499a6ab06ae035e3eb9c8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=675f4ff596f358bf19f499a6ab06ae035e3eb9c8
Author: Emma Anholt <[email protected]> Date: Wed Mar 22 13:11:16 2023 -0700 zink: Add mapping for nir_op_ldexp, but disable it for 64-bit's sake. 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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22083> --- src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 1 + src/gallium/drivers/zink/zink_compiler.c | 9 +++++++++ src/gallium/drivers/zink/zink_screen.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index 4339443231d..7a97c8a65aa 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -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: diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 468b21fd164..ed6d7d3220a 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -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, diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 5ff786cee3c..39f08ee5c3f 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -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 */
