Commit graph

2387 commits

Author SHA1 Message Date
Samuel Pitoiset
81e3c46d06 util: add util_is_aligned()
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28568>
2024-04-04 21:57:46 +00:00
Yonggang Luo
3114917986 util: Turn futex_wake parameter to int32_t for consistence across platforms
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28473>
2024-04-03 00:55:24 +00:00
Yonggang Luo
ca9738cd7a util: futex_wait use TIME_MONOTONIC on win32 for consistence with other platform
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28473>
2024-04-03 00:55:24 +00:00
Yonggang Luo
54e3fde5ca util: Fixes futex_wait on win32
The timeout compute is invalid

Fixes: 095dfc6caa ("util: Move the implementation of futex_wake and futex_wait from futex.h to futex.c")

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28473>
2024-04-03 00:55:24 +00:00
Samuel Pitoiset
a535425fb6 radv: enable radv_zero_vram for Red Dead Redemption 2
This fixes some very rare glitches that are unrelated to DCC.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8719
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28393>
2024-04-02 21:31:46 +00:00
Danylo Piliaiev
df3ba95a24 util/vma: Add function to get max continuous free size
Useful to find out what's the biggest allocation we could make.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28276>
2024-03-28 08:50:38 +00:00
Jan Beich
2b76284635 util: mimic KCMP_FILE via KERN_FILE on DragonFly and FreeBSD
Iterate over all file descriptors and compare their kernel addresses.

Reviewed-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Val Packett <val@packett.cool>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6881>
2024-03-26 20:53:36 +00:00
Paulo Zanoni
72e1e6e120 driconf/anv: set fp64_workaround_enabled to DIRT 5
Otherwise the game refuses to launch. With it, it's playable on my
DG2.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9882
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28213>
2024-03-23 17:01:17 +00:00
Yonggang Luo
1ac1c0843f treewide: Replace usage of macro DEBUG with MESA_DEBUG when possible
This is achieved by the following steps:

#ifndef DEBUG => #if !MESA_DEBUG
defined(DEBUG) => MESA_DEBUG
#ifdef DEBUG => #if MESA_DEBUG

This is done by replace in vscode

excludes
docs,*.rs,addrlib,src/imgui,*.sh,src/intel/vulkan/grl/gpu

These are safe because those files should keep DEBUG macro is already excluded;
and not directly replace DEBUG, as we have some symbols around it.

Use debug or NDEBUG instead of DEBUG in comments when proper

This for reduce the usage of DEBUG,
so it's easier migrating to MESA_DEBUG

These are found when migrating DEBUG to MESA_DEBUG,
these are all comment update, so it's safe

Replace comment /* DEBUG */ and /* !DEBUG */ with proper /* MESA_DEBUG */ or /* !MESA_DEBUG */ manually

DEBUG || !NDEBUG -> MESA_DEBUG || !NDEBUG
!DEBUG && NDEBUG -> !(MESA_DEBUG || !NDEBUG)

Replace the DEBUG present in comment with proper new MESA_DEBUG manually

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28092>
2024-03-22 18:22:34 +00:00
Thomas H.P. Andersen
5532f13566 driconf: override vendor id for X4 Foundations on NVK
The game will refuse to start if the driver version is tool old.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27784>
2024-03-22 11:18:55 +00:00
David Heidelberg
d8f53f698c util: move gen_zipped_file into generic util and rename to gen_zipped_xml_file
Make the filename more descriptive and since the file is used by
multiple drivers, move it into appropriate util/ directory.

Cosmetics:
 - use SPDX license tag
 - add newline before main function

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27804>
2024-03-21 20:48:41 +00:00
Rhys Perry
f88922e816 radv: use dual_color_blend_by_location with Half-Life Alyx
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Ethan Lee <flibitijibibo@gmail.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10462
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28269>
2024-03-20 11:40:18 +00:00
Samuel Pitoiset
4d4b1820ca radv: add radv_force_pstate_peak_gfx11_dgpu and enable it for Helldivers 2
This seems to definitely improve stability issues (random GPU hangs)
with Helldivers 2 on RDNA3 dGPUs. RDNA3 APUs and other generations
shouldn't be affected.

This is a workaround.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10584
Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28260>
2024-03-19 09:06:43 +00:00
Yonggang Luo
d17779430f util: Cleanup strtod.(h|c) by introduce _mesa_get_locale
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28174>
2024-03-19 04:05:08 +00:00
Marek Olšák
4ed3418a43 Unbreak Viewperf by reverting "util: use crc32_z instead of crc32 and bump zlib dep to 1.2.9"
It breaks apps shipping their own copy of zlib, such as Viewperf.
If we use crc32_z, Viewperf is unable to start because it's an undefined
symbol.

This reverts commit 010272b62e.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28233>
2024-03-19 03:08:10 +00:00
Kenneth Graunke
8573e9bf47 ra: Add debug functions for printing spill costs and benefits
These have been incredibly useful when debugging regressions and weird
behavior in the Intel backend when trying to spill multiple registers
before retrying allocation.  With them, we can print out not only what
register was chosen, but the benefit and cost.  Seeing lists of chosen
registers where the benefit/cost was not sorted, and poor options were
chosen before better ones, led me to investigate a number of issues.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28257>
2024-03-19 00:40:52 +00:00
duncan.hopkins
fcd0b4c94a util: Updated util/libdrm.h stubs with drmGetMagic()
Update adds in missing items that MacOS code needs to compile and run the DRI2 code.

New code is copied from the public repository: https://gitlab.freedesktop.org/mesa/drm/-/blob/main/xf86drm.h

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28130>
2024-03-15 10:50:12 +00:00
Alyssa Rosenzweig
93879b1920 util/hash_table: add DERIVE macro
we typically use a hash table with a fixed struct key, but this requires tedious
boilerplate. add a macro that generates all the boilerplate for you so you can
just create a table and go.

naming inspired by Rust #![derive].

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28056>
2024-03-12 19:41:49 +00:00
Alyssa Rosenzweig
ec9b6b5cfa util: add _mesa_hash_table_u64_num_entries
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27925>
2024-03-12 19:00:26 +00:00
Friedrich Vock
4c35828933 radv,driconf: Remove active accel struct workaround
Now unused and enabled by default.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28077>
2024-03-11 17:08:09 +00:00
Mike Blumenkrantz
9a57b1df53 driconf: add radv_zero_vram for Crystal Project (1637730)
fixes #10666

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28079>
2024-03-11 14:14:52 +00:00
Samuel Pitoiset
433a3c262a util/u_debug: fix parsing of "all" again
The current implementation is incorrect if the string starts with "all"
like "RADV_DEBUG=allbos".

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10741
Fixes: 0c42c79edf ("utils/u_debug: Fix parse of "all,<something else>")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28051>
2024-03-11 10:44:12 +00:00
Felix DeGrood
a2bd99f521 driconf: add SotTR DX12 to Intel XeSS workaround
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27610>
2024-03-06 01:12:54 +00:00
Samuel Pitoiset
570ebe1b37 radv: enable radv_zero_vram for RAGE2
Another native Vulkan game which doesn't properly initialize memory.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10701
Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27845>
2024-03-01 16:49:16 +00:00
Sebastian Wick
df801bec1e util: Add timespec_sub_saturate to avoid negative time for deadlines
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27511>
2024-02-27 13:10:13 +00:00
Daniel Stone
d3ed00f38a util: Add util_format_get_component_shift
Similar to util_format_get_component_bits, get the bit offset for a
particular channel in a given format.

Use this to calculate the shift/mask sets for formats when creating DRI
configs, as a prelude to ripping out and replacing the hardcoded table.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Alyssa Rosenzweig
66b00e2966 util/ralloc: add memdup
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27762>
2024-02-26 15:37:58 +00:00
Alyssa Rosenzweig
d964f57a48 util/hash_table: add u64 foreach macro
needs some nontrivial wrapping but can mostly fallback to the regular impl.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27762>
2024-02-26 15:37:58 +00:00
Marek Olšák
99f8f01dfb glthread: pack the index type to 8 bits
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27350>
2024-02-23 18:03:58 +00:00
Danylo Piliaiev
f4c40fc89c tu: Add workaround for D3D11 games accessing UBO out of bounds
Some D3D11 games rely on out-of-bounds indirect UBO loads to return
real values from underlying bound descriptor. This workaround would
prevent us from lowering indirectly accessed UBOs to consts.

Later DXVK would declare dynamically indexed uniforms with upper
size bound, to make the accesses spec compliant. But for now
we need our own workaround.

Known affected games:
- Dark Souls 3
- Sekiro: Shadows Die Twice
- Final Fantasy Type-0 HD
- Ultrakill
- Dishonored 2

DXVK discussions:
- https://github.com/doitsujin/dxvk/issues/405
- https://github.com/doitsujin/dxvk/issues/3861

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27727>
2024-02-23 12:08:53 +00:00
Marek Olšák
11dbdedf46 st/mesa: optimize st_update_arrays using lots of C++ template variants
This adds the following template options:
- add an option to fill TC set_vertex_buffers from st_update_array directly
  (always true without u_vbuf, so always used with radeonsi)
- add an option saying that there are no zero-stride attribs
- add an option saying that there are no user buffers
  (always true with glthread, so always used with radeonsi)
- add an option saying that there is an identity mapping between vertex
  buffers and vertex attribs

I have specifically chosen those options because they improve performance.
I also had other options that didn't, like unrolling the setup_arrays loop.

This adds a total of 42 variants of st_update_array_templ for various cases.
Usually only a few of them are used in practice.

Overhead of st_prepare_draw in VP2020/Catia:
    Before: 8.5% of CPU used
    After: 6.13% of CPU used

That's 2.37% improvement. Since there are 4 threads using the CPU and
the percentage includes all threads in the system, the improvement for
the GL thread is about 8% (roughly 2.17% * 4; each thread at 25% of global
utilization means 100% utilization in 4 cores).

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27731>
2024-02-21 18:36:44 +00:00
Matt Turner
9f32e1a489 anv/drirc: Add option to control implicit sync on external BOs
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10546
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27704>
2024-02-21 17:19:26 +00:00
Marek Olšák
0589dfe4e2 util/idalloc: optimize foreach by tracking the greatest non-zero element
also add util_idalloc_foreach_no_zero_safe.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27494>
2024-02-21 16:04:51 +00:00
Casey Bowman
d124542b55 anv: Override VendorID for Hitman 3
XeSS workaround is required for Hitman 3 to launch for Intel cards.

The following was observed during launch, coming from libxess.dll:
"Intel Plugin Extension ERROR: INTC_LoadExtensionsLibrary failed"

Signed-off-by: Casey Bowman <casey.g.bowman@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27477>
2024-02-13 19:02:24 +00:00
Jesse Natalie
161a90abbd dzn: Add a driconf option to disable dzn for specific apps and use it for RDR2
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27531>
2024-02-13 17:53:42 +00:00
Friedrich Vock
afab80bdb6 radv,driconf: Enable active AS leaf workaround for Jedi Survivor
Another game that can't get AS updates right.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27590>
2024-02-13 08:37:20 +00:00
Marek Olšák
716e483cfb util/idalloc: make deleting invalid IDs a no-op
This happens with piglit tests if we enable ForceGLNamesReuse
for everything.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27586>
2024-02-13 03:53:26 +00:00
Mark Janes
c40dacd4a8 util: add parson for handling json files
Release 1.5.3 (ba29f4eda9ea7703a9f6a9cf2b0532a2605723c3)
from https://github.com/kgabis/parson

Acked-by: Caio Oliveira <caio.oliveira@intel.com>
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27540>
2024-02-09 21:01:05 +00:00
Samuel Pitoiset
61a125647b radv: add radv_disable_ngg_gs and enable it for Persona 3 Reload
Persona 3 Reload is largely affected by the way amplification works with
NGG GS and disabling it drastically improve performance.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27518>
2024-02-09 07:24:16 +00:00
Sviatoslav Peleshko
0a1c8779e8 driconf: Apply dual color blending workaround to Dying Light
The game uses shader with `location=0` and `location=1` outputs where
it wants dual source blending and should've used `location=0, index=0`
and `location=0, index=1`.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10413
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27509>
2024-02-08 09:30:09 +00:00
Kenneth Graunke
24d3c83212 driconf: Advertise GL_EXT_shader_image_load_store on iris for SVP13
SPECviewperf creo-03 needs GL_EXT_shader_image_load_store in order for
its shaders to compile but we don't support a few corner cases that
didn't make it into the ARB variant.  It seems to run fine with an
override, so just do that for now.

Cc: mesa-stable
Acked-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27429>
2024-02-07 23:17:14 +00:00
David Heidelberg
010272b62e util: use crc32_z instead of crc32 and bump zlib dep to 1.2.9
1.2.9 has been released in January 2017, so let's assume
we'll find it everywhere.

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27311>
2024-02-06 19:22:53 +00:00
Sviatoslav Peleshko
0a44f6319e anv,driconf: Add sampler coordinate precision workaround for AoE 4
AoE4 samples texture on the edge between texels, which can cause
unexpected texel to be returned, and cause misrenderings. This workaround
enables coordinate rounding even in NEAREST mode, which fixes the problem.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9864
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27337>
2024-02-06 10:29:15 +00:00
Emmanuel Vadot
464e8aaff4 util: Allow kcmp on FreeBSD
FreeBSD now have kcmp(2) syscall, use it.

Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27184>
2024-02-03 17:19:31 +00:00
Blisto
3bc6f95e3d driconf: set vk_x11_strict_image_count for Atlas Fallen Vulkan
Prevents crash with vsync turned off on xwayland.

Cc: mesa-stable
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27122>
2024-02-02 07:48:22 +00:00
Yiwei Zhang
53d9debcf4 util: refactor to use DETECT_OS_ANDROID
except leaving u_endian.h behind to use __ANDROID__ directly to be
consistent with the rest in that file, which deserves a different
refactor

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27374>
2024-02-01 19:29:49 +00:00
Friedrich Vock
1c01fd0286 util/disk_cache: Use secure_getenv to determine cache directories
Reviewed-by: Eric Engestrom <eric@igalia.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27381>
2024-01-31 17:28:12 +00:00
Friedrich Vock
8b209a6200 util: Provide a secure_getenv fallback for platforms without it
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27381>
2024-01-31 17:28:11 +00:00
Eric Engestrom
501f78fdba util: check for setgid() as well in __normal_user()
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27378>
2024-01-31 11:42:56 +00:00
Eric Engestrom
afd4e633ee util: simplify logic in __normal_user()
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27378>
2024-01-31 11:42:55 +00:00