Commit graph

205591 commits

Author SHA1 Message Date
Chen, Phoebe
f2e65c02e6 amd/vpelib: Fix memory leak from segment ctx
[WHY]
There is potential memory leak from vpe_alloc_segment_ctx.
This memory leak occurs only in multi-frame VPE tests where
between vpe_create and vpe_destroy, multiple calls are made
to vpe_check_support that allocates new segment context without
releasing the old one.

[HOW]
Allocate segment_ctx only when it is not already allocated. If it is
already allocated, check whether re-allocation is needed. If not, skip
the allocation.

Signed-off-by: Phoebe Chen <phoebe.chen@amd.com>
Reviewed-by: Roy Chan <Roy.Chan@amd.com>
Reviewed-by: Jesse Agate <Jesse.Agate@amd.com>
Acked-by: ChuanYu Tseng <ChuanYu.Tseng@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35012>
2025-05-16 11:33:08 +08:00
Leder, Brendan Steve
c1a3d021f3 amd/vpelib: Make BG gen stream idx adjustable
Update BKGR API

Change bg generation code so bg gen isn't hard-coded to stream 0, as
certain cases result in bg being generated at different stream.

Reviewed-by: Roy Chan <Roy.Chan@amd.com>
Reviewed-by: Evan Damphousse <Evan.Damphousse@amd.com>
Acked-by: ChuanYu Tseng <ChuanYu.Tseng@amd.com>
Signed-off-by: Leder, Brendan Steve <BrendanSteve.Leder@amd.co>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35012>
2025-05-16 11:33:08 +08:00
Faith Ekstrand
5b34895e81 nak/dce: Use BitSet for live phis and SSA values
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
2025-05-15 22:28:31 -04:00
Faith Ekstrand
52dcb1c9c1 nak: Add a Phi struct type
Instead of passing raw u32's arround, this adds a new Phi wrapper struct
which is treated as opaque by most of the rest of the compiler.  This is
similar to what we're already doing with Label and SSAValue.  This also
gives us the opportunity to properly document NAK's phi model.

Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
2025-05-15 22:28:31 -04:00
Faith Ekstrand
531070cf91 nak: Use op instead of phi when referring to OpPhiSrcs or OpPhiDsts
This will reduce name conflicts in the next patch

Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
2025-05-15 22:28:31 -04:00
Faith Ekstrand
5f5ce00410 nak/repair_ssa: Rename Phi to PhiTracker
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
2025-05-15 22:28:31 -04:00
Faith Ekstrand
fc54e6e1d2 nak/liveness: Use typed bitsets
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
2025-05-15 22:28:31 -04:00
Faith Ekstrand
afb11a5a9e nak/liveness: Use an SSA value as the last_use HashMap key
We're not saving ourselves anything by using just the index.

Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
2025-05-15 22:28:31 -04:00
Faith Ekstrand
56f06a072c compiler/rust/bitset: Make BitSet a generic container type
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
2025-05-15 22:28:31 -04:00
Faith Ekstrand
323769d3bb compiler/rust,nak: Rename BitSet::get() to contains()
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
2025-05-15 22:14:12 -04:00
Faith Ekstrand
20d247d754 nak: Use Default::default() for BitSet constructors
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
2025-05-15 22:14:12 -04:00
Mel Henning
ed658a2d3a compiler/rust/cfg: Add a hash func type parameter
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
and switch nak over to rustc-hash for CFGBuilder

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34865>
2025-05-16 01:40:05 +00:00
Mel Henning
f5231e0677 nak: Also use rustc-hash for UnionFind
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34865>
2025-05-16 01:40:04 +00:00
Mel Henning
43c3f5a8db nak: Switch most Hash{Set,Map} uses to rustc-hash
We shouldn't need to worry about HashDoS attacks because:
 1. All of these keys are compiler-assigned IDs which makes it very
    difficult to force collitions, and
 2. Anyone who can hit the NAK compiler backend can already use CPU
    power by spamming shader compiles or using O(n^2) behavior in
    shader opt loops
As a result, we can afford to use a weaker hash function without
randomization.

This decreases total compile times by around 12% on shaderdb
(from 8113.74 user to 7115.47 user) on my machine.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34865>
2025-05-16 01:40:04 +00:00
Mel Henning
c1f979d84a nak: Add a dependency on rustc-hash
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34865>
2025-05-16 01:40:04 +00:00
Mel Henning
b4b557c9ef nak: s/HashSet::new()/Default::default()/
wherever this doesn't result in type inference failing.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34865>
2025-05-16 01:40:04 +00:00
Mel Henning
7a47f29d6d nak: s/HashMap::new()/Default::default()/
wherever this doesn't result in type inference failing.
Using default() makes it easier to swap out the underlying type.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34865>
2025-05-16 01:40:04 +00:00
Mel Henning
bb62044836 nak: rustfmt ir_proc.rs
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34865>
2025-05-16 01:40:04 +00:00
Mel Henning
bfe8340296 nouveau/headers: Ignore PermissionError in rustfmt
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13172
Fixes: 591b5da4 ("nouveau/headers: Run rustfmt on generated files")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35008>
2025-05-16 01:08:07 +00:00
Mel Henning
da22094593 nouveau/headers: Run rustfmt after file is closed
If we run a subprocess while the file is still open, we may not have
flushed the file contents to disk.

