Mesa (main): llvmpipe: Add handle export for resource_get_param

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 22 02:23:42 UTC 2021


Module: Mesa
Branch: main
Commit: 91029211093c7ab9e32de101ac7499a958635ac6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=91029211093c7ab9e32de101ac7499a958635ac6

Author: Daniel Stone <daniels at collabora.com>
Date:   Mon Jun 21 19:44:01 2021 +0100

llvmpipe: Add handle export for resource_get_param

mesa/mesa at 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 <daniels at collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Reported-by: Jonas Ådahl <jadahl at gmail.com>
Tested-by: Jonas Ådahl <jadahl at gmail.com>
Fixes: 2dcc9c7f54ed ("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>

---

 src/gallium/drivers/llvmpipe/lp_texture.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index e54196e766e..e240993f8f6 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;
@@ -904,6 +908,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:
@@ -918,10 +923,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;
    }



More information about the mesa-commit mailing list