From 3857f450a6d88cf4d0c616a4224bbd5b9cc89388 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Wed, 2 Jan 2013 20:40:24 +0100 Subject: gallium/util: add helper util_max_layer from r600g --- src/gallium/auxiliary/util/u_inlines.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 2ff90c982d8..ba745ebb5fb 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -582,6 +582,22 @@ util_copy_constant_buffer(struct pipe_constant_buffer *dst, } } +static INLINE unsigned +util_max_layer(struct pipe_resource *r, unsigned level) +{ + switch (r->target) { + case PIPE_TEXTURE_CUBE: + return 6 - 1; + case PIPE_TEXTURE_3D: + return u_minify(r->depth0, level) - 1; + case PIPE_TEXTURE_1D_ARRAY: + case PIPE_TEXTURE_2D_ARRAY: + case PIPE_TEXTURE_CUBE_ARRAY: + return r->array_size - 1; + default: + return 0; + } +} #ifdef __cplusplus } -- cgit v1.2.3