mesa/src/broadcom
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
..
ci v3d: do not tile 1D textures 2022-04-19 08:03:42 +00:00
cle broadcom: add line rasterization mode to packet definition 2022-03-18 09:38:38 +00:00
clif v3d/clif: add support for dumping GS shader state 2021-10-13 21:23:10 +00:00
common broadcom: update language on V3D_DEBUG options 2022-03-28 19:21:48 +00:00
compiler broadcom/compiler: prefer reconstruction over TMU spills when possible 2022-04-08 05:37:28 +00:00
drm-shim Use proper types for meson objects 2022-04-18 13:03:08 +03:00
qpu broadcom: drop unused functions 2022-01-31 16:10:31 +00:00
simulator v3dv/v3d: Fix copyright holder to Raspberry Pi Ltd 2022-02-18 11:50:07 +01:00
vulkan util: Remove util_cpu_detect 2022-04-20 18:44:35 +00:00
.editorconfig broadcom: add editorconfig 2017-07-25 14:44:52 -07:00
meson.build broadcom: remove v3dv3 from neon library 2021-07-29 08:26:11 +00:00