Commit graph

211 commits

Author SHA1 Message Date
Mario Kleiner
1fe73481ba util/format: Add util_format_is_unorm16()
Detects 16 bpc unorm formats. Used by following RGB[A]16
UNORM display enablement commits.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38588>
2026-01-21 12:29:03 +00:00
Jeff Burnett
320d757578 util: Don't force 64-bit division on 32-bit platforms
When converting between snorm and between unorm values, the following
patch introduced 64-bit division on all platforms.

  util: Add and use functions to calculate min and max int for a size
  Commit hash: 72259a870f

The following unit math
  // local MAX_UINT macro based on UINT32_MAX
  (uint64_t * uint32_t + uint32_t) / uint32_t
changed to
  // macros.h inlined 'uint64_t u_uintN_max()' functions.
  (uint64_t * uint64_t + uint32_t) / uint64_t

This can significantly impact performance on 32-bit platforms.

Address this by type-casting the return values from the inlined
functions to avoid the 64-bit divide on 32-bit platforms.

Signed-off-by: Micah Shennum <micah.shennum@garmin.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39001>
2026-01-05 20:52:24 +00:00
Marek Olšák
d0dd5a5f57 ac,radeonsi: move SX PS downconversion code into ac_formats.c
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39093>
2026-01-02 16:46:20 +00:00
Eric R. Smith
b11f543c4e mesa: Add R16G16_R16B16_UNORM and related formats
Including the 10 bit variant X6R10X6G10_X6R10X6B10_UNORM. Only the
RG_RB variants seem to have fourccs, so those are the only ones being
added for now, although they would, obviously, be easy to add).

These are used for Y210, Y212, and Y216 fourccs. In particular Y210
is interesting for panfrost, as it is the fourcc used to indicate a
10 bit single plane 4:2:2 encoded as AFBC (similar to how YUYV is
the canonical AFBC for 10 bit 4:2:0).

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35771>
2025-11-04 22:28:03 +00:00
Boris Brezillon
18f352090d util/format: Add a Z24_UNORM_PACKED format
Mali GPUs support Z24_UNORM stored on three bytes instead of four. Add
a new format for this case.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37158>
2025-09-15 10:59:04 +00:00
Boris Brezillon
f57cc49683 util/format: Autogen type conversion helpers
We are about to need new type converters for our AFBC mode selection
logic (AFBC is type agnostic, but we currently accept only UNORM
formats), so let's switch to an autogen solution for the existing ones,
and generate all missing type converters along the way.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37158>
2025-09-15 10:59:04 +00:00
David Rosca
10dbb0ed2a util/format: Add VK_EXT_ycbcr_2plane_444_formats formats
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37174>
2025-09-08 11:59:36 +00:00
David Rosca
ac896c0327 util/format: Add RGB lowering for single plane YUV formats
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
This fixes a regression with Y8_400 format, which needs to return
R8 as plane format.

Fixes: 5e01ec4bd0 ("util/format: Auto-generate a bunch of YUV helpers")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37056>
2025-09-03 12:51:23 +00:00
Robert Mader
6c83ae95a2 mesa: Add support for NV61, NV24 and NV42 pixel formats
Which are essentially variants of NV12. All of them have been tested
with the Weston client-buffer test with llvmpipe and radeonsi.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36890>
2025-08-26 18:08:37 +00:00
Yonggang Luo
3f3bc4ece5 util/format: u_format_gen.h are using UTIL_ARCH_LITTLE_ENDIAN, include util/u_endian.h for it
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36891>
2025-08-21 03:18:59 +08:00
Boris Brezillon
5e01ec4bd0 util/format: Auto-generate a bunch of YUV helpers
Now that the YUV subsampling pattern is encoded in the name, we can
auto-generate a bunch of helpers that were previously hand-written,
and are pretty often lagging behind when new formats are added.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35177>
2025-08-20 14:01:07 +00:00
Boris Brezillon
f20ee2806e util/format: Add subsampling info to our YUV-as-RGB format names
This will allow for more autogen and is good to have regardless, because
it makes it clear what the subsampling is when looking at the name.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35177>
2025-08-20 14:01:07 +00:00
Boris Brezillon
75ba8f403d util/format: Use more descriptive names for YUV formats
This is the first step for more auto-generated YUV helpers. We keep
the short/fourcc names as aliases, and generate defines so we don't have
to patch the existing code, but ultimately, it'd be good to consistently
use the fully descriptive names so it's easier to reason about the
formats when reading the code.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35177>
2025-08-20 14:01:07 +00:00
Boris Brezillon
fabd0d82db util/format: Auto-generate the enum pipe_format definition
I've recently discovered a case where the enum entry was defined, but the
description in the yaml was missing, leading to a NULL deref when we
were querying the util_format_description object for this format.

