llvmpipe: Add handle export for resource_get_param

mesa/mesa@2dcc9c7f54 from mesa/mesa!6639 added a resource_get_param
hook for llvmpipe, which was nice since it gave lavapipe more features.
One of those features was not exporting llvmpipe textures, so those
parts were stubbed out and landed in an assert(0).

This completely broke kms_swrast (llvmpipe+GBM) on non-release builds,
since that definitely does need to export llvmpipe textures.

The query codepath which caused this explosion does fall back to
resource_get_handle() - which is how it worked previously - but not all
callers do this, so just do what all other drivers implementing
resource_get_param() do and open-code the translation.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reported-by: Jonas Ådahl <jadahl@gmail.com>
Tested-by: Jonas Ådahl <jadahl@gmail.com>
Fixes: 2dcc9c7f54 ("llvmpipe: add resource get param support.")
Ref: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6639
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11504>
(cherry picked from commit 9102921109)
This commit is contained in:
Daniel Stone 2021-06-21 19:44:01 +01:00 committed by Eric Engestrom
parent 29a41ca214
commit 9de17a8491
2 changed files with 25 additions and 1 deletions

View file

@ -2965,7 +2965,7 @@
"description": "llvmpipe: Add handle export for resource_get_param",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "2dcc9c7f54edbff075665ebe5d50f2499dc12163"
},

View file

@ -53,6 +53,10 @@
#include "frontend/sw_winsys.h"
#ifndef _WIN32
#include "drm-uapi/drm_fourcc.h"
#endif
#ifdef DEBUG
static struct llvmpipe_resource resource_list;
@ -917,6 +921,7 @@ llvmpipe_resource_get_param(struct pipe_screen *screen,
uint64_t *value)
{
struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
struct winsys_handle whandle;
switch (param) {
case PIPE_RESOURCE_PARAM_NPLANES:
@ -931,10 +936,29 @@ llvmpipe_resource_get_param(struct pipe_screen *screen,
case PIPE_RESOURCE_PARAM_LAYER_STRIDE:
*value = lpr->img_stride[level];
return true;
#ifndef _WIN32
case PIPE_RESOURCE_PARAM_MODIFIER:
*value = DRM_FORMAT_MOD_INVALID;
return true;
#endif
case PIPE_RESOURCE_PARAM_HANDLE_TYPE_SHARED:
case PIPE_RESOURCE_PARAM_HANDLE_TYPE_KMS:
case PIPE_RESOURCE_PARAM_HANDLE_TYPE_FD:
if (!lpr->dt)
return false;
memset(&whandle, 0, sizeof(whandle));
if (param == PIPE_RESOURCE_PARAM_HANDLE_TYPE_SHARED)
whandle.type = WINSYS_HANDLE_TYPE_SHARED;
else if (param == PIPE_RESOURCE_PARAM_HANDLE_TYPE_KMS)
whandle.type = WINSYS_HANDLE_TYPE_KMS;
else if (param == PIPE_RESOURCE_PARAM_HANDLE_TYPE_FD)
whandle.type = WINSYS_HANDLE_TYPE_FD;
if (!llvmpipe_resource_get_handle(screen, context, resource, &whandle, handle_usage))
return false;
*value = whandle.handle;
return true;
default:
break;
}