Commit Graph

4 Commits

Author SHA1 Message Date
Mike Blumenkrantz ba09a00a5c format_utils: properly parenthesize macro params
this otherwise breaks evaluation of the parameters on arm64

cc: mesa-stable

fixes #6496

Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16860>
2022-06-04 13:15:57 +00:00
Ian Romanick 72259a870f util: Add and use functions to calculate min and max int for a size
Many places need to know the maximum or minimum possible value for a
given size integer... so everyone just open-codes their favorite
version.  There is some potential to hit either undefined or
implementation-defined behavior, so having one version that Just Works
seems beneficial.

v2: Fix copy-and-pasted bug (INT64_MAX instead of INT64_MIN) in
u_intmin.  Noticed by CI.  Lol.  Rename functions
`s/u_(uint|int)(min|max)/u_\1N_\2/g`.  Suggested by Jason.  Add some
unit tests that would have caught the copy-and-paste bug before wasting
CI time.  Change the implementation of u_intN_min to use the same
pattern as stdint.h.  This avoids the integer division.  Noticed by
Jason.

v3: Add changes to convert_clear_color
(src/gallium/drivers/iris/iris_clear.c).  Suggested by Nanley.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12177>
2021-08-03 12:55:02 -07:00
Eric Anholt 0565270380 util: Fix UBSan failure on _mesa_unorm_to_unorm.
It complains about shifting 1<<31 being undefined, so make it a 1u.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297>
2021-01-15 18:58:50 +00:00
Eric Anholt 8d9826f014 util: Move most of src/mesa/main/format_utils.h to util/format/
This is a set of very nice, complete helpers for moving around bits in
various formats, and we want to retain its behavior when deduplicating
Mesa's format pack/unpack and gallium's.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297>
2021-01-15 18:58:50 +00:00