mesa/src
Jason Ekstrand 1b8a43a0ba util: Remove util_cpu_detect
util_cpu_detect is an anti-pattern: it relies on callers high up in the call
chain initializing a local implementation detail. As a real example, I added:

...a Mali compiler unit test
...that called bi_imm_f16() to construct an FP16 immediate
...that calls _mesa_float_to_half internally
...that calls util_get_cpu_caps internally, but only on x86_64!
...that relies on util_cpu_detect having been called before.

As a consequence, this unit test:

...crashes on x86_64 with USE_X86_64_ASM set
...passes on every other architecture
...works on my local arm64 workstation and on my test board
...failed CI which runs on x86_64
...needed to have a random util_cpu_detect() call sprinkled in.

This is a bad design decision. It pollutes the tree with magic, it causes
mysterious CI failures especially for non-x86_64 developers, and it is not
justified by a micro-optimization.

Instead, let's call util_cpu_detect directly from util_get_cpu_caps, avoiding
the footgun where it fails to be called.  This cleans up Mesa's design,
simplifies the tree, and avoids a class of a (possibly platform-specific)
failures. To mitigate the added overhead, wrap it all in a (fast) atomic
load check and declare the whole thing as ATTRIBUTE_CONST so the
compiler will CSE calls to util_cpu_detect.

Co-authored-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15580>
2022-04-20 18:44:35 +00:00
..
amd util: Remove util_cpu_detect 2022-04-20 18:44:35 +00:00
android_stub android_stub: update platform headers to include atrace 2021-10-09 00:42:32 +00:00
asahi asahi: Port driver to macOS 12.x ABI 2022-03-22 00:19:30 +00:00
broadcom util: Remove util_cpu_detect 2022-04-20 18:44:35 +00:00
compiler util: Remove util_cpu_detect 2022-04-20 18:44:35 +00:00
drm-shim drm-shim: Implement a shim function for close 2022-04-12 10:01:39 +00:00
egl win32: Fixes 32 bits visual studio module definition files by add script gen_vs_module_defs.py 2022-04-19 19:38:47 +00:00
etnaviv ci: update various ci result files 2022-03-11 09:58:28 +00:00
freedreno turnip: Don't disable LRZ in subpasses after the first in the easy case. 2022-04-19 18:45:30 +00:00
gallium util: Remove util_cpu_detect 2022-04-20 18:44:35 +00:00
gbm gallium: Learn about kopper 2022-04-07 00:17:40 +00:00
getopt
glx glx: Learn about kopper 2022-04-07 00:17:40 +00:00
gtest gtest: Fix output of array ASSERT/EXPECT macros 2021-11-11 09:53:09 -08:00
hgl
imagination pvr: Fix clang-format errors caused by vk outarrays. 2022-04-19 09:13:07 +00:00
imgui
intel anv: implement VK_EXT_primitives_generated_query 2022-04-20 10:37:24 +03:00
loader gallium/dri: add missing PIPE_BIND_DRI_PRIME handling 2022-02-08 00:13:07 +00:00
mapi win32: Do not use BUILD_GL32, we use def file to export win32 dll symbols. 2022-04-19 19:38:47 +00:00
mesa util: Remove util_cpu_detect 2022-04-20 18:44:35 +00:00
microsoft win32: Fixes 32 bits visual studio module definition files by add script gen_vs_module_defs.py 2022-04-19 19:38:47 +00:00
nouveau Use proper types for meson objects 2022-04-18 13:03:08 +03:00
panfrost Use proper types for meson objects 2022-04-18 13:03:08 +03:00
tool ci: Use a dlclose-disabling preload library for leak checking in Vulkan. 2022-01-27 23:47:46 +00:00
util util: Remove util_cpu_detect 2022-04-20 18:44:35 +00:00
virtio venus: prepare and feed renderer protocol info into cs 2022-04-09 00:19:05 +00:00
vulkan win32: Fixes 32 bits visual studio module definition files by add script gen_vs_module_defs.py 2022-04-19 19:38:47 +00:00
meson.build microsoft: Initial vulkan-on-12 driver 2022-03-25 16:21:45 +00:00