Module: Mesa Branch: main Commit: f1771ec3980611a27e075f2bb7f1a9c6d54dd0ec URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1771ec3980611a27e075f2bb7f1a9c6d54dd0ec
Author: Asahi Lina <[email protected]> Date: Tue Nov 8 10:32:56 2022 -0500 asahi: Implement agx_resource_get_param Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19606> --- src/gallium/drivers/asahi/agx_pipe.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 8f15c1f2c7d..02536161207 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -262,6 +262,41 @@ agx_resource_get_handle(struct pipe_screen *pscreen, /* Linear textures require specifying their strides explicitly, which only * works for 2D textures. Rectangle textures are a special case of 2D. */ + +static bool +agx_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 agx_resource *rsrc = (struct agx_resource *)prsc; + struct pipe_resource *cur; + unsigned count; + + switch (param) { + case PIPE_RESOURCE_PARAM_STRIDE: + *value = ail_get_wsi_stride_B(&rsrc->layout, level); + return true; + case PIPE_RESOURCE_PARAM_OFFSET: + *value = rsrc->layout.level_offsets_B[level]; + return true; + case PIPE_RESOURCE_PARAM_MODIFIER: + *value = rsrc->modifier; + return true; + case PIPE_RESOURCE_PARAM_NPLANES: + /* We don't support multi-planar formats, but we should still handle + * this case for GBM shared resources. + */ + for (count = 0, cur = prsc; cur; cur = cur->next) + count++; + *value = count; + return true; + default: + return false; + } +} + static bool agx_is_2d(enum pipe_texture_target target) {
