Commit Graph

212932 Commits

Author SHA1 Message Date
Kenneth Graunke
248050b6d0 brw: Add a quick NIR-based register pressure estimate pass
This tries to calculate an underestimate (lower bound) for the register
pressure at various SIMD widths, by counting live values in the NIR
shader.  This fundamentally won't be accurate, but it can give us an
idea of whether it's even worth trying a certain SIMD-width compile.

Doing this at the NIR level means we:
- Can use SSA structure rather than fuzzy liveness intervals
- Can avoid the backend scheduler aggressively trying to hide latency,
  presenting an overinflated view of the register pressure
- Have divergence information on-hand, making it easier to "scale up"
- Can skip cloning and optimizing NIR for compute shader SIMD widths

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36750>
2025-09-30 19:44:03 +00:00
Kenneth Graunke
5ebd766156 brw: Do most of NIR postprocessing before cloning for SIMD variants
We were doing a lot of NIR work repeatedly for each SIMD variant of
compute and mesh shaders.  Instead, do it once before cloning, and
just do one final optimization loop and out-of-SSA for each.

fossil-db results on Arc B580:

   Totals:
   Instrs: 233771096 -> 233794024 (+0.01%); split: -0.01%, +0.02%
   Subgroup size: 15922768 -> 15922736 (-0.00%); split: +0.00%, -0.00%
   Send messages: 12095619 -> 12098234 (+0.02%); split: -0.00%, +0.02%
   Loop count: 137562 -> 137523 (-0.03%)
   Cycle count: 32600323744 -> 32667411252 (+0.21%); split: -0.06%, +0.27%
   Spill count: 540908 -> 542027 (+0.21%); split: -0.07%, +0.28%
   Fill count: 700938 -> 698983 (-0.28%); split: -0.73%, +0.45%
   Scratch Memory Size: 37266432 -> 37304320 (+0.10%); split: -0.10%, +0.20%
   Max live registers: 72691728 -> 72692987 (+0.00%); split: -0.00%, +0.00%
   Non SSA regs after NIR: 67690309 -> 67688352 (-0.00%); split: -0.01%, +0.00%

   Totals from 3576 (0.45% of 789301) affected shaders:
   Instrs: 6932956 -> 6955884 (+0.33%); split: -0.41%, +0.74%
   Subgroup size: 88816 -> 88784 (-0.04%); split: +0.09%, -0.13%
   Send messages: 329168 -> 331783 (+0.79%); split: -0.02%, +0.81%
   Loop count: 8753 -> 8714 (-0.45%)
   Cycle count: 15153678820 -> 15220766328 (+0.44%); split: -0.14%, +0.58%
   Spill count: 213751 -> 214870 (+0.52%); split: -0.18%, +0.71%
   Fill count: 282616 -> 280661 (-0.69%); split: -1.82%, +1.13%
   Scratch Memory Size: 13056000 -> 13093888 (+0.29%); split: -0.27%, +0.56%
   Max live registers: 834757 -> 836016 (+0.15%); split: -0.11%, +0.26%
   Non SSA regs after NIR: 995033 -> 993076 (-0.20%); split: -0.48%, +0.28%

Looking at a few of the shaders with substantial instruction count
increases, it appears that it is largely due to more loops being
unrolled, which is probably actually a good thing.

The compile time impact of this patch appears to be negligable.
However, doing postprocessing before SIMD cloning allows us to
examine the postprocessed SSA-form NIR for improvements in an
upcoming patch.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36750>
2025-09-30 19:44:02 +00:00
Kenneth Graunke
0712c220ab brw: Split brw_postprocess_nir() into two pieces
brw_postprocess_nir contains a lot of stuff these days.  The first part
does a bunch of lowering and cleanup optimizations in SSA form.  The
second part does some post-optimization lowering and the out-of-SSA
conversion.

We may want to do additional work before the post-optimization/post-SSA
phase.  Splitting this allows us to insert such tasks in the "middle".

For convenience, brw_postprocess_nir() becomes a wrapper which invokes
both parts, so callers can continue working as they did until they have
a reason to do otherwise.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36750>
2025-09-30 19:44:02 +00:00
Kenneth Graunke
71b513a1e9 brw: Lower certain subgroup size modes in brw_preprocess_nir
This allows us to lower known subgroup size cases earlier, giving us
some earlier optimization opportunities.  We would need to know the
actual SIMD width to handle certain cases, but we can just pass 0 here,
which will lead to get_subgroup_size returning 0 - the same as leaving
this unset.  We can come back to that later during the per-SIMD-width
postprocessing.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36750>
2025-09-30 19:44:02 +00:00
Kenneth Graunke
3e493e03cc brw: Move "SSA form" printing to after divergence analysis is run
We were printing the SSA form, then immediately running divergence
analysis.  This patch flips those, so we can see con/div in INTEL_DEBUG
output for SSA form, which is really useful.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36750>
2025-09-30 19:44:02 +00:00
Kenneth Graunke
1b0808adf3 intel/nir: Make ffma peephole optimization preserve fp_fast_math flags
float_controls2 may have marked these as needing to preserve NaN or
other values.  If so, our newly contracted ffma needs to as well.

