mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 11:08:03 +02:00
mesa: Deduplicate _mesa_pack_ubyte_stencil_row()
util_format_pack_s_8uint() has the same behavior of replacing the s values but supports more formats. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10336>
This commit is contained in:
parent
8bd91d1368
commit
0e20f6a1e9
2 changed files with 5 additions and 49 deletions
|
|
@ -90,9 +90,12 @@ extern void
|
|||
_mesa_pack_uint_z_row(mesa_format format, uint32_t n,
|
||||
const uint32_t *src, void *dst);
|
||||
|
||||
extern void
|
||||
static inline void
|
||||
_mesa_pack_ubyte_stencil_row(mesa_format format, uint32_t n,
|
||||
const uint8_t *src, void *dst);
|
||||
const uint8_t *src, void *dst)
|
||||
{
|
||||
util_format_pack_s_8uint(format, dst, src, n);
|
||||
}
|
||||
|
||||
extern void
|
||||
_mesa_pack_uint_24_8_depth_stencil_row(mesa_format format, uint32_t n,
|
||||
|
|
|
|||
|
|
@ -591,53 +591,6 @@ _mesa_pack_uint_z_row(mesa_format format, uint32_t n,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_pack_ubyte_stencil_row(mesa_format format, uint32_t n,
|
||||
const uint8_t *src, void *dst)
|
||||
{
|
||||
switch (format) {
|
||||
case MESA_FORMAT_S8_UINT_Z24_UNORM:
|
||||
{
|
||||
/* don't disturb the Z values */
|
||||
uint32_t *d = ((uint32_t *) dst);
|
||||
uint32_t i;
|
||||
for (i = 0; i < n; i++) {
|
||||
uint32_t s = src[i];
|
||||
uint32_t z = d[i] & 0xffffff00;
|
||||
d[i] = z | s;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MESA_FORMAT_Z24_UNORM_S8_UINT:
|
||||
{
|
||||
/* don't disturb the Z values */
|
||||
uint32_t *d = ((uint32_t *) dst);
|
||||
uint32_t i;
|
||||
for (i = 0; i < n; i++) {
|
||||
uint32_t s = src[i] << 24;
|
||||
uint32_t z = d[i] & 0xffffff;
|
||||
d[i] = s | z;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MESA_FORMAT_S_UINT8:
|
||||
memcpy(dst, src, n * sizeof(uint8_t));
|
||||
break;
|
||||
case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
|
||||
{
|
||||
struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
|
||||
uint32_t i;
|
||||
for (i = 0; i < n; i++) {
|
||||
d[i].x24s8 = src[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
unreachable("unexpected format in _mesa_pack_ubyte_stencil_row()");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Incoming Z/stencil values are always in uint_24_8 format.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue