frontends/va: honor DRI_PRIME for VA_DISPLAY_WAYLAND
This matches the X11 behavior. Other display types are unaffected. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8069 Reviewed-by: Leo Liu <leo.liu@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31012>
This commit is contained in:
committed by
Marge Bot
parent
286bac97ad
commit
ed781c7403
@@ -106,7 +106,7 @@ struct vl_screen *vl_win32_screen_create_from_d3d12_device(IUnknown* d3d12_devic
|
||||
#else
|
||||
/* Always enable the DRM vl winsys */
|
||||
struct vl_screen *
|
||||
vl_drm_screen_create(int fd);
|
||||
vl_drm_screen_create(int fd, bool honor_dri_prime);
|
||||
|
||||
#ifdef USE_XSHM
|
||||
struct vl_screen *
|
||||
|
||||
@@ -34,13 +34,25 @@
|
||||
#include "util/u_memory.h"
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
#include "loader.h"
|
||||
|
||||
static void
|
||||
vl_drm_screen_destroy(struct vl_screen *vscreen);
|
||||
|
||||
struct vl_screen *
|
||||
vl_drm_screen_create(int fd)
|
||||
vl_drm_screen_create(int fd, bool honor_dri_prime)
|
||||
{
|
||||
struct vl_screen *vscreen;
|
||||
int libva_owned_fd = -1;
|
||||
|
||||
if (honor_dri_prime) {
|
||||
/* Pass a non-NULL value as the 2nd param in order to not
|
||||
* close the original fd - it's owned by libva.
|
||||
* If fd is overriden, we'll close after the call to
|
||||
* pipe_loader_drm_probe_fd because pipe_loader dups the fd.
|
||||
*/
|
||||
loader_get_user_preferred_fd(&fd, &libva_owned_fd);
|
||||
}
|
||||
|
||||
vscreen = CALLOC_STRUCT(vl_screen);
|
||||
if (!vscreen)
|
||||
@@ -49,6 +61,9 @@ vl_drm_screen_create(int fd)
|
||||
if (pipe_loader_drm_probe_fd(&vscreen->dev, fd, false))
|
||||
vscreen->pscreen = pipe_loader_create_screen(vscreen->dev, false);
|
||||
|
||||
if (libva_owned_fd >= 0 && libva_owned_fd != fd)
|
||||
close(fd);
|
||||
|
||||
if (!vscreen->pscreen)
|
||||
goto release_pipe;
|
||||
|
||||
|
||||
@@ -169,8 +169,16 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
|
||||
FREE(drm_driver_name);
|
||||
}
|
||||
#endif
|
||||
if(!drv->vscreen)
|
||||
drv->vscreen = vl_drm_screen_create(drm_info->fd);
|
||||
if(!drv->vscreen) {
|
||||
/* VA_DISPLAY_WAYLAND uses the compositor's fd, like VA_DISPLAY_X11 does.
|
||||
* In this case, tell vl_drm_screen_create to consider the DRI_PRIME env
|
||||
* variable to let the user select a different device.
|
||||
* The other display types receive a fd explicitely picked by the application,
|
||||
* so don't try to override them.
|
||||
*/
|
||||
bool honor_dri_prime = ctx->display_type == VA_DISPLAY_WAYLAND;
|
||||
drv->vscreen = vl_drm_screen_create(drm_info->fd, honor_dri_prime);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user