Re: [Mesa-dev] [PATCH 11/13] gallium/util: implement pack functions for Z32F and Z32F_S8X24
On Fri, 2011-07-01 at 14:42 +0200, Marek Olšák wrote: > On Fri, Jul 1, 2011 at 10:49 AM, Keith Whitwell wrote: > > On Fri, 2011-07-01 at 02:29 +0200, Marek Olšák wrote: > >> The suffix of 64 means it returns uint64_t. > > > > It might be slightly clearer to call these functions util_pack64_{xxx} > > -- currently it reads as if it is packing 64-bit source data. > > Yeah, that's nicer. Here's the diff I am going to squash with the > patches 11 and 12. Looks great! Keith ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 11/13] gallium/util: implement pack functions for Z32F and Z32F_S8X24
On Fri, Jul 1, 2011 at 10:49 AM, Keith Whitwell wrote: > On Fri, 2011-07-01 at 02:29 +0200, Marek Olšák wrote: >> The suffix of 64 means it returns uint64_t. > > It might be slightly clearer to call these functions util_pack64_{xxx} > -- currently it reads as if it is packing 64-bit source data. Yeah, that's nicer. Here's the diff I am going to squash with the patches 11 and 12. Marek diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index d2dfba5..9391f1b 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -460,7 +460,7 @@ util_pack_mask_z(enum pipe_format format, uint32_t z) static INLINE uint64_t -util_pack_mask_z64(enum pipe_format format, uint32_t z) +util_pack64_mask_z(enum pipe_format format, uint32_t z) { switch (format) { case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: @@ -495,13 +495,13 @@ util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s) static INLINE uint64_t -util_pack_mask_z_stencil64(enum pipe_format format, uint32_t z, uint8_t s) +util_pack64_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s) { uint64_t packed; switch (format) { case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: - packed = util_pack_mask_z64(format, z); + packed = util_pack64_mask_z(format, z); packed |= (uint64_t)s << 32ull; return packed; default: @@ -556,7 +556,7 @@ util_pack_z(enum pipe_format format, double z) static INLINE uint64_t -util_pack_z64(enum pipe_format format, double z) +util_pack64_z(enum pipe_format format, double z) { union fi fui; @@ -601,13 +601,13 @@ util_pack_z_stencil(enum pipe_format format, double z, uint8_t s) static INLINE uint64_t -util_pack_z_stencil64(enum pipe_format format, double z, uint8_t s) +util_pack64_z_stencil(enum pipe_format format, double z, uint8_t s) { uint64_t packed; switch (format) { case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: - packed = util_pack_z64(format, z); + packed = util_pack64_z(format, z); packed |= (uint64_t)s << 32ull; break; default: diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 8fcf6b9..8e12386 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -361,7 +361,7 @@ util_clear_depth_stencil(struct pipe_context *pipe, break; case 8: { - uint64_t zstencil = util_pack_z_stencil64(dst->texture->format, + uint64_t zstencil = util_pack64_z_stencil(dst->texture->format, depth, stencil); assert(dst->format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED); ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 11/13] gallium/util: implement pack functions for Z32F and Z32F_S8X24
On Fri, 2011-07-01 at 02:29 +0200, Marek Olšák wrote: > The suffix of 64 means it returns uint64_t. It might be slightly clearer to call these functions util_pack64_{xxx} -- currently it reads as if it is packing 64-bit source data. Keith > --- > src/gallium/auxiliary/util/u_pack_color.h | 64 > + > 1 files changed, 64 insertions(+), 0 deletions(-) > > diff --git a/src/gallium/auxiliary/util/u_pack_color.h > b/src/gallium/auxiliary/util/u_pack_color.h > index 5378f2d..d2dfba5 100644 > --- a/src/gallium/auxiliary/util/u_pack_color.h > +++ b/src/gallium/auxiliary/util/u_pack_color.h > @@ -458,6 +458,19 @@ util_pack_mask_z(enum pipe_format format, uint32_t z) > } > } > > + > +static INLINE uint64_t > +util_pack_mask_z64(enum pipe_format format, uint32_t z) > +{ > + switch (format) { > + case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: > + return z; > + default: > + return util_pack_mask_z(format, z); > + } > +} > + > + > static INLINE uint32_t > util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s) > { > @@ -481,6 +494,21 @@ util_pack_mask_z_stencil(enum pipe_format format, > uint32_t z, uint8_t s) > } > > > +static INLINE uint64_t > +util_pack_mask_z_stencil64(enum pipe_format format, uint32_t z, uint8_t s) > +{ > + uint64_t packed; > + > + switch (format) { > + case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: > + packed = util_pack_mask_z64(format, z); > + packed |= (uint64_t)s << 32ull; > + return packed; > + default: > + return util_pack_mask_z_stencil(format, z, s); > + } > +} > + > > /** > * Note: it's assumed that z is in [0,1] > @@ -525,6 +553,24 @@ util_pack_z(enum pipe_format format, double z) >return 0; > } > } > + > + > +static INLINE uint64_t > +util_pack_z64(enum pipe_format format, double z) > +{ > + union fi fui; > + > + if (z == 0) > + return 0; > + > + switch (format) { > + case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: > + fui.f = (float)z; > + return fui.ui; > + default: > + return util_pack_z(format, z); > + } > +} > > > /** > @@ -554,6 +600,24 @@ util_pack_z_stencil(enum pipe_format format, double z, > uint8_t s) > } > > > +static INLINE uint64_t > +util_pack_z_stencil64(enum pipe_format format, double z, uint8_t s) > +{ > + uint64_t packed; > + > + switch (format) { > + case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: > + packed = util_pack_z64(format, z); > + packed |= (uint64_t)s << 32ull; > + break; > + default: > + return util_pack_z_stencil(format, z, s); > + } > + > + return packed; > +} > + > + > /** > * Pack 4 ubytes into a 4-byte word > */ ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 11/13] gallium/util: implement pack functions for Z32F and Z32F_S8X24
The suffix of 64 means it returns uint64_t. --- src/gallium/auxiliary/util/u_pack_color.h | 64 + 1 files changed, 64 insertions(+), 0 deletions(-) diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index 5378f2d..d2dfba5 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -458,6 +458,19 @@ util_pack_mask_z(enum pipe_format format, uint32_t z) } } + +static INLINE uint64_t +util_pack_mask_z64(enum pipe_format format, uint32_t z) +{ + switch (format) { + case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + return z; + default: + return util_pack_mask_z(format, z); + } +} + + static INLINE uint32_t util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s) { @@ -481,6 +494,21 @@ util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s) } +static INLINE uint64_t +util_pack_mask_z_stencil64(enum pipe_format format, uint32_t z, uint8_t s) +{ + uint64_t packed; + + switch (format) { + case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + packed = util_pack_mask_z64(format, z); + packed |= (uint64_t)s << 32ull; + return packed; + default: + return util_pack_mask_z_stencil(format, z, s); + } +} + /** * Note: it's assumed that z is in [0,1] @@ -525,6 +553,24 @@ util_pack_z(enum pipe_format format, double z) return 0; } } + + +static INLINE uint64_t +util_pack_z64(enum pipe_format format, double z) +{ + union fi fui; + + if (z == 0) + return 0; + + switch (format) { + case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + fui.f = (float)z; + return fui.ui; + default: + return util_pack_z(format, z); + } +} /** @@ -554,6 +600,24 @@ util_pack_z_stencil(enum pipe_format format, double z, uint8_t s) } +static INLINE uint64_t +util_pack_z_stencil64(enum pipe_format format, double z, uint8_t s) +{ + uint64_t packed; + + switch (format) { + case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + packed = util_pack_z64(format, z); + packed |= (uint64_t)s << 32ull; + break; + default: + return util_pack_z_stencil(format, z, s); + } + + return packed; +} + + /** * Pack 4 ubytes into a 4-byte word */ -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev