diff options
author | Kenneth Graunke <[email protected]> | 2018-07-30 15:20:00 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2018-10-14 23:36:28 -0700 |
commit | c3d219837af66b4299ab7e746b65ff33a0a6ca0d (patch) | |
tree | b98292b407a1e7968515ccd0e63fdd5503324cc6 | |
parent | 5849e0612cc4c21d213bdb4bd8d0a3f9531cc2b3 (diff) |
gallium/format: Add a helper to combine separate Z24 and S8 stencil.
This new function takes separate Z24 depth and S8 stencil sources,
and packs them into a single combined Z24S8 buffer.
Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r-- | src/gallium/auxiliary/util/u_format_zs.c | 20 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_format_zs.h | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format_zs.c b/src/gallium/auxiliary/util/u_format_zs.c index 4ad3a0c6477..4b801d2dcf7 100644 --- a/src/gallium/auxiliary/util/u_format_zs.c +++ b/src/gallium/auxiliary/util/u_format_zs.c @@ -449,6 +449,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, unsigned width, unsigned height) diff --git a/src/gallium/auxiliary/util/u_format_zs.h b/src/gallium/auxiliary/util/u_format_zs.h index adddfaf3a74..160919dde73 100644 --- a/src/gallium/auxiliary/util/u_format_zs.h +++ b/src/gallium/auxiliary/util/u_format_zs.h @@ -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); |