This autogen of the enum will also allow for more autogen, and proper
classication of formats.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35177>
2025-08-20 14:01:06 +00:00
Antonio Ospite
ddf2aa3a4d build: avoid redefining unreachable() which is standard in C23
In the C23 standard unreachable() is now a predefined function-like
macro in <stddef.h>

See https://android.googlesource.com/platform/bionic/+/HEAD/docs/c23.md#is-now-a-predefined-function_like-macro-in

And this causes build errors when building for C23:

-----------------------------------------------------------------------
In file included from ../src/util/log.h:30,
                 from ../src/util/log.c:30:
../src/util/macros.h:123:9: warning: "unreachable" redefined
  123 | #define unreachable(str)    \
      |         ^~~~~~~~~~~
In file included from ../src/util/macros.h:31:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:456:9: note: this is the location of the previous definition
  456 | #define unreachable() (__builtin_unreachable ())
      |         ^~~~~~~~~~~
-----------------------------------------------------------------------

So don't redefine it with the same name, but use the name UNREACHABLE()
to also signify it's a macro.

Using a different name also makes sense because the behavior of the
macro was extending the one of __builtin_unreachable() anyway, and it
also had a different signature, accepting one argument, compared to the
standard unreachable() with no arguments.

This change improves the chances of building mesa with the C23 standard,
which for instance is the default in recent AOSP versions.

All the instances of the macro, including the definition, were updated
with the following command line:

  git grep -l '[^_]unreachable(' -- "src/**" | sort | uniq | \
  while read file; \
  do \
    sed -e 's/\([^_]\)unreachable(/\1UNREACHABLE(/g' -i "$file"; \
  done && \
  sed -e 's/#undef unreachable/#undef UNREACHABLE/g' -i src/intel/isl/isl_aux_info.c

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36437>
2025-07-31 17:49:42 +00:00
Konstantin Seurer
9313a16e24 util: Fix sparse tile size when dimensions=1
The return value is blocks and not bytes.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36197>
2025-07-23 13:29:18 +00:00
Pierre-Eric Pelloux-Prayer
fddd5bc2e5 util/texcompress: fix comparison warning
Fixes warnings reported by static analysis. It shouldn't change
the behavior as numxpixels/numypixels should always be smaller
than 255.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35877>
2025-07-04 15:26:39 +00:00
Robert Mader
76095b2cb0 mesa/formats: Add support for 10 and 12 bit SW decoder YCbCr formats
Matching e.g. I420_10LE in Gstreamer / yuv420p10 in ffmpeg. The formats
are notably used for HDR10 videos by software decoders like dav1d, libav,
libaom and libvpx.

