Mesa (main): iris: handle depth-stencil import with a wrapper function
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 9 06:00:12 UTC 2021
Module: Mesa
Branch: main
Commit: d75502be33669ab296937f1cbadbf77fef4e27f7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d75502be33669ab296937f1cbadbf77fef4e27f7
Author: Tapani Pälli <tapani.palli at intel.com>
Date: Thu Jun 3 15:22:24 2021 +0300
iris: handle depth-stencil import with a wrapper function
This is similar to u_transfer_helper wrap but implemented in
the driver as the layout between drivers can vary.
v2: remove else, simplify (Rohan, Eleni)
v3: add hiz surface support when importing depth buffer
v4: use iris_resource_configure_aux_offsets for setting
aux offsets for depth
v5: introduce helper for configuring imported memobj aux
offsets and utilize that
v6: simplify, remove aux support for now
v7: cleanups, fix offset calculation (Nanley)
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Nanley Chery <nanley.g.chery at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10609>
---
src/gallium/drivers/iris/iris_resource.c | 46 +++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 95af0d131ed..780560dae57 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -1279,6 +1279,50 @@ iris_resource_from_memobj(struct pipe_screen *pscreen,
return &res->base.b;
}
+/* Handle combined depth/stencil with memory objects.
+ *
+ * This function is modeled after u_transfer_helper_resource_create.
+ */
+static struct pipe_resource *
+iris_resource_from_memobj_wrapper(struct pipe_screen *pscreen,
+ const struct pipe_resource *templ,
+ struct pipe_memory_object *pmemobj,
+ uint64_t offset)
+{
+ enum pipe_format format = templ->format;
+
+ /* Normal case, no special handling: */
+ if (!(util_format_is_depth_and_stencil(format)))
+ return iris_resource_from_memobj(pscreen, templ, pmemobj, offset);
+
+ struct pipe_resource t = *templ;
+ t.format = util_format_get_depth_only(format);
+
+ struct pipe_resource *prsc =
+ iris_resource_from_memobj(pscreen, &t, pmemobj, offset);
+ if (!prsc)
+ return NULL;
+
+ struct iris_resource *res = (struct iris_resource *) prsc;
+
+ /* Stencil offset in the buffer without aux. */
+ uint64_t s_offset = offset +
+ ALIGN(res->surf.size_B, res->surf.alignment_B);
+
+ prsc->format = format; /* frob the format back to the "external" format */
+
+ t.format = PIPE_FORMAT_S8_UINT;
+ struct pipe_resource *stencil =
+ iris_resource_from_memobj(pscreen, &t, pmemobj, s_offset);
+ if (!stencil) {
+ iris_resource_destroy(pscreen, prsc);
+ return NULL;
+ }
+
+ iris_resource_set_separate_stencil(prsc, stencil);
+ return prsc;
+}
+
static void
iris_flush_resource(struct pipe_context *ctx, struct pipe_resource *resource)
{
@@ -2380,7 +2424,7 @@ iris_init_screen_resource_functions(struct pipe_screen *pscreen)
pscreen->resource_create = u_transfer_helper_resource_create;
pscreen->resource_from_user_memory = iris_resource_from_user_memory;
pscreen->resource_from_handle = iris_resource_from_handle;
- pscreen->resource_from_memobj = iris_resource_from_memobj;
+ pscreen->resource_from_memobj = iris_resource_from_memobj_wrapper;
pscreen->resource_get_handle = iris_resource_get_handle;
pscreen->resource_get_param = iris_resource_get_param;
pscreen->resource_destroy = u_transfer_helper_resource_destroy;
More information about the mesa-commit
mailing list