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, extend the resource_get_param hook to allow users to fetch
this information without WINSYS_HANDLE_TYPE_KMS.
Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes:
9da901d2b2e7 ("etnaviv: fail in get_handle(TYPE_KMS) without a scanout resource")
Reported-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12370>
enum pipe_resource_param param,
unsigned usage, uint64_t *value)
{
- switch (param) {
- case PIPE_RESOURCE_PARAM_NPLANES: {
+ if (param == PIPE_RESOURCE_PARAM_NPLANES) {
unsigned count = 0;
for (struct pipe_resource *cur = prsc; cur; cur = cur->next)
*value = count;
return true;
}
+
+ struct pipe_resource *cur = prsc;
+ for (int i = 0; i < plane; i++) {
+ cur = cur->next;
+ if (!cur)
+ return false;
+ }
+ struct etna_resource *rsc = etna_resource(cur);
+
+ switch (param) {
+ case PIPE_RESOURCE_PARAM_STRIDE:
+ *value = rsc->levels[level].stride;
+ return true;
+ case PIPE_RESOURCE_PARAM_OFFSET:
+ *value = rsc->levels[level].offset;
+ return true;
+ case PIPE_RESOURCE_PARAM_MODIFIER:
+ *value = layout_to_modifier(rsc->layout);
+ return true;
default:
return false;
}