Commit graph

2895 commits

Author SHA1 Message Date
Mel Henning
46130bc721 util/rmq: Fix uninitialized read in preprocess
We were previously always reading table->width elements from the previous
row in this loop, but we write fewer entries than that to the current
row. Fix this by adjusting the element count.

Fixes: 0d07b86073 ("util: Add range_minimum_query")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14593
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
(cherry picked from commit 4171161227)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39462>
2026-01-08 07:49:53 -08:00
Georg Lehmann
769f6674af util: add IEEE 754-2019 min/max number
fmin/fmax are not signed zero correct.

The name is taken from RDNA4's ISA, because the full IEEE name is a bit long.

Cc: mesa-stable

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
(cherry picked from commit f68b891a81)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39462>
2026-01-06 08:09:50 -08:00
Vinson Lee
a96da583fa util/blob: Fix const correctness warning in blob_read_string
Fix compiler error:

  ../src/util/blob.c:344:8: error: assigning to 'uint8_t *' from
  'const void *' discards qualifiers
  [-Werror,-Wincompatible-pointer-types-discards-qualifiers]

glibc now provides C23-style type-generic string functions. memchr
returns const void * when passed a const void * argument. Update nul
declaration to const since it's only used to find the null terminator
position and calculate a size.

Fixes: 1c9877327e ("glsl: Add blob.c---a simple interface for serializing data")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
(cherry picked from commit b40850b24a)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39462>
2026-01-06 08:09:32 -08:00
Vinson Lee
283cb22720 util/u_printf: Fix const correctness in util_printf_next_spec_pos
Fix compiler error:

