Commit Graph

24 Commits

Author SHA1 Message Date
Konstantin Seurer fe5c7f1418 gallium/tests: Remove format desc null checks
Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17490>
2022-07-21 12:48:01 +00:00
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
Rob Clark a9618e7c42 util: Add accessor for util_cpu_caps
In release builds, there should be no change, but in debug builds the
assert will help us catch undefined behavior resulting from using
util_cpu_caps before it is initialized.

With fix for u_half_test for MSVC from Jesse Natalie squashed in.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9266>
2021-02-26 18:31:19 +00:00
Marek Olšák f5f0c012ad gallium/util: remove empty file u_half.h
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6987>
2020-10-06 21:07:11 -04:00
Marek Olšák b42c6ff6f6 util: remove util_float_to_half and util_half_to_float wrappers
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6987>
2020-10-06 21:07:07 -04:00
Matt Turner 1aac47db69 Revert F16C series (MR 6774)
This reverts commit 4fb2eddfdf.
This reverts commit 7a1deb16f8.
This reverts commit 2b6a172343.
This reverts commit 5af81393e4.
This reverts commit 87900afe5b.

A couple of problems were discovered after this series was merged that
cause breakage in different configurations:

   (1) It seems that using -mf16c also enables AVX, leading to SIGILL on
   platforms that do not support AVX.
   (2) Since clang only warns about unknown flags, and as I understand
   it Meson's handling in cc.has_argument() is broken, the F16C code is
   wrongly enabled when clang is used, even for example on ARM, leading
   to a compilation error.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3583
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6969>
2020-10-01 21:08:12 +00:00
Marek Olšák 4fb2eddfdf gallium/util: remove empty file u_half.h
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6774>
2020-09-30 16:28:24 +00:00
Marek Olšák 2b6a172343 util: remove util_float_to_half and util_half_to_float wrappers
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6774>
2020-09-30 16:28:24 +00:00
Eric Anholt 5b8d67cb64 util: Move fetch_rgba to a separate function table.
Only llvmpipe and translate_generic use it, and only in fallbacks, so if
you're not building that then let's not bloat our binaries with it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6305>
2020-08-16 21:25:14 +00:00
Eric Anholt 35b22b5da0 util: Make all 3 fetch_rgba functions occupy the same function slot.
A single format either had the float, the sint, or the uint version.
Making the dst be void * lets us store them in the same slot and not have
logic in the callers to call the right one.

-6kb on gallium drivers

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6305>
2020-08-16 21:25:14 +00:00
Eric Anholt 4064a6cd20 util: Split the pack/unpack functions out of the format desc.
This gives the compiler a chance to GC pack/unpack functions separate from
the format descriptions.  For drivers that use everything, this is
+10-20kb, while for libvulkan_intel it's -1.3MB.

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1048434
Acked-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5826>
2020-08-12 13:13:39 -07:00
Eric Anholt 882ca6dfb0 util: Move gallium's PIPE_FORMAT utils to /util/format/
To make PIPE_FORMATs usable from non-gallium parts of Mesa, I want to
move their helpers out of gallium.  Since u_format used
util_copy_rect(), I moved that in there, too.

I've put it in a separate directory in util/ because it's a big chunk
of related code, and it's not clear to me whether we might want it as
a separate library from libmesa_util at some point.

Closes: #1905
Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
2019-11-14 10:47:20 -08:00
Jan Vesely 47b390fe45 Treewide: Remove Elements() macro
Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2016-05-17 15:28:04 -04:00
Jose Fonseca 9ae0e8ee3c test/unit: Make translate_test invoke translate_create by default.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2016-04-14 07:19:04 +01:00
Zack Rusin 70bc43acdb gallium/tests: fix the translate test 2013-06-28 09:43:17 -04:00
Brian Paul 3a62e8bcac translate_test: add support for half floats
Fixes assertion reported in
https://bugs.freedesktop.org/show_bug.cgi?id=44519
but there's still failing cases.
2012-06-06 07:55:59 -06:00
Kai Wasserbäch 066875f340 tests/unit: Fix include style
As explained in the thread starting at [0], the internal include style
should be »#include "path/to/header.h"« for non-system includes.

[0]
<http://news.gmane.org/find-root.php?message_id=%3c4E5802BE.6020206%40vmware.com%3e>

Signed-off-by: Kai Wasserbäch <kai@dev.carbon-project.org>
Signed-off-by: Brian Paul <brianp@vmware.com>
2011-08-29 08:03:04 -06:00
José Fonseca 6586a3b287 tests: Use elts in translate_test. 2011-04-01 20:18:22 +01:00
Vinson Lee 26c042c30a translate_test: Fix compilation with MSVC. 2010-08-12 17:12:56 -07:00
Luca Barbieri b9abe7f62c translate_test: fix compilation on non-POSIX platforms
Use a kludgy function based on rand() instead of drand48()
2010-08-12 22:10:09 +02:00
Luca Barbieri 4d946c4e8a translate_test: improve
1. Generate random data specifically for float and doubles, so that
   they end up in [0, 1] range
2. Don't test useless conversions like SCALED <-> NORM
3. Poison the buffers before testing
2010-08-12 18:36:21 +02:00
Luca Barbieri 39cd4f7ceb translate_test: fix segfault on x86-64 2010-08-11 22:32:20 +02:00
Luca Barbieri 99cc6d70a4 translate_test: fix, reindent, and improve
1. Fix the segfault due to the reverted commit using the new interface
2. Reindent to Mesa 3 spaces style
3. Improve output and return success/failure with error code
4. Add much better support for testing translate_sse
2010-08-11 21:47:28 +02:00
Luca Barbieri 945e38c73b translate: add testsuite
Currently only checks all possible format conversions, and doesn't
attempt to test whether multiple buffers/elements or indices work.
2010-08-11 16:27:58 +02:00