Fixes dEQP-VK.spirv_assembly.instruction.compute.float_controls2.*.input_args.mat_det_testedWithout_NotNan*
when nir_opt_algebraic is run after this pass.

Cc: mesa-stable
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36750>
2025-09-30 19:44:02 +00:00
Kenneth Graunke
25cb6dfbf7 nir: Add load_simd_width_intel to divergence analysis
For some reason we missed adding this.  This prevents some asserts
from triggering when I call divergence analysis at certain points
in an upcoming patch.

Cc: mesa-stable
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36750>
2025-09-30 19:44:02 +00:00
sjfricke
05ea82a766 nir: Fix gnu-empty-initializer warning
Found with clang 14

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37615>
2025-09-30 19:09:31 +00:00
Alyssa Ross
318b020831 meson.build: set with_clc for asahi tools
Even if both Asahi drivers are disabled, clc is still needed to build
the tools.

Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37636>
2025-09-30 17:37:32 +00:00
Alyssa Ross
14759757dd meson.build: remove dead code
This is already inside an `if with_clc`, so there was no case where
_llvmspirvlib_min_version was set to >= 8.0.1.3.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37635>
2025-09-30 17:02:31 +00:00
Sergio Lopez
2732837591 hk: fix instance reference in vk_free
In hk_create_drm_physical_device() we might call vk_free() passing
pdev->vk.instance->alloc as first argument, but if we've arrived there
via fail_pdev_alloc the instance has not yet been installed into the
physical device, potentially triggering a SIGSEGV.

Fix it by using a direct reference to the instance as first argument.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37642>
2025-09-30 08:24:26 +02:00
Alyssa Ross
f5dd8436b2 docs: update GitLab option name
Link: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/195502
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37637>
2025-09-30 14:46:57 +00:00
David Rosca
fd898f4977 gallium/vl: Fix building vl_stubs
Fixes: 214a431caf ("gallium/vl: Remove mpeg12 shader decoder")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14007
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37629>
2025-09-30 13:40:06 +00:00
Mary Guillemard
095f13109f panvk, vk/meta: Move D/S sanitizing to panvk
In reality, only panvk rely on this and this breaks HK.

Signed-off-by: Mary Guillemard <mary@mary.zone>
Fixes: 42abf00f2b ("vulkan: Handle VK_IMAGE_VIEW_CREATE_DRIVER_INTERNAL_BIT_MESA automatically")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37631>
2025-09-30 13:14:18 +00:00
Ella Stanforth
316eca63a9 v3dv: Add support for 16bit normalised formats
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:43 +00:00
Ella Stanforth
40515312f6 v3dv: Add normalisation flags to the format table
These indicate if we need to apply software packing and unpacking for render
targets of these formats.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:43 +00:00
Ella Stanforth
9e9763cf86 v3dv: Take format plane when packing hw clear color
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:42 +00:00
Ella Stanforth
b597e838c2 v3d: Add support for 16bit normalised formats
This is done using unsigned integer formats combined with in shader
conversion. This is incompatible with hardware blending.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:42 +00:00
Ella Stanforth
aaa858f958 v3d/compiler: Implement 16bit normalised render targets.
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:42 +00:00
Ella Stanforth
c9e9d72cce v3d/compiler: implement normalised to float conversions
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:42 +00:00
Ella Stanforth
082e6369f9 nir: add v3d specific intrinsic normalised to float conversion
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:42 +00:00
Ella Stanforth
9263e1838b v3d/compiler: Lower load_output after logic operations
Fixes: 42154029fc ("v3d/compiler: Implement software blend lowering")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:42 +00:00
Ella Stanforth
0a640f42c5 v3d/compiler: Add unpacking instructions for normalised 16bit formats.
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:41 +00:00
Ella Stanforth
8ad47b67b8 v3d: Fallback to software blend support for formats that do not support blend.
Allows us to support blending for internal formats other than 8n and 16f.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:40 +00:00
Ella Stanforth
ee48e81b26 v3d: Always lower frag color
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:39 +00:00
Ella Stanforth
dfbf1a8e80 v3d: rename msaa resolve
The conditions for being able to do msaa resolve and hardware blending are
identical.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35820>
2025-09-30 12:48:39 +00:00
Simon Perretta
61a9c4f63d pvr, pco: add primitive support for terminate,demote_to_helper}_invocation
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:54 +00:00
Simon Perretta
a1acd6f8d1 pvr, pco: add primitive support for VK_KHR_robustness2.nullDescriptor
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:54 +00:00
Simon Perretta
2a7ebf2ae0 nir/lower_alpha: extend to support dynamic a2c
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:53 +00:00
Simon Perretta
63c4ecfae0 pvr, pco: add remaining support for eds2 & 3
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:53 +00:00
James Fitzpatrick
17468aee4b pvr: add support for (EXT|KHR)_line_rasterization
Signed-off-by: James Fitzpatrick <james.fitzpatrick@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:52 +00:00
James Fitzpatrick
7e11ec20e4 pvr: update WClamp value to 1.0e-13f
Signed-off-by: James Fitzpatrick <james.fitzpatrick@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:52 +00:00
Luigi Santivetti
a48857be7b pvr: propagate image samples when doing a blit from DS surface
Enabling DS resolve attachment entails a blit for a ZLS subtile region, in such
case the TQ needs to know the number of samples in the source surface in order to
pack the texture state.

Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:51 +00:00
leonperianu
9ab273f5ab pvr: add support for VK_KHR_depth_stencil_resolve
This commit enables the VK_KHR_depth_stencil_resolve extension in the PVR
Vulkan driver. Only worth to note that this implementation is based on the
renderpass driver path and it will need a rework as part of the dynamic
rendering enablement.

