Commit Graph

18 Commits

Author SHA1 Message Date
Michel Dänzer 0ce93e5ba7 dri3: Include dix-config.h instead of xorg-config.h
This is DIX code.
2020-09-15 11:38:55 +02:00
Eric Anholt ef95331603 dri3: Switch fds_from_pixmap to stdint types.
Again, this was causing 32-bit build warnings due to mixing CARD* and
stdint.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-05-08 11:59:41 -04:00
Eric Anholt 4c754b01fa dri3: Switch get_modifiers to using stdint.
We were mixing stdint and CARD* types, causing compiler warnings on
32-bit.  Just switch over to stdint, which is what we'd like the server
to be using long term, anyway.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-05-08 11:59:36 -04:00
Eric Anholt 5e86484a18 dri3: Switch get_drawable_modifiers to using stdint.
We were mixing stdint and CARD* types, causing compiler warnings on
32-bit.  Just switch over to stdint, which is what we'd like the server
to be using long term, anyway.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-05-08 11:59:34 -04:00
Mario Kleiner 352a5ac87f dri3: Fix DRI3.2 support for drivers other than modesetting-ddx.
Both xf86-video-intel and xf86-video-nouveau cause OpenGL clients to
fail when used with DRI3 on server 1.20 with Mesa 18.1.

Reason is that the servers DRI3 version is now unconditionally reported
as DRI3 1.2 to 1.2 capable clients. This causes clients using Mesa 18.1
to use the new DRI 3.2 requests DRI3GetSupportedModifiers,
DRI3PixmapFromBuffers, etc. Drivers other than modesetting-ddx do not
support the needed hooks like info->pixmap_from_fds or
info->get_formats, info->get_modifiers. Unfortunately we can't simply
report the servers DRI3 version as 1.0 in this case, as the reported
version can not be specific to a X-Screen, and different screens may
have drivers with different capabilities.

Luckily the server has fallbacks to ->pixmap_from_fd, ->fd_from_pixmap,
and simply reporting an empty set of supported modifiers for the
DRI3GetSupportedModifiers request if the ddx doesn't support DRI 3.2.

Clients like Mesa 18.1's dri3 loader respond to the empty set of
reported modifiers by falling back to a dri driver selected buffer
format (image->createImageWithModifiers responds to a NULL modifier_list
by acting like ->createImage()). This works, but Mesa 18.1 will still
try to use the DRI3PixmapFromBuffers request to create the corresponding
pixmap, just passing in a modifier that corresponds to whatever tiling
the dri driver selected by default. To prevent this request - and
thereby the client - from failing with a BadImplementation error, remove
the check for modifier == DRM_MOD_FORMAT_INVALID in the pixmap_from_fd
fallback path of dri3_pixmap_from_fds() and trust that if we hit the
fallback path then the client will have passed a buffer with some driver
specific default tiling that can be handled by pixmap_from_fd.

Another approach would be for Mesa's dri3 loader to keep track how a
buffer was created (with explicit modifiers or not), and then call
DRI3PixmapFromBuffers or DRI3PixmapFromBuffer, but then any future DRI3
client implementation would need to be fixed, so the server side is
probably the better place for this.

Tested on Intel Ivybridge and NVidia Pascal.

Fixes: 6e7c40f62d ("dri3: Add multi-planar/modifier buffer requests")
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-04-25 14:48:58 -04:00
Daniel Stone c593d843f6 dri3: Don't call vfuncs on old DRI3 screens
Only call the get_supported_modifiers vfunc if the DRI3 screen struct is
sufficiently new.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-04-24 16:59:08 -04:00
Emil Velikov a42992a4cc dri3: rework format/modifier caching
Cut down the unnecessary malloc/memcpy/free by utilising the explicit
copy provided by the client.

But above all: do so, after ensuring we get valid data from the
implementation.

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov e2f45002fc dri3: check for ::get_drawable_modifiers failure
Currently if the function fails, we'll fall into two false assumptions:
 - the the count is zero
 - that the storage pointer is safe for free()

