mesa: Add a helper function to query 3D block sizes
authorAnuj Phogat <anuj.phogat@gmail.com>
Wed, 9 Mar 2016 19:38:54 +0000 (11:38 -0800)
committerAnuj Phogat <anuj.phogat@gmail.com>
Tue, 3 May 2016 10:43:17 +0000 (03:43 -0700)
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/formats.c
src/mesa/main/formats.h

index 3d2349b7304bf064cd24b9ffa6766e8cae20e773..cfaac04f13a301523094e5d2f7ae9967cbe8d918 100644 (file)
@@ -320,6 +320,27 @@ _mesa_get_format_block_size(mesa_format format, GLuint *bw, GLuint *bh)
 }
 
 
+/**
+ * Return the block size (in pixels) for the given format. Normally
+ * the block size is 1x1x1. But compressed formats will have block
+ * sizes of 4x4x4, 3x3x3 pixels, etc.
+ * \param bw  returns block width in pixels
+ * \param bh  returns block height in pixels
+ * \param bd  returns block depth in pixels
+ */
+void
+_mesa_get_format_block_size_3d(mesa_format format,
+                               GLuint *bw,
+                               GLuint *bh,
+                               GLuint *bd)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+   *bw = info->BlockWidth;
+   *bh = info->BlockHeight;
+   *bd = info->BlockDepth;
+}
+
+
 /**
  * Returns the an array of four numbers representing the transformation
  * from the RGBA or SZ colorspace to the given format.  For array formats,
index 794d599db3b8cb6ec7f43ffe5de97a93bb7cc3ce..c6653bc5984f8065d43f27125db26c4afe4f3409 100644 (file)
@@ -663,6 +663,10 @@ _mesa_get_format_base_format(uint32_t format);
 extern void
 _mesa_get_format_block_size(mesa_format format, GLuint *bw, GLuint *bh);
 
+extern void
+_mesa_get_format_block_size_3d(mesa_format format, GLuint *bw,
+                               GLuint *bh, GLuint *bd);
+
 extern mesa_array_format
 _mesa_array_format_flip_channels(mesa_array_format format);