Job Noorman
273fd18b89
nir/opt_varyings: fix alu def cloning
...
nir_builder_alu_instr_finish_and_insert initialized the def's bit_size
and num_components so we should set them afterwards.
Signed-off-by: Job Noorman <jnoorman@igalia.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Fixes: c66967b5cb ("nir: add nir_opt_varyings, new pass optimizing and compacting varyings")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40651 >
2026-04-03 08:18:08 +02:00
Job Noorman
d56d35aa76
nir/opt_varyings_bulk: add data parameter to optimize callback
...
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/40651 >
2026-04-03 08:18:08 +02:00
Marek Olšák
27a4c58745
nir/tests: test nir_opt_varyings with sysvals
...
Test that view_index is moved, and sample_mask_in isn't.
Acked-by: Pierre-Eric
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40664 >
2026-04-02 14:38:56 +00:00
Marek Olšák
f3e208ee6c
nir/opt_varyings: move expressions with view_index into preceding shaders
...
Example:
Before:
VS output0 = v0
VS output1 = v1
FS output = gl_ViewIndex == 0 ? input0 : input1;
After:
VS output0 = gl_ViewIndex == 0 ? v0 : v1;
FS output = input0;
Acked-by: Pierre-Eric
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40664 >
2026-04-02 14:38:56 +00:00
Marek Olšák
92cf9af827
nir: factor out nir_system_value_from_instr from nir_opt_varyings
...
Acked-by: Pierre-Eric
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40664 >
2026-04-02 14:38:56 +00:00
Marek Olšák
bfc75c0641
nir: return a failure value from nir_system_value_from_intrinsic
...
We need to be able to check whether an intrinsic loads a sysval.
Acked-by: Pierre-Eric
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40664 >
2026-04-02 14:38:56 +00:00
Lionel Landwerlin
b4aaa17a11
nir/lower_io: add index support for load_param_intel
...
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40729 >
2026-04-01 12:56:43 +00:00
Lionel Landwerlin
22b16d54ab
nir: add heap variant of load_param_intel
...
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40729 >
2026-04-01 12:56:43 +00:00
Lionel Landwerlin
4f74d9293f
nir/divergence: handle resource_intel like other intrinsics
...
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40729 >
2026-04-01 12:56:43 +00:00
Georg Lehmann
0975e1513a
nir/opt_large_constants: optimize constant arrays with just two different values
...
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Often, games just use arrays to select between 1.0 and 0.0 or -1.0.
In the case where all values are the same except one index, use a
compare instead of a shift. It's impossible to optimize the shift to
just a compare because of NIR's SM5 shift semantics, but when we know the
array length, it works just fine.
Foz-DB Navi21:
Totals from 3393 (2.96% of 114627) affected shaders:
MaxWaves: 87039 -> 87087 (+0.06%)
Instrs: 4991034 -> 4977962 (-0.26%); split: -0.28%, +0.02%
CodeSize: 27505196 -> 27509988 (+0.02%); split: -0.08%, +0.10%
VGPRs: 156216 -> 154720 (-0.96%)
SpillSGPRs: 812 -> 801 (-1.35%); split: -1.60%, +0.25%
Latency: 38221096 -> 38207053 (-0.04%); split: -0.10%, +0.06%
InvThroughput: 9518564 -> 9469903 (-0.51%); split: -0.52%, +0.01%
VClause: 121340 -> 121370 (+0.02%); split: -0.05%, +0.07%
SClause: 127822 -> 127996 (+0.14%); split: -0.01%, +0.14%
Copies: 437743 -> 437832 (+0.02%); split: -0.40%, +0.43%
Branches: 173910 -> 173893 (-0.01%); split: -0.17%, +0.16%
PreSGPRs: 147137 -> 147957 (+0.56%); split: -0.01%, +0.57%
PreVGPRs: 126313 -> 126296 (-0.01%); split: -0.09%, +0.08%
VALU: 3309713 -> 3288169 (-0.65%); split: -0.66%, +0.01%
SALU: 762369 -> 770904 (+1.12%); split: -0.03%, +1.15%
VMEM: 182394 -> 182392 (-0.00%)
SMEM: 201777 -> 201801 (+0.01%); split: -0.00%, +0.01%
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40539 >
2026-04-01 12:23:18 +00:00
Samuel Pitoiset
98d486ea77
spirv: handle untyped pointer storage class with descriptor heap
...
It's possible with descriptor heap.
Original patch by Faith Ekstrand <faith.ekstrand@collabora.com>.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40731 >
2026-04-01 11:46:16 +00:00
Samuel Pitoiset
1f8be7bfad
spirv: fix OpUntypedVariableKHR with optional data type parameter
...
This would read OOB and crash because data type is optional per the
SPIRV spec.
Original patch by Faith Ekstrand <faith.ekstrand@collabora.com>.
Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40731 >
2026-04-01 11:46:16 +00:00
Georg Lehmann
eff9f00533
nir/search: remove matching variable type
...
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Now unused, and if you really need it use a search helper.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40713 >
2026-04-01 09:52:45 +00:00
Georg Lehmann
5b1405dcbf
nir/opt_algebraic: remove a few non 1bit bool patterns
...
We almost exclusive optimize 1bit booleans nowadays,
so I think these shouldn't be needed.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40713 >
2026-04-01 09:52:45 +00:00
Samuel Pitoiset
e27e41a842
vulkan,spirv: update headers
...
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40721 >
2026-04-01 07:39:37 +00:00
Lionel Landwerlin
d6bc20160e
nir/lower_robust_access: add heap/bindless support
...
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
a7cc97ac86
nir/opt_shrink_stores: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
a075b4f501
nir/lower_helper_writes: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
fed72f015d
nir/gather_info: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
ce1082c026
nir/validate: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
ffeafc9ef1
nir/opt_preamble: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
ca4facb568
nir/opt_group_loads: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
2e969dc5c7
nir/opt_access: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
def3af6171
nir/opt_uniform_atomics: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
4dd3ff8b99
nir/opt_intrinsics: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
e7af65d1fe
nir/divergence_analysis: add missing nir_intrinsic_image_heap_texel_address
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40710 >
2026-03-31 12:42:57 +00:00
Samuel Pitoiset
4cf6cd85e0
nir/lower_image: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40657 >
2026-03-31 10:10:17 +00:00
Samuel Pitoiset
78d1aa018a
nir/opt_move_discards_to_top: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40657 >
2026-03-31 10:10:17 +00:00
Samuel Pitoiset
22e1d1a1f4
nir/opt_sink: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40657 >
2026-03-31 10:10:17 +00:00
Samuel Pitoiset
8a26bbc525
nir/opt_shrink_vectors: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40657 >
2026-03-31 10:10:17 +00:00
Samuel Pitoiset
6479c1092c
nir/lower_mediump: add heap support
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40657 >
2026-03-31 10:10:17 +00:00
Lionel Landwerlin
b81d13bec3
nir/lower_non_uniform: add heap support
...
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40657 >
2026-03-31 10:10:17 +00:00
Lionel Landwerlin
6a89c29029
nir/lower_image_atomics_to_global: add heap support
...
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40657 >
2026-03-31 10:10:17 +00:00
Samuel Pitoiset
fb0647fb25
nir: add texture_heap_offset/sampler_heap_offset to nir_build_tex()
...
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40657 >
2026-03-31 10:10:17 +00:00
Samuel Pitoiset
c4e3380187
nir,treewide: add nir_image_intrinsic_type
...
We have 4 image intrinsic variants now. This enum is useful for
nir_rewrite_image_intrinsic() and it will be used by other NIR passes.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40709 >
2026-03-31 09:10:27 +00:00
Samuel Pitoiset
9d059a60f5
nir: introduce nir_descriptor_type for Vulkan like descriptors
...
This removes a Vulkan dependency in NIR core.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40670 >
2026-03-31 07:16:20 +00:00
Karol Herbst
b7ca34db13
nir: unvendor ac_nir_lower_sin_cos
...
So we can use it for Nvidia.
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40541 >
2026-03-31 01:47:31 +02:00
Karol Herbst
5bb3c9f69c
nir: rename fsin_amd and fcos_amd to a more generic name
...
Nvidia implements both the same way as AMD does, so it makes sense to
allow for code sharing here.
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40541 >
2026-03-31 01:47:29 +02:00
Georg Lehmann
1b6ed1b34e
nir,radv: lower shadow compare gather to 16bit
...
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
The output is 1.0 or 0.0 anyway, so there are no precision issues.
For hardware that has v_fma_mix_f32, the inserted conversions should be free
in most cases.
Foz-DB Navi21:
Totals from 1393 (0.68% of 205005) affected shaders:
MaxWaves: 40612 -> 40660 (+0.12%)
Instrs: 571239 -> 570266 (-0.17%); split: -0.19%, +0.02%
CodeSize: 2933912 -> 2979304 (+1.55%); split: -0.00%, +1.55%
VGPRs: 50504 -> 50256 (-0.49%)
Latency: 9883143 -> 9879335 (-0.04%); split: -0.05%, +0.01%
InvThroughput: 2591073 -> 2570721 (-0.79%); split: -0.79%, +0.00%
VClause: 11600 -> 11551 (-0.42%); split: -0.43%, +0.01%
SClause: 26644 -> 26641 (-0.01%)
Copies: 31434 -> 30556 (-2.79%); split: -3.14%, +0.34%
PreVGPRs: 41762 -> 41509 (-0.61%)
VALU: 405533 -> 404655 (-0.22%); split: -0.24%, +0.03%
SALU: 55576 -> 55575 (-0.00%); split: -0.02%, +0.02%
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40685 >
2026-03-30 18:54:22 +00:00
Georg Lehmann
027503cac2
nir/lower_tex: fix lowering 16bit textureGatherOffsets
...
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40685 >
2026-03-30 18:54:22 +00:00
Rhys Perry
213470b477
util: allow any key for hash tables
...
We sometimes use this with non-pointer keys.
This removes a footgun at the cost of a larger entry size on 32-bit.
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40318 >
2026-03-30 11:29:44 +00:00
Faith Ekstrand
dc44b2e916
spirv: Mark DescriptorHeapKHR as implemented
...
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40649 >
2026-03-30 06:51:26 +00:00
Konstantin Seurer
b127c11be9
spirv,nir: Preserve more information about the descriptor type
...
Descriptor heap mappings need the information to selectively apply
mappings (descriptor type masks).
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40649 >
2026-03-30 06:51:25 +00:00
Samuel Pitoiset
df515cfb5b
nir: make nir_variable::descriptor_set a 32-bit variable
...
With descriptor heap there is no limit.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40649 >
2026-03-30 06:51:25 +00:00
Faith Ekstrand
f35839a6bc
spirv: Handle OpBufferPointerKHR
...
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40649 >
2026-03-30 06:51:25 +00:00
Faith Ekstrand
2366bd9cde
spirv: Handle ArrayStrideIdKHR and OffsetIdKHR decorations
...
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40649 >
2026-03-30 06:51:25 +00:00
Faith Ekstrand
b42b7c8f60
spirv,vulkan: Implement OpConstantSizeOfKHR
...
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40649 >
2026-03-30 06:51:24 +00:00
Faith Ekstrand
ad9f92ba10
spirv: Handle OpTypeBufferKHR
...
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40649 >
2026-03-30 06:51:23 +00:00
Faith Ekstrand
bc031b76d8
spirv: Add new SPV_KHR_descriptor_heap Builtins
...
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40649 >
2026-03-30 06:51:23 +00:00
Faith Ekstrand
719cb88748
spirv: Improve the error message for invalid SPIR-V sections
...
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40649 >
2026-03-30 06:51:23 +00:00