mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 13:28:06 +02:00
util: Add new helpers for pipe resources
They will be handy for drivers supporting multi-planar formats.
Cc: mesa-stable
Reviewed-by: Italo Nicola <italonicola@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26109>
(cherry picked from commit d679154dc0)
This commit is contained in:
parent
1a238bece9
commit
5542b17f72
3 changed files with 39 additions and 1 deletions
|
|
@ -1284,7 +1284,7 @@
|
|||
"description": "util: Add new helpers for pipe resources",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -64,3 +64,35 @@ util_resource_size(const struct pipe_resource *res)
|
|||
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of the resources.
|
||||
*/
|
||||
unsigned
|
||||
util_resource_num(const struct pipe_resource *res)
|
||||
{
|
||||
const struct pipe_resource *cur;
|
||||
unsigned count;
|
||||
|
||||
for (count = 0, cur = res; cur; cur = cur->next)
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the resource at the given index.
|
||||
*/
|
||||
struct pipe_resource *
|
||||
util_resource_at_index(const struct pipe_resource *res, unsigned index)
|
||||
{
|
||||
const struct pipe_resource *cur;
|
||||
unsigned count;
|
||||
|
||||
for (count = 0, cur = res; cur; cur = cur->next) {
|
||||
if (count++ == index)
|
||||
return (struct pipe_resource *)cur;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,12 @@
|
|||
unsigned
|
||||
util_resource_size(const struct pipe_resource *res);
|
||||
|
||||
unsigned
|
||||
util_resource_num(const struct pipe_resource *res);
|
||||
|
||||
struct pipe_resource *
|
||||
util_resource_at_index(const struct pipe_resource *res, unsigned index);
|
||||
|
||||
/**
|
||||
* Return true if the texture target is an array type.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue