gallium/util: Implement util_format_translate_3d
authorAxel Davy <axel.davy@ens.fr>
Mon, 7 Mar 2016 20:35:59 +0000 (21:35 +0100)
committerAxel Davy <axel.davy@ens.fr>
Wed, 18 May 2016 21:37:14 +0000 (23:37 +0200)
This is the equivalent of util_format_translate, but for volumes.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/auxiliary/util/u_format.c
src/gallium/auxiliary/util/u_format.h

index 34df01d8b5e2375a6f44ec24dfb5d30dc2b08655..cbdb5ce9ddc2f2e6cb22a658d214f59454dca696 100644 (file)
@@ -739,6 +739,40 @@ util_format_translate(enum pipe_format dst_format,
    return TRUE;
 }
 
+boolean
+util_format_translate_3d(enum pipe_format dst_format,
+                         void *dst, unsigned dst_stride,
+                         unsigned dst_slice_stride,
+                         unsigned dst_x, unsigned dst_y,
+                         unsigned dst_z,
+                         enum pipe_format src_format,
+                         const void *src, unsigned src_stride,
+                         unsigned src_slice_stride,
+                         unsigned src_x, unsigned src_y,
+                         unsigned src_z, unsigned width,
+                         unsigned height, unsigned depth)
+{
+   uint8_t *dst_layer;
+   const uint8_t *src_layer;
+   unsigned z;
+   dst_layer = dst;
+   src_layer = src;
+   dst_layer += dst_z * dst_slice_stride;
+   src_layer += src_z * src_slice_stride;
+   for (z = 0; z < depth; ++z) {
+      if (!util_format_translate(dst_format, dst_layer, dst_stride,
+                                 dst_x, dst_y,
+                                 src_format, src_layer, src_stride,
+                                 src_x, src_y,
+                                 width, height))
+          return FALSE;
+
+      dst_layer += dst_slice_stride;
+      src_layer += src_slice_stride;
+   }
+   return TRUE;
+}
+
 void util_format_compose_swizzles(const unsigned char swz1[4],
                                   const unsigned char swz2[4],
                                   unsigned char dst[4])
index a99c1bc7bad233af8eca15188f4ae0a6bdbf4861..d0557785f93b9263a370836695f14221a16f565f 100644 (file)
@@ -1271,6 +1271,19 @@ util_format_translate(enum pipe_format dst_format,
                       unsigned src_x, unsigned src_y,
                       unsigned width, unsigned height);
 
+boolean
+util_format_translate_3d(enum pipe_format dst_format,
+                         void *dst, unsigned dst_stride,
+                         unsigned dst_slice_stride,
+                         unsigned dst_x, unsigned dst_y,
+                         unsigned dst_z,
+                         enum pipe_format src_format,
+                         const void *src, unsigned src_stride,
+                         unsigned src_slice_stride,
+                         unsigned src_x, unsigned src_y,
+                         unsigned src_z, unsigned width,
+                         unsigned height, unsigned depth);
+
 /*
  * Swizzle operations.
  */