Use-cases include video players and editors that can allocate DMA buffers
- e.g. via udmabuf, dma-heaps, VA-API, V4L2, etc. - allowing them to avoid
unnecessary copies. Testing HDR10 playback on CI might also become easier.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34303>
2025-06-30 11:56:23 +00:00
Eric R. Smith
d4f83a96c9 util/format: add support for YU08 and YU10 formats
Adds support for single plane YUV 420 formats (YU08 and YU10 fourcc
codes). The internal layout for these is unspecified and driver
specific.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35318>
2025-06-25 18:37:28 +02:00
Rob Clark
9e07f38b91 util+tu: Add util_format_is_float16()
Extract out a helper to check for f16 formats from turnip so it can be
used elsewhere.

Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35589>
2025-06-20 00:10:47 +00:00
Boris Brezillon
ceb79e399e util/format: Handle emulated YUV formats in util_format_get_plane_{height,width}()
Useful to drivers doing the CSC in software, but still needing
to account for width/height adjusment based on the subsampling.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Tested-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35015>
2025-06-05 13:51:34 +00:00
Eric R. Smith
6b54547a0e util/format: fix some missing cases in util_format_get_plane_format
We were missing some of the emulated YUV formats (like R8_G8B8_420_UNORM)
in util_format_get_plane_format; add those.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35015>
2025-06-05 13:51:34 +00:00
Boris Brezillon
f28b2c9e8d util/format: Add missing entries for {R8_B8G8,G8_B8R8}_422_UNORM
The yaml lacks entries for those formats which are defined in the enum.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Tested-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35015>
2025-06-05 13:51:34 +00:00
Erik Faye-Lund
6cd898dbc2 util/format: add util_format_is_astc_hdr()-helper
This will be used later in the series.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35132>
2025-05-28 14:49:06 +00:00
Erik Faye-Lund
ccc7833f16 util/format: add ASTC HDR formats
These are just the float variations of the normal LDR formats. Not all
LDR formats have an HDR variant.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35132>
2025-05-28 14:49:06 +00:00
Pohsiang (John) Hsu
fdc36dd54a util: fix msvc build warning 4146 (unary minus operator applied to unsigned type, result still unsigned)
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34845>
2025-05-09 16:34:00 +00:00
Konstantin Seurer
d49de8f10a util: Add util_format_is_int64
util_format_is_int64 returns true for pure 64-bit integer (sint64 and uint64) formats.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33628>
2025-05-08 19:30:19 +00:00
Loïc Molinari
9205212d2e mesa: Add CPU traces
A few function scope traces are added to texture management entry
points, shader compilation, draw and 2D rect copy to give better
context to driver traces.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Benjamin Lee <benjamin.lee@collabora.com>
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34385>
2025-04-15 10:37:39 +00:00
Juan A. Suarez Romero
5b42da1be8 util/format: nr_channels is always <= 4
While the nr_channels is defined with 3 bits, which allows up to 7
channels, actually the number of channels is less or equal to 4.

This adds an assertion that helps static analyzers to avoid several
false positives related with this.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32589>
2024-12-11 18:34:47 +00:00
Eric R. Smith
6f95870561 format: Add R8_G8B8_422_UNORM format
This is the format that drivers will want to use for NV16
without YUV conversion (if they support this natively).
Previously we had NV16 working but it was always emulated
with R8 + GR88.

Fixes: 440b69210a ("dri, mesa: fix NV16 texture format")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32524>
2024-12-11 15:28:08 +00:00
Eric R. Smith
1ea79ec164 egl, mesa: add support for NV15 and NV20 textures
Support external images with 10 bit YUV in NV15 and NV20 formats.
These are produced by some hardware decoders, so this will be
useful.

Signed-off-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31854>
2024-11-25 13:04:19 +00:00
Eric R. Smith
440b69210a dri, mesa: fix NV16 texture format
Support for NV16 was kind of half done, by declaring it to be
NV12. That didn't actually work though, so add some more stuff
to make it work.

Signed-off-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31854>
2024-11-25 13:04:19 +00:00
Eric R. Smith
b6531e45ed util: rename PIPE_FORMAT_Y8_U8V8_422_UNORM
Y8_U8V8_422_UNORM is more commonly known as NV16. There has been
a fourcc for NV16 for a while now, so let's rename it to be in
line with NV12 and similar formats.

Signed-off-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31854>
2024-11-25 13:04:19 +00:00
Valentine Burley
81ebd6ea8d util/format: Add new 12-bit P012 RGB/planar formats
Introduce three 12-bit formats: X4R12_UNORM, X4R12X4G12_UNORM, and X4G12_X4B12X4R12_420_UNORM.
These formats allocate 12 bits for each color channel with 4 bits of padding to align with Vulkan's P012
and related planar formats.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Signed-off-by: Valentine Burley <valentine.burley@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30821>
2024-10-16 14:30:15 +00:00
Valentine Burley
1134ad8799 util/format: Add new 10-bit P010 RGB/planar formats
Introduce three 10-bit formats: X6R10_UNORM, X6R10X6G10_UNORM, and X6G10_X6B10X6R10_420_UNORM.
These formats allocate 10 bits for each color channel with 6 bits of padding to align with Vulkan's P010
and related planar formats.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Signed-off-by: Valentine Burley <valentine.burley@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30821>
2024-10-16 14:30:15 +00:00
Valentine Burley
7fb7fa794c util: Remove Vulkan-only formats from get_plane_width/height
This reverts commit 3316bc3e88.

