[Mesa-dev] [PATCH 2/3] gallium/format: Add a helper to combine separate Z24 and S8 stencil.

Eric Anholt eric at anholt.net
Tue Aug 21 00:27:56 UTC 2018


Kenneth Graunke <kenneth at whitecape.org> writes:

> This new function takes separate Z24 depth and S8 stencil sources,
> and packs them into a single combined Z24S8 buffer.
> ---
>  src/gallium/auxiliary/util/u_format_zs.c | 20 ++++++++++++++++++++
>  src/gallium/auxiliary/util/u_format_zs.h |  2 ++
>  2 files changed, 22 insertions(+)
>
> diff --git a/src/gallium/auxiliary/util/u_format_zs.c b/src/gallium/auxiliary/util/u_format_zs.c
> index 69f2f2971f7..4138fbe6503 100644
> --- a/src/gallium/auxiliary/util/u_format_zs.c
> +++ b/src/gallium/auxiliary/util/u_format_zs.c
> @@ -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);
> +   }
> +}

missing spaces after for and around binary operators.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180820/3c6fc1e1/attachment-0001.sig>


More information about the mesa-dev mailing list