mesa/src/gallium/auxiliary/nir
Maaz Mombasawala 3da0774be1 nir: Add option to preserve double immediates in tgsi shader.
The nir to tgsi translator flattens all constants in the nir shader into uint32
immediates. In the svga driver, the vgpu10 shader translator then packs all
these immediates into a constant buffer, and also optimizes it to prevent
repetitions by only emitting a 32-bit constant once.
This can cause problems with double sized constants, since either the lower or
higher 32-bits of different 64-bit constant can be identical, and in the constant
buffer that repeating 32-bit value will be emitted only once, so a 64-bit
constant gets split into two non-contiguous 32-bit values.
When this 64-bit constant is then invoked by a double instruction live ddiv or
dmul, the source register can now have invalid swizzles like .xz or .xw since
its 32-bit components are not contiguous.
We have seen this happen in the piglit test -
spec@arb_gpu_shader_fp64@execution@glsl-fs-loop-unroll-mul-fp64
which emits invalid swizzle values for double instructions.

To fix this, introduce a new option in nir to tgsi shader translator that
preserves uint64 constants. When a 64-bit immediate is translated into svga
shader code, its 32-bit components are contiguous and aligned in the constant
buffer, so accessing them only emits valid swizzles .xy and .zw.

Other drivers using the nir to tgsi shader translater should not see any change
in the tgsi shader emitted unless they too explicitly invoke the
keep_double_immediates option like svga.

Signed-off-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33749>
2025-03-11 23:28:33 +00:00
..
nir_draw_helpers.c Fix copy-and-paste bug in nir_lower_aapoint_impl 2024-11-26 18:12:07 +00:00
nir_draw_helpers.h gallium/draw: Enable polygon stipple NIR helpers to generate bool1 or bool32 Booleans 2023-01-28 20:42:32 -08:00
nir_to_tgsi.c nir: Add option to preserve double immediates in tgsi shader. 2025-03-11 23:28:33 +00:00
nir_to_tgsi.h nir: Add option to preserve double immediates in tgsi shader. 2025-03-11 23:28:33 +00:00
nir_to_tgsi_info.c ntt: handle interp intrinsics as derefs 2023-08-15 11:54:05 +00:00
nir_to_tgsi_info.h meson: always define {,DRAW_}LLVM_AVAILABLE one way or the other 2023-12-24 10:01:39 +00:00
pipe_nir.h gallium: add pipe_shader_from_nir helper 2023-11-21 20:14:35 +00:00
tgsi_to_nir.c tnn: nir: Don't use deprecated NIR_PASS_V macro anymore 2025-03-06 03:29:21 +00:00
tgsi_to_nir.h ttn: Don't include full nir.h where not necessary. 2025-02-12 22:33:07 +01:00