Signed-off-by: leonperianu <leon.perianu@imgtec.com>
Co-authored-by: Luigi Santivetti <luigi.santivetti@imgtec.com>
Co-authored-by: Ashish Chauhan <ashish.chauhan@imgtec.com>
Co-authored-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:51 +00:00
Luigi Santivetti
6c4883bc9d pvr: restrict the scope of copy_{buffer,image}_to_{image,buffer}
Do not conflate api and internal driver use of copy commands and make the
correct assumptions for the api path, according to the Vulkan spec.

Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:51 +00:00
Luigi Santivetti
2c2fdac093 pvr: improve unemitted resolve attachments readability
Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:51 +00:00
Frank Binns
2e97daec67 pvr: setup Vulkan 1.1 & 1.2 features, properties, version
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:50 +00:00
Frank Binns
b1cb11337a pvr: advertise KHR_spirv_1_4
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:50 +00:00
Simon Perretta
27b329eea3 pvr: add support for VK_KHR_shader_draw_parameters, drawIndirectFirstInstance
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:49 +00:00
Simon Perretta
0134e86375 pco: set lower_device_index_to_zero
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:49 +00:00
Frank Binns
80609b35e1 pvr: advertise KHR_shader_subgroup_extended_types
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:49 +00:00
Simon Perretta
bd96981cad pvr, pco: add minimal support required for Vulkan 1.2 subgroups
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:48 +00:00
Simon Perretta
6dc5e1e109 pco: fully support Vulkan 1.2 image atomics
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:48 +00:00
Simon Perretta
08e3740e07 pvr, pco: support imageCubeArray feature
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:47 +00:00
Simon Perretta
339ba75014 pco: treat all load_consts as 32-bit
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:47 +00:00
Frank Binns
c0df962fa0 pvr: enable KHR_create_renderpass2
The driver already implements the regular render pass functions in terms of the
VK_KHR_create_renderpass2 functions. However, the extension couldn't be
advertised due to missing support for VK_KHR_multiview. Now multiview is
supported, renderpass2 can be advertised as well.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:46 +00:00
Simon Perretta
cb6c921502 pvr, pco: add multiview compiler support, advertise extension
- Pass view index to fragment shader via linked flat varying.
- Use view index instead of layer id for input attachments when required.

Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:46 +00:00
Peter Quayle
9d48088428 pvr: add view index support for vertex shaders
Signed-off-by: Peter Quayle <peter.quayle@imgtec.com>
Co-authored-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:46 +00:00
Peter Quayle
93c7f0f9c0 pvr: various multiview fixes
- Fix ds address offset for multiview.
- Fix multiview depth/stencil address by restoring it after every kick.
- Enable empty tile processing after first subpass for multiview.

Signed-off-by: Peter Quayle <peter.quayle@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:45 +00:00
Luigi Santivetti
a1002a6673 pvr: add initial driver support for VK_KHR_multiview
Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37512>
2025-09-30 12:15:45 +00:00