Fixes: 591b5da4 ("nouveau/headers: Run rustfmt on generated files")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35008>
2025-05-16 01:08:07 +00:00
Kenneth Graunke
20222cd956 anv: Use the new nir_opt_acquire_release_barriers pass
Improves performance of Phasmophobia with the "Eye Adaptation" video
setting enabled on Arc B570 by about 9.5%.

fossil-db results on Battlemage:

   Totals:
   Instrs: 148797922 -> 148797865 (-0.00%)
   Send messages: 7066341 -> 7066317 (-0.00%)
   Cycle count: 21459978352 -> 21459975048 (-0.00%)

   Totals from 8 (0.00% of 574410) affected shaders:
   Instrs: 4633 -> 4576 (-1.23%)
   Send messages: 479 -> 455 (-5.01%)
   Cycle count: 611886 -> 608582 (-0.54%)

Observed to cut 15% of sends in a Phasmophobia shader, 8.3% in a Far Cry
New Dawn shader, 7% in a Borderlands 3 DX11 shader, and 3.4-3.7% of
sends in a few Witcher 3 and Dark Souls 3 shaders.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33504>
2025-05-16 00:29:13 +00:00
Kenneth Graunke
deb1d47155 nir: Add a new optimization for acquire/release atomics & barriers
Some shaders contain back-to-back atomic accesses in SPIR-V with
AcquireRelease semantics.  In NIR, we translate these to a release
memory barrier, the atomic, then an acquire memory barrier.

This results in a lot of unnecessary memory barriers in the middle
of the sequence of atomics:

   0. Release barrier
   1. Atomic
   2. Acquire barrier
   3. Release barrier
   4. Atomic
   5. Acquire barrier
   6. Release barrier
   7. Atomic
   8. Acquire barrier

In the absence of loads/stores, and when the atomic destinations are
unused, these barriers in-between atomics shouldn't be required.

This optimization pass would drop them (lines 2-3 and 5-6 above) while
leaving the first and last barriers (0 and 8), so the sequence remains
synchronized against other access elsewhere in the program.

