From 9de17a8491b1dfaad4a3f0368f9b05c9f749d35c Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 21 Jun 2021 19:44:01 +0100 Subject: [PATCH] llvmpipe: Add handle export for resource_get_param MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mesa/mesa@2dcc9c7f54ed 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 Reviewed-By: Mike Blumenkrantz Reviewed-by: Dave Airlie Reported-by: Jonas Ådahl Tested-by: Jonas Ådahl Fixes: 2dcc9c7f54ed ("llvmpipe: add resource get param support.") Ref: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6639 Part-of: (cherry picked from commit 91029211093c7ab9e32de101ac7499a958635ac6) --- .pick_status.json | 2 +- src/gallium/drivers/llvmpipe/lp_texture.c | 24 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 927c7f234fb..36f56650315 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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" }, diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index a0f74675b55..5e8f15d53fa 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -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; }