Commit graph

200 commits

Author SHA1 Message Date
Qiang Yu
41cde01b0b gallium: add PIPE_RESOURCE_PARAM_DISJOINT_PLANES
To query if a DRI_IMAGE has separate plane buffer handle.

radeonsi's DCC compressed dri image has multiple planes
(compressed data and metadata). But they share the same
buffer with different offsets, so we only need one buffer
handle for them.

This attribute is used to distinguish single buffer multi
plane image from multi buffer multi plane image.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31658>
2025-09-15 09:39:19 +00:00
Marek Olšák
692206d58c dri: fail creating DRI images that exceed hw limits
otherwise random stuff happens

it probably resolves https://gitlab.freedesktop.org/mesa/mesa/-/issues/13652

Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36566>
2025-08-05 17:37:34 +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
Rob Clark
3fcf63f364 dri2: Allow allocating suboptimal for sampling
Fixes allocations via gbm, which doesn't necessarily need to be
renderable.

Fixes: ba7454a155 ("dri2+gallium: Support to import suboptimal formats")
Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36081>
2025-07-15 12:37:08 +00:00
Daniel Stone
a9298ca55c dri: Remove DRI2 loader extension
Now that all our backends are either swrast or using client image-based
allocation, we don't need the DRI2 loader interface anymore. Remove it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35885>
2025-07-09 17:49:59 +00:00
Daniel Stone
5be2e7f5c0 dri: Remove getBuffersWithFormat
This was only used for X11's DRI2, which we no longer have.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35885>
2025-07-09 17:49:58 +00:00
Daniel Stone
a8629e5622 dri: Remove dri2_from_names
This is now unused with the removal of X11 DRI2, and the wl_drm
pre-dmabuf path.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35885>
2025-07-09 17:49:58 +00:00
Daniel Stone
718ef151f2 egl/wayland: Remove support for non-dmabuf wl_drm
wl_drm is the legacy protocol which is used to support
EGL_WL_bind_wayland_display to exchange buffers between client and
server. It's supported dmabuf for a very long time, and as a private
protocol for Mesa's use, there is no need to carry around support for
old codepaths, as all relevant drivers support dmabuf.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35885>
2025-07-09 17:49:58 +00:00
Rob Clark
63b33eb4d9 dri: Correct handle-usage flags
If we can only import for sampling from, don't tell the driver that we
want to render to the handle.

Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35982>
2025-07-08 19:05:43 +00:00
Rob Clark
ba7454a155 dri2+gallium: Support to import suboptimal formats
In some cases a format may be supported in a more limited way by the
hardware.  For example, formats with NPoT pixel sizes.  A driver might
normally prefer that mesa/st use R8G8B8X8 rather than R8G8B8.  But if
the user wants to (dma-buf/etc) import R8G8B8, it is still possible,
and in this case zero copy is more important.

So add a PIPE_BIND_x flag as a hint to the driver when checking if
a format is supported.

Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35982>
2025-07-08 19:05:43 +00:00
Daniel Stone
4d61e281ea dri2: Remove format components mapping
This was only used to answer the DRI components attrib request, which
was made unused as of the previous commit to move knowledge of the enum
to wayland-drm server-side code.