These formats were only used by RADV and are no longer needed as we can get the plane dimensions
from the YCbCr table.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Signed-off-by: Valentine Burley <valentine.burley@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30899>
2024-08-29 15:57:52 +00:00
Konstantin
3316bc3e88 util: Handle more formats in get_plane_(width|height)
Required by RADV to use PIPE_FORMAT_G8_B8R8_420_UNORM and
PIPE_FORMAT_G8_B8_R8_420_UNORM.

Reviewed-by: Valentine Burley <valentine.burley@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30459>
2024-08-01 07:44:02 +00:00
Daniel Stone
508a3bdd27 u_format: Reword introduction
Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29649>
2024-07-19 13:50:42 +00:00
Daniel Stone
974d31dba7 format: Generate sRGB<->linear conversions from table
Instead of having a hardcoded table to convert between sRGB formats and
their linear-gamma equivalents (and vice-versa), generate this from the
information in the format table.

This requires adding a 'sublayout' attribute to differentiate between,
e.g. DXT1 and DXT3, which otherwise appear to be equivalent but for
their name prefix.

As an anonymous union is being used, we also need named initialisers for
the util_format_description entries.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29649>
2024-07-19 13:50:42 +00:00
Daniel Stone
e05415a82e format: Generate endian-independent format aliases
Instead of having a hardcoded list of endian-independent format aliases
in the header, generate them from the format definitions.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29649>
2024-07-19 13:50:42 +00:00
Daniel Stone
ccc6442d6f u_format: Rewrite format table to use YAML
u_format has always had its format table in CSV. This is kind of nice
for some things, but is a serious pain to extend, especially with
optional fields.

In going through our many (many, many) duplicated tables of format
mappings, it would've been nice to add some descriptions to our central
u_format table, such as mapping to DRM FourCC, to EGLImage mappings, and
to GL internalformats for EGLImage imports. Unfortunately, doing so with
more additional fields would just make the CSV totally unreadable.

Move the CSV table to a YAML-based table and adjust the Python parsers
to suit. The resulting generated files are identical before and after
the transition.

The new parser also has a significant amount of format validation to
make it easier to catch common errors.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29649>
2024-07-19 13:50:42 +00:00
David Heidelberg
68215332a8 build: pass licensing information in SPDX form
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Dylan Baker <dylan.c.baker@intel.com>
Acked-by: Eric Engestrom <eric@igalia.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29972>
2024-06-29 12:42:49 -07:00
Konstantin Seurer
eb64ce4386 util: Add a helper for querying sparse tile sizes
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29408>
2024-06-27 09:29:33 +00:00
Juan A. Suarez Romero
a407285ff2 util: use unsigned types when performing bitshift
Ensure unsigned integers are used instead of signed ones when performing
left bit shifts.

This has been detected by the Undefined Behaviour Sanitizer (UBSan).

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29772>
2024-06-21 21:07:05 +00:00
Faith Ekstrand
3797fc18d8 util/format_pack: Clamp SNORM values to [-1, 1] when unpacking
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28793>
2024-06-19 01:56:22 +00:00
Faith Ekstrand
354f0958af util/format_pack: Also use iround for SCALED formats
This is probably not necessary but more correct.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28793>
2024-06-19 01:56:22 +00:00
Faith Ekstrand
b187be5b1c util/format_pack: Fix packing of signed 1010102 SSCALED formats
Previously, [SU]SCALED formats would hit the integer path and we would
generate:

    ((uint32_t)CLAMP(src[i], min, max)) & MASK

This is fine for unsigned scaled formats.  However, for signed formats,
a negative float value cast to an unsigned integer yields undefined
results.  On x86, it implicitly clamps to 0.  This change makes us
generate:

    ((uint32_t)(int32_t)CLAMP(src[i], min, max)) & MASK

hich gets us correct casting.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28793>
2024-06-19 01:56:22 +00:00
Erik Faye-Lund
cd37384985 util/format: correct a typo
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29380>
2024-05-28 15:04:14 +00:00
Eric Engestrom
8c22112a7d util/format: add missing null check in util_format_is_srgb()
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11137
Fixes: ff6cf60cb8 ("gallium/util: add util_format_is_srgb() helper")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29160>
2024-05-14 07:16:02 +00:00
Sathishkumar S
afd15f481b util/format: add planar3 y8_u8_v8_440 pipe format
add pipe format to represent yuv440 surface

Signed-off-by: Sathishkumar S <sathishkumar.sundararaju@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28866>
2024-05-09 20:43:02 +00:00