gallium/format: Add a helper to combine separate Z24 and S8 stencil.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 30 Jul 2018 22:20:00 +0000 (15:20 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 15 Oct 2018 06:36:28 +0000 (23:36 -0700)
This new function takes separate Z24 depth and S8 stencil sources,
and packs them into a single combined Z24S8 buffer.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/auxiliary/util/u_format_zs.c
src/gallium/auxiliary/util/u_format_zs.h

index 4ad3a0c64777d3896816d0786bf1c3e124f67d57..4b801d2dcf711a2e8c1d5f4c74be89b1c0f777d7 100644 (file)
@@ -448,6 +448,26 @@ util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride
    }
 }
 
+void
+util_format_z24_unorm_s8_uint_pack_separate(uint8_t *dst_row, unsigned dst_stride,
+                                            const uint32_t *z_src_row, unsigned z_src_stride,
+                                            const uint8_t *s_src_row, unsigned s_src_stride,
+                                            unsigned width, unsigned height)
+{
+   unsigned x, y;
+   for (y = 0; y < height; ++y) {
+      const uint32_t *z_src = z_src_row;
+      const uint8_t *s_src = s_src_row;
+      uint32_t *dst = (uint32_t *)dst_row;
+      for (x = 0; x < width; ++x) {
+         *dst++ = (*z_src++ & 0x00ffffff) | (*s_src++ << 24);
+      }
+      dst_row += dst_stride / sizeof(*dst_row);
+      z_src_row += z_src_stride / sizeof(*z_src_row);
+      s_src_row += s_src_stride / sizeof(*s_src_row);
+   }
+}
+
 void
 util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
                                                 const uint8_t *src_row, unsigned src_stride,
index adddfaf3a74da7c4911979e0658f84c615a5519d..160919dde73e9c90d57ad746069ff27de191beed 100644 (file)
@@ -112,6 +112,8 @@ util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stri
 void
 util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
 
+void
+util_format_z24_unorm_s8_uint_pack_separate(uint8_t *dst_row, unsigned dst_stride, const uint32_t *z_src_row, unsigned z_src_stride, const uint8_t *s_src_row, unsigned s_src_stride, const unsigned width, unsigned height);
 
 void
 util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);