I've just fixed the former (in glamor + xwayland) and have no
plans on adding yet another workaround for the latter.

Simply zero both variables. Regardless if the implementation is missing
the callback or it foobars with output variables (normally a bad idea).

Bonus points - this fixes a bug where we feed garbage to free() further
down ;-)

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov a83ceec868 dri3: simplify dri3_open() implementation
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov 9a159f37e0 dri3: annotate fds/strides/offsets arrays as const
It makes it perfectly clear that we should not be modifying them.
Should help highlight issues like the one fixed with previous commit.

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov 66b632bb06 dri3: annotate the dri3_screen_info data as const
dri3_screen_info is the user provide dispatch. Something that we do
not and should not change.

When using the _ptr typecast + const the compiler barfs at us
(rightfully so), so use the _rec one.

[Silence a new const mismatch warning too - ajax]

Fixes: 5631382988 ("dri3: Add DRI3 extension")
Cc: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:23 -04:00
Daniel Stone 8ff1cdb2bf dri3: Set stride and size for old clients
For old clients using the fd_from_pixmap entrypoint, make sure we set
stride and size correctly.

Noticed by inspection.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2018-04-05 10:51:38 -04:00
Daniel Stone 75bba3aedc dri3: Use single-FD screen call for single-FD request
When importing client buffers into Pixmaps, we can use the fds_to_pixmap
hook for both single-FD and multi-FD client requests without any harm.

For the other direction of exporting Pixmap buffers to client FDs,
create a new helper which calls the old pixmap_to_fd hook if available.
This allows the implementation to ensure that the Pixmap storage is
accessible to clients not aware of multiple planes or modifiers, e.g. by
reallocating and copying.

This makes it possible to run a compositing manager on an old GLX/EGL
stack on top of an X server which allocates internal buffer storage
using exotic modifiers from modifier-aware GBM/EGL/KMS.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-04-04 13:46:57 -04:00
Louis-Francis Ratté-Boulianne 6e7c40f62d dri3: Add multi-planar/modifier buffer requests
Initial implementation for DRI3 v1.1. Only the DRI3 implementation
is there, backends need to implement the proper hooks.

Version is still set to 1.0 so clients shouldn't use the new
requests yet.

v2: Use depth/bpp instead of DRM formats in requests

v3: Remove DMA fence requests from v1.1
    Add screen/drawable modifier sets

v4: Free array returned by 'get_drawable_modifiers()'

v5: Fix FD leak

Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Acked-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-05 13:27:20 -05:00
Keith Packard 6ec04a75de dri3: Fix dri3_open API change by adding new dri3_open_client
Xwayland will eventually need the current client in dri3_open. Simply
changing that API is not an option though as other drivers that
implement DRI3 will not have a matching function signature and will
crash when called.

Add a new dri3_open_client function pointer and bump
DRI3_SCREEN_INFO_VERSION so that drivers can be aware of the new
function which will be used in preference to the old function when
available.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anhole <eric@anholt.net>
2014-04-08 13:53:58 -07:00
Kristian Høgsberg 9ba2084321 dri3: Allow asynchronous implementation for dri3_open
By passing the client pointer to the dri3_open implementation, we allow
the clients to implement the open callback asynchronously.  If the
client ignore count is positive after returning from dri3_open, we
assume that authentication is in progress and doesn't send the reply.
The code to send the reply is moved into a helper function, which the
implementation can call upon receiving its authenticaion reply.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-04-01 10:31:09 -07:00
Adam Jackson e6fafd3de7 dri3: Guard against buggy clients
There's nothing to stop a client from sending these requests to screens
without DRI3 support, and if they do, we'll crash.  Let's not do that.

Reviewed-by: Jasper St. Pierre <<jstpierre@mecheye.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-12-13 14:58:40 -05:00
Keith Packard 5631382988 dri3: Add DRI3 extension
Adds DRM compatible fences using futexes.
Uses FD passing to get pixmaps from DRM applications.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-10-31 16:58:30 -07:00