Mesa (staging/21.2): v3d: implement resource_get_param

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 19 18:16:10 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: 2a88afe58a225f2200f00141f54aa03b30ce5584
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a88afe58a225f2200f00141f54aa03b30ce5584

Author: Simon Ser <contact at emersion.fr>
Date:   Sat Aug 14 14:05:43 2021 +0200

v3d: implement resource_get_param

Prior to this commit, the stride, offset and modifier were fetched
via WINSYS_HANDLE_TYPE_KMS. However we can't make such a query
succeed if the buffer couldn't be imported to the KMS device.

Instead, implement the resource_get_param hook to allow users to
fetch this information without WINSYS_HANDLE_TYPE_KMS.

A tiny helper function is introduced to compute the modifier of a
resource.

Signed-off-by: Simon Ser <contact at emersion.fr>
Fixes: 7bcb22363935 ("v3d, vc4: Fix dmabuf import for non-scanout buffers")
Reported-by: Roman Stratiienko <r.stratiienko at gmail.com>
Reviewed-by: Daniel Stone <daniels at collabora.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12370>
(cherry picked from commit 8de086e12f5a20a75b227e48faeb83d9aacb21c3)

Conflicts:
	src/broadcom/ci/piglit-v3d-rpi4-fails.txt

---

 .pick_status.json                         |  2 +-
 src/broadcom/ci/piglit-v3d-rpi4-fails.txt | 28 ++++++++++++++++-
 src/gallium/drivers/v3d/v3d_resource.c    | 52 ++++++++++++++++++++++++-------
 3 files changed, 69 insertions(+), 13 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 6d60c7e9581..057c4cd7cbf 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -31,7 +31,7 @@
         "description": "v3d: implement resource_get_param",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "7bcb22363935431f1c8886608d9a77b3503fc5b4"
     },
diff --git a/src/broadcom/ci/piglit-v3d-rpi4-fails.txt b/src/broadcom/ci/piglit-v3d-rpi4-fails.txt
index f335cf8f016..e613955739b 100644
--- a/src/broadcom/ci/piglit-v3d-rpi4-fails.txt
+++ b/src/broadcom/ci/piglit-v3d-rpi4-fails.txt
@@ -208,7 +208,33 @@ spec at ext_framebuffer_object@fbo-blending-formats,Fail
 spec at ext_framebuffer_object@fbo-blending-formats at GL_RGB10,Fail
 spec at ext_framebuffer_object@getteximage-formats init-by-clear-and-render,Fail
 spec at ext_framebuffer_object@getteximage-formats init-by-rendering,Fail
-spec at ext_image_dma_buf_import@ext_image_dma_buf_import-export-tex,Fail
+spec at ext_gpu_shader4@execution at texelfetch@fs-texelfetch-isampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetch@fs-texelfetch-sampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetch@fs-texelfetch-usampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetchoffset@fs-texelfetch-isampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetchoffset@fs-texelfetch-sampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetchoffset@fs-texelfetch-usampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetchoffset@vs-texelfetch-isampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetchoffset@vs-texelfetch-sampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetchoffset@vs-texelfetch-usampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetch@vs-texelfetch-isampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetch@vs-texelfetch-sampler1darray,Fail
+spec at ext_gpu_shader4@execution at texelfetch@vs-texelfetch-usampler1darray,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texture() 1darray,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texture() 1darrayshadow,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texture(bias) 1darray,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texture(bias) 1darrayshadow,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texture() cubeshadow,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texturegrad 1darray,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texturegrad 1darrayshadow,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texturegradoffset 1darray,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texturegradoffset 1darrayshadow,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texturelod 1darray,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texturelod 1darrayshadow,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texturelodoffset 1darray,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4texturelodoffset 1darrayshadow,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4textureoffset 1darray,Fail
+spec at ext_gpu_shader4@tex-miplevel-selection gpu4textureoffset 1darrayshadow,Fail
 spec at ext_packed_depth_stencil@texwrap formats bordercolor,Fail
 spec at ext_packed_depth_stencil@texwrap formats bordercolor at GL_DEPTH24_STENCIL8- border color only,Fail
 spec at ext_packed_depth_stencil@texwrap formats bordercolor-swizzled,Fail
diff --git a/src/gallium/drivers/v3d/v3d_resource.c b/src/gallium/drivers/v3d/v3d_resource.c
index 62da3147620..d48479460db 100644
--- a/src/gallium/drivers/v3d/v3d_resource.c
+++ b/src/gallium/drivers/v3d/v3d_resource.c
@@ -396,6 +396,21 @@ v3d_resource_destroy(struct pipe_screen *pscreen,
         free(rsc);
 }
 
+static uint64_t
+v3d_resource_modifier(struct v3d_resource *rsc)
+{
+        if (rsc->tiled) {
+                /* A shared tiled buffer should always be allocated as UIF,
+                 * not UBLINEAR or LT.
+                 */
+                assert(rsc->slices[0].tiling == V3D_TILING_UIF_XOR ||
+                       rsc->slices[0].tiling == V3D_TILING_UIF_NO_XOR);
+                return DRM_FORMAT_MOD_BROADCOM_UIF;
+        } else {
+                return DRM_FORMAT_MOD_LINEAR;
+        }
+}
+
 static bool
 v3d_resource_get_handle(struct pipe_screen *pscreen,
                         struct pipe_context *pctx,
@@ -409,6 +424,7 @@ v3d_resource_get_handle(struct pipe_screen *pscreen,
 
         whandle->stride = rsc->slices[0].stride;
         whandle->offset = 0;
+        whandle->modifier = v3d_resource_modifier(rsc);
 
         /* If we're passing some reference to our BO out to some other part of
          * the system, then we can't do any optimizations about only us being
@@ -416,17 +432,6 @@ v3d_resource_get_handle(struct pipe_screen *pscreen,
          */
         bo->private = false;
 
-        if (rsc->tiled) {
-                /* A shared tiled buffer should always be allocated as UIF,
-                 * not UBLINEAR or LT.
-                 */
-                assert(rsc->slices[0].tiling == V3D_TILING_UIF_XOR ||
-                       rsc->slices[0].tiling == V3D_TILING_UIF_NO_XOR);
-                whandle->modifier = DRM_FORMAT_MOD_BROADCOM_UIF;
-        } else {
-                whandle->modifier = DRM_FORMAT_MOD_LINEAR;
-        }
-
         switch (whandle->type) {
         case WINSYS_HANDLE_TYPE_SHARED:
                 return v3d_bo_flink(bo, &whandle->handle);
@@ -448,6 +453,30 @@ v3d_resource_get_handle(struct pipe_screen *pscreen,
         return false;
 }
 
+static bool
+v3d_resource_get_param(struct pipe_screen *pscreen,
+                       struct pipe_context *pctx, struct pipe_resource *prsc,
+                       unsigned plane, unsigned layer, unsigned level,
+                       enum pipe_resource_param param,
+                       unsigned usage, uint64_t *value)
+{
+        struct v3d_resource *rsc = v3d_resource(prsc);
+
+        switch (param) {
+        case PIPE_RESOURCE_PARAM_STRIDE:
+                *value = rsc->slices[level].stride;
+                return true;
+        case PIPE_RESOURCE_PARAM_OFFSET:
+                *value = 0;
+                return true;
+        case PIPE_RESOURCE_PARAM_MODIFIER:
+                *value = v3d_resource_modifier(rsc);
+                return true;
+        default:
+                return false;
+        }
+}
+
 #define PAGE_UB_ROWS (V3D_UIFCFG_PAGE_SIZE / V3D_UIFBLOCK_ROW_SIZE)
 #define PAGE_UB_ROWS_TIMES_1_5 ((PAGE_UB_ROWS * 3) >> 1)
 #define PAGE_CACHE_UB_ROWS (V3D_PAGE_CACHE_SIZE / V3D_UIFBLOCK_ROW_SIZE)
@@ -1148,6 +1177,7 @@ v3d_resource_screen_init(struct pipe_screen *pscreen)
         pscreen->resource_create = u_transfer_helper_resource_create;
         pscreen->resource_from_handle = v3d_resource_from_handle;
         pscreen->resource_get_handle = v3d_resource_get_handle;
+        pscreen->resource_get_param = v3d_resource_get_param;
         pscreen->resource_destroy = u_transfer_helper_resource_destroy;
         pscreen->transfer_helper = u_transfer_helper_create(&transfer_vtbl,
                                                             true, false,



More information about the mesa-commit mailing list