llvmpipe: query winsys support for dmabuf mapping

Fixes #11257 by ensuring winsys mapping functions is only called
if its supported by the winsys, which should prevent llvmpipe from
crashing with kmswast.

If the winsys is kms_swrast then this method will be null, but on
drisw it will be available.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29546>
This commit is contained in:
Lucas Fryzek
2024-06-03 11:39:27 +01:00
committed by Marge Bot
parent d0d5fedbab
commit db38a4913e

View File

@@ -664,7 +664,13 @@ llvmpipe_resource_from_handle(struct pipe_screen *_screen,
#ifdef HAVE_LINUX_UDMABUF_H
struct llvmpipe_memory_fd_alloc *alloc;
uint64_t size;
if(_screen->import_memory_fd(_screen, whandle->handle, (struct pipe_memory_allocation**)&alloc, &size, true)) {
/* Not all winsys implement displaytarget_create_mapped so we need to check
* that is available (not null).
*/
if (winsys->displaytarget_create_mapped &&
_screen->import_memory_fd(_screen, whandle->handle,
(struct pipe_memory_allocation**)&alloc,
&size, true)) {
data = alloc->data;
lpr->dt = winsys->displaytarget_create_mapped(winsys, template->bind,
template->format, template->width0, template->height0,