mesa/src/compiler
Job Noorman 30716cc524 nir/lower_explicit_io: add support for offset_shift
The goal here is to generate addresses that are a right-shifted version
of the actual byte address and record the shift amount in the
offset_shift index. While we could just insert a ushr at the end of
deref chains, this will prevent the shift to be optimized away in many
cases. Instead, we try to extract the shift from the array strides and
struct offsets that make up the deref chain, and only insert a ushr when
absolutely necessary (i.e., for casts). This means we have to walk the
entire deref chain at once for accesses that support offset_shift and we
don't use the standard algorithm of replacing each deref one at a time.

To be able to legally right-shift casts, we use the alignment
information and never shift more than what the alignment could support.
It should also be noted that casts generally have two sources: something
provided by the driver (e.g., a Vulkan resource index) or a variable
pointer coming from a phi/bcsel. For the latter, the entire access chain
consists of multiple parts that are ended by either a phi/bcsel or an
access. Only the part the ends in an access is handled by this new
algorithm; the other parts are handled as usual. This is necessary
because we have no way to encode the offset shift or to even know how
much we would be able to shift without knowing how it is accessed.

This commit adds the general implementation for lowering accesses using
offset_shift and adds a compiler option for drivers to enable it for
SSBO accesses.

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35092>
2025-08-20 07:51:30 +00:00
..
clc util: Refactoring util_dl_get_path_from_proc out of clc/clc_helpers.cpp 2025-08-07 21:15:13 +00:00
glsl glsl,gallium,mesa: replace MESA_SHADER_STAGES with MESA_SHADER_MESH_STAGES 2025-08-11 01:44:44 +00:00
isaspec meson: do not compile libisaspec unless used 2025-03-25 08:32:47 +00:00
libcl libcl: avoid calling UNREACHABLE(str) macro without arguments 2025-08-04 23:15:18 +02:00
nir nir/lower_explicit_io: add support for offset_shift 2025-08-20 07:51:30 +00:00
rust all: rename pipe_shader_type to mesa_shader_stage 2025-08-06 10:28:40 +08:00
spirv spirv: Fix RT raygen hit attribute validation error 2025-08-13 10:20:35 +00:00
builtin_types.py compiler: add float8 glsl types 2025-06-23 07:59:24 +00:00
builtin_types_c.py util,vulkan,mesa,compiler: Generate source files with utf8 encoding from mako template 2023-12-07 12:41:07 +00:00
builtin_types_h.py compiler: Generate files with newline at end 2025-06-24 14:01:04 +00:00
glsl_types.c compiler/types: handle BFLOAT16 when decoding blob 2025-08-20 04:12:00 +00:00
glsl_types.h build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
list.h nir: remove unused stuff from list.h 2025-07-31 20:23:04 +00:00
meson.build nir: move list.h outside the glsl directory 2025-07-31 20:23:02 +00:00
shader_enums.c nir,spirv: Add support for SPV_ARM_core_builtins 2025-08-07 11:46:33 +02:00
shader_enums.h nir: add ACCESS_SKIP_HELPERS 2025-08-12 08:56:37 +00:00
shader_info.h all: rename gl_shader_stage to mesa_shader_stage 2025-08-06 10:28:40 +08:00