One common example where this occurs is a sequence of min and max
atomics to clamp a certain memory location's value within a range.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33504>
2025-05-16 00:29:13 +00:00
Rob Clark
65e18a8494 freedreno: Fix shader-clock when kernel exposes UCHE_TRAP_BASE
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Fixes: 4b1b4ee10c ("freedreno,tu: Read and pass to compiler uche_trap_base)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35010>
2025-05-15 22:27:17 +00:00
Yinjie Yao
089e2cb6f9 radeonsi: Disable av1 cdef_channel_strength for VCN4
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
VCN4 hardware doesn't support this feature, it can only be supported in VCN5.

Signed-off-by: Yinjie Yao <yinjie.yao@amd.com>
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35004>
2025-05-15 18:52:08 +00:00
Seán de Búrca
10fad5081d nouveau: implement Default for Push
By convention, a struct with a `new()` method which has no parameters
should have a `Default` impl which calls `new()`.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34372>
2025-05-15 17:52:32 +00:00
Seán de Búrca
f4f4b25d25 nak,nil: style cleanup
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34372>
2025-05-15 17:52:32 +00:00
Seán de Búrca
adecea4af9 nak,nouveau: adjust function/method signatures to better match convention
v2: restore `to_cssa()` naming

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34372>
2025-05-15 17:52:32 +00:00
Seán de Búrca
e559c63fd8 nak,nil: elide lifetimes where possible
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34372>
2025-05-15 17:52:32 +00:00
Seán de Búrca
e4f045df58 nak,nil: avoid explicit returns at the end of functions
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34372>
2025-05-15 17:52:32 +00:00
Seán de Búrca
e32c82d0f5 nak: use standard methods and macros to improve readability
v2: Leave `Op::is_branch()` and `Op::no_scoreboard()` matches alone
v3: Revert additional changes with unclear readability

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34372>
2025-05-15 17:52:32 +00:00
Seán de Búrca
ba2b9345e8 nak: use Option propagation instead of explicit let-else clauses
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34372>
2025-05-15 17:52:32 +00:00
Seán de Búrca
f2cc77dca8 nak: collapse extraneous conditional branches
v2: Revert collapsing of branches per review

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34372>
2025-05-15 17:52:32 +00:00
Seán de Búrca
451b37820d nak: remove unnecessary casts and conversions
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34372>
2025-05-15 17:52:32 +00:00
Seán de Búrca
e4d895f0e1 rusticl: fix build with clippy driver
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35002>
2025-05-15 09:35:17 -07:00
Seán de Búrca
35af55a2a7 rusticl: replace map_or(false, f) with is_some_and(f)
A new clippy lint fails on this pattern, causing build errors on
versions >= 1.84.0. `is_some_and()` is stable from 1.70.0.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35002>
2025-05-15 09:35:08 -07:00
José Roberto de Souza
cb6f96a1e8 anv: Remove a '#if GFX_VER >= 30' block inside of a else of '#if GFX_VERx10 >= 125'
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Removing deadcode.

Reviewed-by: Lucas Fryzek <lfryzek@igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34988>
2025-05-15 15:25:12 +00:00
José Roberto de Souza
37b42ef648 anv: Drop '#if GFX_VERx10 >= 125' inside of '#if GFX_VERx10 >= 125'
This is just redundant.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34988>
2025-05-15 15:25:12 +00:00
José Roberto de Souza
bca12800aa iris: Restrict platforms that needs Wa_1604061319
It was being applied even to platforms that don't require it.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34988>
2025-05-15 15:25:12 +00:00
José Roberto de Souza
3cd972a2d3 anv: Enable preemption due 3DPRIMITIVE in GFX 12
The issues preventing it to be enabled were fixed so now we can enable
it but we need also to enable workaround 16013994831 back again.

Cc: mesa-stable
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34988>
2025-05-15 15:25:12 +00:00
José Roberto de Souza
2432d6677e anv: Implement missing part of Wa_1604061319
Description of this workaround are not clear but looking at Iris
implementation we need to emit all 3DSTATE_PUSH_CONSTANT_ALLOC_XS if
any 3DSTATE_PUSH_CONSTANT_ALLOC_XS is emitted.

Cc: mesa-stable
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34988>
2025-05-15 15:25:12 +00:00
Ashley Smith
a1376449c8 panvk: Expose support for multiview on v7
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34832>
2025-05-15 14:04:29 +00:00
Ashley Smith
4171917210 panvk: Add support for VK_KHR_multiview on v7
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34832>
2025-05-15 14:04:29 +00:00
Rob Clark
d8ed4f14e6 freedreno/ir3: Fix tess/geom asan error
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Fixes: ee0ee2a317 ("ir3: don't sync every TCS/GEOM block")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34989>
2025-05-15 12:46:16 +00:00
Georg Lehmann
3f70433ff0 aco: add type information for operands/definitions
More information available for use in the optimizer.

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29695>
2025-05-15 12:17:17 +00:00
Corentin Noël
6c1c116a0f virgl: Avoid possible double free when destroying the hw resource
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
When a resource is un-referenced, the reference count is decremented,
and intentionally no lock is acquired. This can result in the following
race condition when a resource is created from a handle:

```
[Thread] Operation
[0] Create resource from handle for the first time, refcount set to 1
[0] resource is unreferenced, refcount is decremented to 0 (intentionally
    no mutex is locked)
[0] before entering virgl_hw_res_destroy to lock
    virgl_drm_winsys::bo_handles_mutex the thread yields
[1] Create resource from handle pulls the resource from
     virgl_drm_winsys::bo_handles, refcount is incremented to 1
[1] resource is unreferenced, refcount is decremented to 0
[1] Enter virgl_hw_res_destroy,
[1] acquire the lock on virgl_drm_winsys::bo_handles_mutex
[1] check reference count to be 0, yes -> the resource is destroyed
[1] release the lock on virgl_drm_winsys::bo_handles_mutex
[0] Enter virgl_hw_res_destroy,
[0] acquire the lock on virgl_drm_winsys::bo_handles_mutex
[0] Here the res pointer already points to freed memory
[0] check reference count to be 0, yes -> the resource is destroyed (again!)
double free or corruption (!prev)
```

To work around this race condition, keep track of the number of times
the resource was pulled from virgl_drm_winsys::bo_handles to see whether
it has to be kept alive despite the reference count being zero.

This can be reproduced with the `spec@ext_image_dma_buf_import@ext_image_dma_buf_import-refcount-multithread`
piglit test.

Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34809>
2025-05-15 10:38:13 +00:00
Mary Guillemard
1c57581856 pan/lib: Make pan_shader.c not GENX
We move pan_raw_format_mask_midgard to pan_format.c instead making
pan_shader.c not depending on any GENX.

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Olivia Lee <olivia.lee@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34895>
2025-05-15 10:41:07 +02:00
Mary Guillemard
0bb9df9d33 pan/lib: Make pan_shader_get_compiler_options not GENX
Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Olivia Lee <olivia.lee@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34895>
2025-05-15 10:40:57 +02:00
Mary Guillemard
7158f2eb8b pan/lib: Make pan_shader_compile not GENX
Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Olivia Lee <olivia.lee@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34895>
2025-05-15 10:40:47 +02:00
Mary Guillemard
1fa13ceb74 pan/lib: Move pan_fixup_blend_type to pan_blend.c
Also move bifrost_blend_type_from_nir to pan_blend.c, rename it and
makes it not GENX.

This part is related to blend so it makes more sense to have it there
and this will allow us to make pan_shader.c not GENX.

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Olivia Lee <olivia.lee@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34895>
2025-05-15 10:40:36 +02:00
Mary Guillemard
b3f8c955a7 pan/genxml: Add Register File Format to common.xml
This was added in v6+ and never changed.
This will allow us to remove GENX code logic that is identical.

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Olivia Lee <olivia.lee@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34895>
2025-05-15 10:40:23 +02:00