In theory, this makes the format mapping a little less flexible, however
in practice wayland-drm was neither extensible nor extended, and has
been deprecated in favour of explicit user awareness of format
properties.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35856>
2025-07-02 14:35:25 +00:00
Timothy Arceri
94032b2298 dri: add missing field to dri2_dup_image()
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35814>
2025-06-30 23:04:57 +00:00
Timothy Arceri
3a51865faa dri: use plane format directly
Since 7e10601786 we not longer need the table we can just use
the formats directly.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35814>
2025-06-30 23:04:57 +00:00
Eric R. Smith
f2093b137e dri2: Teach the DRI layer about YU08 and YU10
Add the necessary bits to support YU08/YU10 images.

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:38:40 +02:00
Ryan Mckeever
0cafd65a31 frontend/dri: Replace tabs with spaces
Signed-off-by: Ryan Mckeever <ryan.mckeever@collabora.com>
Reviewed-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/34889>
2025-06-24 05:41: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
Simon Ser
105fcb9cfd dri: revert INVALID modifier special-casing
Commit 361f362258 ("dri: Unify createImage and createImageWithModifiers")
has introduced new behavior for drivers which don't support explicit
format modifiers. Before this commit, INVALID was not special-cased
and any call to dri_create_image() with one or more modifiers returned
NULL. After this commit, INVALID gained a special meaning: it indicates
that the implicit modifier is accepted by the caller. This is surprising
and is an API break.

This causes further API breaks: for instance, before this commit a BO
created via gbm_bo_create_with_modifiers() was guaranteed to always
return a non-INVALID modifier in gbm_bo_get_modifier().

This is inconsistent with gbm_dri_surface_create(): that function
treats INVALID as a bad entry in the modifier list, and fails if
it's the only acceptable modifier.

Additionally, drivers don't special-case INVALID and just ignore it
if they see it in a modifier list. This causes more inconsistencies.
For instance, let's say that a library user passes the modifier list
{ INVALID, FOO } to GBM. If a driver supports explicit modifiers and
doesn't support FOO for scanout, it'll return NULL. If a driver
doesn't support explicit modifiers, the current logic would return
a non-NULL BO with an INVALID modifier. This discrepency makes it
harder to reason about the system: half of the API ignores INVALID,
while the other half assumes INVALID indicates an implicit modifier.

To fix these issues, revert to the behavior before the commit, and
require use of the dedicated API without supplying any modifier for
implicit modifiers.

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: 361f362258 ("dri: Unify createImage and createImageWithModifiers")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32396>
2024-12-02 18:42:59 +00:00
Scott Moreau
7d1a32fafd dri: Fix hardware cursor for cards without modifier support
After the breaking commit, gbm_bo_create_with_modifiers({LINEAR}) returns
a BO with gbm_bo_get_modifier() = INVALID. This restores the functionality
and fixes most notably, hardware cursors for cards without modifiers.

Fixes #12039.

Fixes: 361f362258 ("dri: Unify createImage and createImageWithModifiers")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31725>
2024-11-28 14:52:42 +00:00
Pierre-Eric Pelloux-Prayer
df7bb6bfd2 dri: Remove unused function
This function is unused so get rid of it.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32281>
2024-11-27 19:00:20 +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
Marek Olšák
0bffe8ec05 mesa_interface: rename __DRIimage to struct dri_image
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31752>
2024-10-22 06:48:02 +00:00
Marek Olšák
ee54fe9f69 mesa_interface: rename __DRIconfig to struct dri_config
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31752>
2024-10-22 06:48:02 +00:00
Marek Olšák
186a3b6dad mesa_interface: replace opaque __DRIdrawable with struct dri_drawable everywhere
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31752>
2024-10-22 06:48:02 +00:00
Marek Olšák
329e03535b mesa_interface: replace opaque __DRIcontext with struct dri_context everywhere
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31752>
2024-10-22 06:48:02 +00:00
Marek Olšák
1ce9aa3d65 mesa_interface: replace opaque __DRIscreen with struct dri_screen everywhere
it's always struct dri_screen

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31752>
2024-10-22 06:48:02 +00:00
Mike Blumenkrantz
9042e9a8c0 dri: rework drawable creation
this consolidates all the creation code into the dri frontend,
enabling a single caller from the loader

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30619>
2024-08-19 17:43:58 +00:00
Mike Blumenkrantz
764e17eb03 dri: further collapse dri_screen creation
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30619>
2024-08-19 17:43:58 +00:00
Mike Blumenkrantz
c5f55ee126 dri: rename and move handle_in_fence to dri_helpers
make this reusable

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30619>
2024-08-19 17:43:58 +00:00
Mike Blumenkrantz
a3de3a4501 dri: set __DRI_IMAGE_ERROR_BAD_PARAMETER if driver doesn't support dmabuf import
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30619>
2024-08-19 17:43:58 +00:00
Mike Blumenkrantz
fca2e0ff32 dri: delete a bunch of unused interfaces
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30524>
2024-08-09 14:23:28 +00:00
Mike Blumenkrantz
1de7c86bc1 dri: pass through a type enum for creating screen instead of driver_extensions
the caller always knows what type of screen this will be, which means
it's finally possible to kill off passing a vtable here

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30524>
2024-08-09 14:23:28 +00:00
Mike Blumenkrantz
4246432c3e dri: delete more dead code
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30524>
2024-08-09 14:23:28 +00:00
Mike Blumenkrantz
d6ac254c01 dri: fix kms_swrast screen fail
this should match all the other screen init functions