../src/util/u_printf.c:75:13: error: initializing 'char *' with an
expression of type 'const char *' discards qualifiers
[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
   75 |       char *spec_pos = strpbrk(str_found, "cdieEfFgGaAosuxXp%");
      |             ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

glibc now provides C23-style type-generic string functions. strpbrk
returns const char * when passed a const char * argument. Update
spec_pos declaration to match.

Fixes: 6d263ff5a3 ("util: Convert util/u_printf.cpp to util/u_printf.c")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
(cherry picked from commit c576d64801)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39117>
2025-12-28 18:58:25 -08:00
Tapani Pälli
5ac2605b9d anv/drirc: disable Xe2 CCS drm modifiers for GTK engine
Cc: mesa-stable
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
(cherry picked from commit 2418c91537)

Conflicts:
	src/util/driconf.h

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39117>
2025-12-17 14:12:40 -08:00
Janne Grunau
cd707cc449 util/driconf/asahi: Override GL renderer for web browsers
Several web sites block clients with "Apple" in the WebGL renderer
string if the reported OS is not one of Apple's.
This check seems to implemented via a 3rd party product which is slowly
rolled out over more web sites. Instead of playing whack-a-mole with
web sites in multiple browsers override the OpenGL renderer in mesa for
known browsers.

Backport-to: 25.3
Signed-off-by: Janne Grunau <j@jannau.net>
(cherry picked from commit f912db3f8d)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39003>
2025-12-08 09:25:38 -08:00
Samuel Pitoiset
e4049a3a07 radv: add radv_hide_rebar_on_dgpu and enable for Red Dead Redemption 2
RDR2 VRAM memory management when resizable BAR is enabled seems
incorrect because it keeps allocating VRAM without freeing anything.

This introduces a drirc option to emulate a fake carveout of 256MiB to
workaround this game bug. This also adjust memory budgets by
distributing it between visible and invisible because AMDGPU reports
the same value for both when REBAR is enabled.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12091
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39003>
2025-12-04 20:41:10 +00:00
Timothy Arceri
37ae6d445a util/driconf: add Cursemark workaround
Fixes gpu hang on radeonsi and corrupt rendering on iris.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14392
Cc: mesa-stable

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
(cherry picked from commit b75cd07265)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39003>
2025-12-04 09:15:33 -08:00
Sushma Venkatesh Reddy
e6a8e1321b drirc: Add anv_assume_full_subgroups for Detroit: Become Human
Add workaround to assume full 32-thread subgroups. This fixes rendering
corruption when running the Detriot: Become Human game using anv driver.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14120

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
(cherry picked from commit 36d7cd0514)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38803>
2025-12-03 22:24:03 +00:00
Tapani Pälli
1ee375555c anv: add vk_wsi_disable_unordered_submits and enable for GTK
See radv change 0d9d45db4e for further explanation.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14354
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
(cherry picked from commit b2b5e83894)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38803>
2025-12-02 11:00:27 -08:00
Gurchetan Singh
27a88241ba util: fix arithmetic on a pointer to void warning
Otherwise, the following error is observed:

src/util/cache_ops_x86_clflushopt.c:40:22:
   error: arithmetic on a pointer to void is a GNU extension [-Werror,-Wgnu-pointer-arith]
   40 |    void *end = start + size;
      |                ~~~~~ ^
src/util/cache_ops_x86_clflushopt.c:44:9:
  error: arithmetic on a pointer to void is a GNU extension [-Werror,-Wgnu-pointer-arith]
   44 |       p += cpu_caps->cacheline;
      |       ~ ^

This works with GNU extension enabled, but does lead to warnings
with Clang.

v2: Add to trial_c + trial_cpp checks (Erik)
v3: use c_msvc_compat_args to avoid fixing other instances of this issue (Erik)

Fixes: 555881e574 ("util/cache_ops: Add some cache flush helpers")
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
(cherry picked from commit 14cfe14626)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38803>
2025-12-02 11:00:27 -08:00
Timothy Arceri
0e019bd754 util/driconf: Add linux version of Penumbra fixes
Cc: mesa-stable
(cherry picked from commit d10036362f)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38803>
2025-12-01 09:16:52 -08:00
Tapani Pälli
e6c814c448 drirc: set intel_disable_threaded_context for Amnesia The Bunker
Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14084
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
(cherry picked from commit 21f646d196)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38803>
2025-12-01 09:16:37 -08:00
Tapani Pälli
1f1f0d5ad6 drirc/iris: add drirc to disable threaded context
Cc: mesa-stable
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
(cherry picked from commit 4daabf76b4)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38803>
2025-12-01 09:16:36 -08:00
Samuel Pitoiset
48b0dd2892 radv: add vk_wsi_disable_unordered_submits and enable for GTK
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
GTK is missing a semaphore between QueueSubmit() and QueuePresent()
causing the WSI submit to be "unordered" and to immediately signal the
semaphores (because it's missing a wait semaphore in QueuePresent()).

The workaround is to disable unordered WSI submits until GTK fixes it
properly.

Cc: "25.3"
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14087
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
(cherry picked from commit 0d9d45db4e)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38432>
2025-11-14 08:36:53 -08:00
Sviatoslav Peleshko
a407dc6d83 driconf: Add vertex_program_default_out option for Penumbra: Overture
Penumbra's vertex program Diffuse_EnvMap_Reflect_vp.cg produces 3-component
texture coordinates and primitive colors while using the FF fragment
program. Add this WA to fix the misrenderings.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14170
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
(cherry picked from commit 5af8abbf8b)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38432>
2025-11-13 08:10:32 -08:00
Sviatoslav Peleshko
4a0cb910e4 mesa,driconf: Add WA to initialize vertex program outputs to vec4(0,0,0,1)
Per ARB_vertex_program spec result registers are 4-component and initially
undefined, and the FF fragment program expects its intputs to be
4-component too. So, if the client's vertex program does not write the
whole vector it will cause misrenderings unless the same client also
supplies fragment program that expects less than 4 componens.

This commit adds a workaround that initializes results to vec4(0, 0, 0, 1)
which seems to be an expected behavior for such clients.

Cc: mesa-stable
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
(cherry picked from commit f03432c81a)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38432>
2025-11-13 08:10:31 -08:00
Georg Lehmann
7d4557bae8 radv: do not report wave32 in gl_SubgroupSize for Doom Dark Ages
Some checks failed
macOS-CI / macOS-CI (dri) (push) Has been cancelled
macOS-CI / macOS-CI (xlib) (push) Has been cancelled
The shaders in question use:

(memory_load + (gl_SubgroupSize - 1)) & ~(gl_SubgroupSize - 1)

My guess is that this is supposed to be the subgroup size of whatever
produced the value, not the subgroup size in this shader.
And because in the consumer the workgroup size is 32, we use wave32.

Fixes: a2d3cbac2a ("radv: determine subgroup/wave size early")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14187

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
(cherry picked from commit 83e9ae2d5c)

Conflicts:
	src/amd/vulkan/radv_instance.c
	src/amd/vulkan/radv_instance.h
	src/util/driconf.h

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
2025-11-05 10:18:26 -08:00
Lionel Landwerlin
30678337dd u_trace: reserve chunk space before emitting copies
Some implementations can emit tracepoints when copying u_trace
buffers. It's important to reserve the slots we want to copy into
before emitting the copies so that both processes don't clash with one
another.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
(cherry picked from commit df5f92d114)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
2025-11-04 10:16:42 -08:00
Samuel Pitoiset
1e885e7a88 radv: add a workaround for illegal depth/stencil descriptors with No Man's Sky
Using descriptors with both depth and stencil aspects is illegal in
Vulkan and this hangs the GPU.

Use NULL descriptors to mitigate the issue. Note that AMDVLK also
ignores them.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13325
Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
(cherry picked from commit cb4e0c4140)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
2025-10-31 12:07:13 -07:00
Paul Gofman
a46307a732 driconf: add a workaround for Investigation Stories : gunsound
CC: mesa-stable
(cherry picked from commit 63aec75981)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
2025-10-31 12:07:11 -07:00
Eric Engestrom
9aeac1e0a7 util/meson: don't build libmesa_util_clflush unless needed
Fixes: efbecd93ba ("util: Build util/cache_ops_x86.c with -msse2")
(cherry picked from commit 0fe0acd4c3)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
2025-10-30 12:14:05 -07:00
Eric Engestrom
46f0422165 util/meson: don't build libmesa_util_clflushopt unless needed
Fixes: 555881e574 ("util/cache_ops: Add some cache flush helpers")
(cherry picked from commit ccf33664e8)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
2025-10-30 12:14:04 -07:00
Alyssa Rosenzweig
3ce875a2d0 anv: use D3D-compatible texturing for Proton
Intel & AMD Direct3D drivers modify their rounding behaviour for texturing to
match Direct3D expectations. Such behaviour is not conformant in Vulkan, and
Intel hardware lacks a reasonable way to get NVIDIA's behaviour (which uniquely
works for Vulkan & Direct3D). The second best choice is to use
Direct3D-compatible behaviour for Proton (via driconf) and our current
Vulkan-conformant behaviour everywhere else. Given the APIs diverge and there is
no Vulkan extension to control the behaviour explicitly, driconf'ing on the
engineName is the reasonable solution.

anv already has a anv_force_filter_addr_rounding driconf option to force
Direct3D behaviour for certain Direct3D titles. Here we simply apply it to all
D3D10+ titles, aligning us with the Windows driver.

Note that D3D9 does not have this behaviour. We therefore use standard Vulkan
behaviour for D3D9 to avoid breaking D3D9 titles, even though the engineName is
the same as D3D10+.

This is the same solution radv uses, they call it radv_disable_trunc_coord. We
could unify the driconf entries later.

See https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38098#note_3166306
for a more detailed analysis, as well as the linked references:

   https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27337
   https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25911
   https://github.com/HansKristian-Work/vkd3d-proton/pull/1884

This fixes misrendering in piles of Direct3D games run on anv via Proton,
including Assassin's Creed Valhalla.

Cc: mesa-stable
Closes: #13886
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Co-authored-by: Calder Young <cgiacun@gmail.com>
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
(cherry picked from commit 7a71952762)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
2025-10-30 12:13:52 -07:00
Taras Pisetskyi
5ae8474029 drirc/anv: force_vk_vendor=-1 for Wuthering Waves
Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12459

Signed-off-by: Taras Pisetskyi <taras.pisetskyi@globallogic.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
(cherry picked from commit dcd9b90aff)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38167>
2025-10-27 09:34:33 -07:00
Mauro Rossi
fb2273df78 util: Fix gnu-empty-initializer error
Fixes the following building error happening with clang:

../src/util/os_file.c:291:29: error: use of GNU empty initializer extension [-Werror,-Wgnu-empty-initializer]
   struct epoll_event evt = {};
                            ^
1 error generated.

Fixes: 17e28652 ("util: mimic KCMP_FILE via epoll when KCMP is missing")
Cc: "25.3"
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
(cherry picked from commit 7bbbfa6670)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38167>
2025-10-24 07:55:03 -07:00
Faith Ekstrand
0182cde848 util: Build util/cache_ops_x86.c with -msse2
__builtin_ia32_clflush() requires -msse2 so we need to set -msse2 at
least for building that file.  Fortunately, there are no GPUs that
actually need userspace cache flushing that can ever be bolted onto a
pre-SSE2 x86 CPUs.

Fixes: 555881e574 ("util/cache_ops: Add some cache flush helpers")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14134
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
(cherry picked from commit efbecd93ba)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38010>
2025-10-22 09:03:38 -07:00
Faith Ekstrand
94ec7c686d util: Don't advertise cache ops on x86 without SSE2
Fixes: 555881e574 ("util/cache_ops: Add some cache flush helpers")
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
(cherry picked from commit 3739d7a90c)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38010>
2025-10-22 09:03:37 -07:00
Faith Ekstrand
a47184e396 util/cache_ops/x86: Call util_get_cpu_caps() less
This also makes all the paths a bit more clear because we only ever
clflushopt on the clflusopt paths and only ever clflush on the clflush
paths.  It's really not much more code or logic duplication.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37803>
2025-10-16 01:19:44 +00:00
Faith Ekstrand
555881e574 util/cache_ops: Add some cache flush helpers
The x86 implementation was shamelessly stolen from intel_mem.c and the
aarch64 implementaiton was based on the code in Turnip.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37803>
2025-10-16 01:19:44 +00:00
Alyssa Rosenzweig
84d8e6824b treewide: don't check before free
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
This was something that came up in the slop MR. Not sure it's actually a
good idea or not but kind of curious what people think, given we have a
sound tool (Coccinelle) to do the transform. Saves a redundant branch
but means extra noninlined function calls.. likely no actual perf impact
but saves some code.

Via Coccinelle patches:

    @@
    expression ptr;
    @@

    -if (ptr) {
    -free(ptr);
    -}
    +free(ptr);

    @@
    expression ptr;
    @@

    -if (ptr) {
    -FREE(ptr);
    -}
    +FREE(ptr);

    @@
    expression ptr;
    @@

    -if (ptr) {
    -ralloc_free(ptr);
    -}
    +ralloc_free(ptr);

    @@
    expression ptr;
    @@

    -if (ptr != NULL) {
    -free(ptr);
    -}
    -
    +free(ptr);

    @@
    expression ptr;
    @@

    -if (ptr != NULL) {
    -FREE(ptr);
    -}
    -
    +FREE(ptr);

    @@
    expression ptr;
    @@

    -if (ptr != NULL) {
    -ralloc_free(ptr);
    -}
    -
    +ralloc_free(ptr);

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> [v3d]
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> [venus]
Reviewed-by: Frank Binns <frank.binns@imgtec.com> [powervr]
Reviewed-by: Janne Grunau <j@jannau.net> [asahi]
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> [radv]
Reviewed-by: Job Noorman <jnoorman@igalia.com> [ir3]
Acked-by: Marek Olšák <maraeo@gmail.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Acked-by: Job Noorman <jnoorman@igalia.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37892>
2025-10-15 23:01:33 +00:00
Pierre-Eric Pelloux-Prayer
c0c95dc845 util: use F_DUPFD_QUERY on Linux
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
F_DUPFD_QUERY has been introduced in 6.10 exactly for the purpose
of telling if 2 fd points at the same file description so use it
first.

If it's not supported, we'll get r=-1 and errno=EINVAL, and we can
fallback on KCMP or epoll.

Acked-by: Simona Vetter <simona.vetter@ffwll.ch>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34447>
2025-10-15 07:58:12 +00:00
Pierre-Eric Pelloux-Prayer
17e286529b util: mimic KCMP_FILE via epoll when KCMP is missing
On Linux platforms where KCMP isn't allowed epoll can be used
as a fallback mechanism to provide the same feature.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34447>
2025-10-15 07:58:12 +00:00
Timothy Arceri
45a8cce5d6 util/range_remap: switch to using sorted array
Here we switch to using a sorted arrays for the binary search which
significantly speeds up the lookups. For a shader with ~8000
uniforms its up to 10x faster and the godot-tps-gles3-high.trace
in issue #13894 returns to its original runtime length before we
switched to using range remap in e052254066

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37754>
2025-10-15 02:16:36 +00:00
Timothy Arceri
2ea58908ae util/range_remap: add util_range_switch_to_sorted_array() helper
This creates an array of the linked list elements to be used for
faster binary searches in the following patch, and frees the old
linked list.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37754>
2025-10-15 02:16:36 +00:00
Timothy Arceri
f8326657f8 util/range_remap: use child memory context for list
This will allow us to easily free the list when we switch to
a sorted array in a following patch

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37754>
2025-10-15 02:16:35 +00:00
Timothy Arceri
9536de6eac util/range_remap: split list node from range entry
This will allow us to create an array of entries without the
node member in a following patch.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37754>
2025-10-15 02:16:34 +00:00
Timothy Arceri
754c6d0f54 glsl/util: update util_range_remap to use range_remap struct
This will allow us to use the linked list for validation of inserts
during linking then switch to using an array for fast binary searches.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37754>
2025-10-15 02:16:34 +00:00
Timothy Arceri
35d5e903ac util/range_remap: dont overwrite entry if ptr is NULL
If the ptr value is NULL and we match an existing entry during an
insert call we now just return the existing value. This allows us
to drop an extra lookup, this will become important as the
following patches change `util_range_remap()` lookups to use a
sorted array that is not created until after we have added all
entries to our linked list.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37754>
2025-10-15 02:16:33 +00:00
Rob Hughes
b79013ead9 llvmpipe: Work around WSL 1 missing support for memfd_create()
WSL version 1 has a known limitation that the kernel does not support
the memfd_create() syscall, and it always returns -1 (see
https://github.com/microsoft/WSL/issues/3542). This results in
lavapipe/llvmpipe failing to create the anonymous file it needs for
allocations from the pipe_screen object, which in turn results in
results in failed application calls to Vulkan APIs (in the case I
observed, vkMapMemory returned an invalid (0xffffffff) pointer along
with VK_SUCCESS, leading to the application segfaulting).

This issue can be reproduced by simply running `vkcube` (or, presumably
any other simple Vulkan application) inside WSL 1, e.g.:

xvfb-run -s '-screen 0 1024x768x24' vkcube --c 300

This patch addresses the issue with several changes:

1. llvmpipe_create_screen() now checks for errors from the
   os_create_anonymous_file function and errors out early, making it
   easier to track down issues similar to this. Previously, the invalid
   fd of -1 would be stored in the pipe_screen struct and the problems
   would only appear later.
2. os_create_anonymous_file() now attempts to handle the case where
   memfd_create() fails, by falling back to creating a file in a
   temporary directory. This fallback is the same as is already done for
   builds that don't have memfd_create available at build time - note
   that the difference here is that this is a _runtime_ fallback, as is
   needed for the case of WSL 1.
3. The fallback logic previously relied on the XDG_RUNTIME_DIR
   environment variable, which might not be set when running inside WSL
   because there is unlikely to be a desktop environment configured.
   This patch adds a fallback of creating a new directory inside /tmp in
   this case.

Reviewed-by: Lucas Fryzek <lfryzek@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37679>
2025-10-14 17:40:12 +00:00
Lionel Landwerlin
b8ae4ede60 brw: add serialize send stats
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
Reviewed-by: Alyssa Anne Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37394>
2025-10-10 11:19:39 +00:00
Olivia Lee
10a8defecc util/macros: coerce likely/unlikely to bool even without __builtin_expect
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Coercing the argument to a bool when we have __builtin_expect but
leaving it unmodified otherwise is a recipe for really subtle bugs. I
don't know if any bugs like that exist currently, but I almost
introduced one in panfrost.

Signed-off-by: Olivia Lee <olivia.lee@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37801>
2025-10-10 01:37:28 +00:00
Alyssa Rosenzweig
85207a4f6a util: add BITSET_CALLOC helper
comes up a bunch.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37779>
2025-10-09 12:29:55 +00:00
Lionel Landwerlin
3df4d86409 u_trace: use os_get_option instead of getenv
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Tim Van Patten <timvp@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37740>
2025-10-08 16:00:49 +00:00
Rob Clark
e60d34fa78 freedreno: Disable explicit sync heuristic for Xwayland
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Xwayland seems to mix implicit and explicit sync, depending on client
app.  This trips up the heuristic that disables implicit sync once it
starts seeing app using explicit sync.  This is not typical behavior,
so add a driconf override to disable the heuristic.

Fixes: 137cd3b0fa ("freedreno/drm: Move no_implicit_sync accounting")
Cc: mesa-stable
Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37703>
2025-10-06 15:55:48 +00:00
Timothy Arceri
db2126f8ef util: rewrite remap util to avoid looping list
Here we write the binary search to avoid looping over the list
by keeping track of the mid point entries and moving directly
from the last test point.

Fixes: bf946bcc ("util: add range remap util")

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37386>
2025-10-05 05:29:36 +00:00
Timothy Arceri
57ac68f616 util: add shortcut for range remap inserts
The user of this insert function often just inserts things in a
consecutive manner. So here we add a shortcut for inserting entries
at the tail of the list.

Fixes: bf946bccf2 ("util: add range remap util")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13894

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37386>
2025-10-05 05:29:36 +00:00
Alyssa Rosenzweig
c2ae207e80 brw,anv: use XML-based stats
I didn't bother switching either iris or elk/hasvk but one could.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37517>
2025-10-02 20:22:00 +00:00
Alyssa Rosenzweig
b575b0954a util/shader_stats: allow "hidden" stats
to allow drivers to do more complex printing without needing a subclass
paradigm. To be used on Intel.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37517>
2025-10-02 20:22:00 +00:00
Mel Henning
e7a62d5eff util/macros: Add ATTRIBUTE_COLD
Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37475>
2025-09-26 19:40:45 +00:00