[Mesa-dev] [PATCH 1/2] util: add util_resource_is_array_texture()

Chia-I Wu olvaffe at gmail.com
Fri Jun 7 00:44:59 PDT 2013


Checking if array_size is greater than 1 is not enough for single-layered
array textures.

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
---
 src/gallium/auxiliary/util/u_resource.h |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_resource.h b/src/gallium/auxiliary/util/u_resource.h
index 977e013..a5e091f 100644
--- a/src/gallium/auxiliary/util/u_resource.h
+++ b/src/gallium/auxiliary/util/u_resource.h
@@ -26,9 +26,27 @@
 #ifndef U_RESOURCE_H
 #define U_RESOURCE_H
 
-struct pipe_resource;
+#include "pipe/p_state.h"
 
 unsigned
 util_resource_size(const struct pipe_resource *res);
 
+/**
+ * Return true if the resource is an array texture.
+ *
+ * Note that this function returns true for single-layered array textures.
+ */
+static INLINE boolean
+util_resource_is_array_texture(const struct pipe_resource *res)
+{
+   switch (res->target) {
+   case PIPE_TEXTURE_1D_ARRAY:
+   case PIPE_TEXTURE_2D_ARRAY:
+   case PIPE_TEXTURE_CUBE_ARRAY:
+      return TRUE;
+   default:
+      return FALSE;
+   }
+}
+
 #endif
-- 
1.7.10.4



More information about the mesa-dev mailing list