cc: mesa-stable

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30524>
2024-08-09 14:23:28 +00:00
Mike Blumenkrantz
9f461400eb dri: delete all the extra dri2 extension handling
none of this is used anymore

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30524>
2024-08-09 14:23:28 +00:00
Mike Blumenkrantz
3216d2b03e dri: consolidate a bunch of dri_screen init code
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30524>
2024-08-09 14:23:28 +00:00
Mike Blumenkrantz
899541c7bc dri: delete some dri_screen cruft
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30524>
2024-08-09 14:23:28 +00:00
Mike Blumenkrantz
b53620b2b3 dri: delete __DRIdri2Extension interface
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30524>
2024-08-09 14:23:27 +00:00
Mike Blumenkrantz
afe6309449 dri: delete unused DRI_MESA queryCompatibleRenderOnlyDeviceFd method
make it more obvious which members match other DRI_MESA interface members

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30524>
2024-08-09 14:23:27 +00:00
Mike Blumenkrantz
101e78152e dri: make DRI2_BLOB public
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30494>
2024-08-05 20:33:15 +00:00
Mike Blumenkrantz
9d41f1f552 dri: make set_damage_region public
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30494>
2024-08-05 20:33:15 +00:00
Mike Blumenkrantz
f6afe277d3 dri: only add DRI_BUFFER_DAMAGE if the driver supports set_damage_region
100% of callers check both

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30494>
2024-08-05 20:33:14 +00:00
Mike Blumenkrantz
caa44dffbe dri: make a few more functions public
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30472>
2024-08-02 20:49:32 +00:00
Mike Blumenkrantz
9362ae7ecd dri: check for dmabuf_import at top of dri2_from_dma_bufs
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30472>
2024-08-02 20:49:32 +00:00
Mike Blumenkrantz
4105f0f001 dri: publicize dri_query_compatible_render_only_device_fd
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30472>
2024-08-02 20:49:31 +00:00
Mike Blumenkrantz
10a80782e0 dri: make DRI_IMAGE public
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30450>
2024-08-01 15:28:03 +00:00
Mike Blumenkrantz
012d20c6a3 dri: make DRI_INTEROP public
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30450>
2024-08-01 15:28:03 +00:00
Mike Blumenkrantz
ec3ad889da dri: delete DRI2_THROTTLE interface
unused

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30450>
2024-08-01 15:28:03 +00:00
Mike Blumenkrantz
e8d4b0a253 dri: unify DRI2_CONFIG_QUERY interfaces
these should always be the same to check both option caches

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30450>
2024-08-01 15:28:03 +00:00
Mike Blumenkrantz
0c4813dd0b dri: make DRI_FLUSH public
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30450>
2024-08-01 15:28:03 +00:00
Mike Blumenkrantz
e678c4d271 dri: delete __DRI2_RENDERER_QUERY interface
now requires link_whole for dri target to retain symbols

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30450>
2024-08-01 15:28:03 +00:00