Module: Mesa Branch: main Commit: cb8cdab928ff2302bef00b341914168c78a89a7c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb8cdab928ff2302bef00b341914168c78a89a7c
Author: Robert Mader <robert.ma...@collabora.com> Date: Sun Nov 19 22:12:36 2023 +0100 vc4/resource: Support offset query for multi-planar planes This is required in order to return the correct value for `gbm_dri_bo_get_offset()` for e.g. the second plane of a NV12 image. Use the newly introduced `util_resource` helper and, while on it, also add support for `gbm_bo_get_plane_count()`. Cc: mesa-stable Reviewed-by: Juan A. Suarez <jasua...@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26283> --- src/gallium/drivers/vc4/vc4_resource.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index 0a3a435a46c..e2acc4ad48f 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -26,6 +26,7 @@ #include "util/u_memory.h" #include "util/format/u_format.h" #include "util/u_inlines.h" +#include "util/u_resource.h" #include "util/u_surface.h" #include "util/u_transfer_helper.h" #include "util/u_upload_mgr.h" @@ -350,18 +351,22 @@ vc4_resource_get_param(struct pipe_screen *pscreen, enum pipe_resource_param param, unsigned usage, uint64_t *value) { - struct vc4_resource *rsc = vc4_resource(prsc); + struct vc4_resource *rsc = + (struct vc4_resource *)util_resource_at_index(prsc, plane); switch (param) { case PIPE_RESOURCE_PARAM_STRIDE: *value = rsc->slices[level].stride; return true; case PIPE_RESOURCE_PARAM_OFFSET: - *value = 0; + *value = rsc->slices[level].offset; return true; case PIPE_RESOURCE_PARAM_MODIFIER: *value = vc4_resource_modifier(rsc); return true; + case PIPE_RESOURCE_PARAM_NPLANES: + *value = util_resource_num(prsc); + return true; default: return false; }