From: Eric Anholt Date: Wed, 1 Jul 2020 20:33:21 +0000 (-0700) Subject: util: Share a single function pointer for the 4-byte rgba unpack function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b7418270c34b0476345488ea9a9c7185a7327e15;p=mesa.git util: Share a single function pointer for the 4-byte rgba unpack function. Everyone wants the same behavior, and this helps shrink the size of our format description tables. Reviewed-by: Marek Olšák Part-of: --- diff --git a/src/gallium/drivers/nouveau/nv30/nv30_vbo.c b/src/gallium/drivers/nouveau/nv30/nv30_vbo.c index 99ceef77403..b50157c3b1a 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_vbo.c @@ -47,7 +47,7 @@ nv30_emit_vtxattr(struct nv30_context *nv30, struct pipe_vertex_buffer *vb, data = nouveau_resource_map_offset(&nv30->base, res, vb->buffer_offset + ve->src_offset, NOUVEAU_BO_RD); - util_format_unpack_rgba_float(ve->src_format, v, data, 1); + util_format_unpack_rgba(ve->src_format, v, data, 1); switch (nc) { case 4: diff --git a/src/util/format/u_format.c b/src/util/format/u_format.c index 5bb4b0fdb00..cd732642154 100644 --- a/src/util/format/u_format.c +++ b/src/util/format/u_format.c @@ -341,12 +341,7 @@ util_format_read_4(enum pipe_format format, src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8); - if (util_format_is_pure_uint(format)) - format_desc->unpack_rgba_sint(dst, dst_stride, src_row, src_stride, w, h); - else if (util_format_is_pure_uint(format)) - format_desc->unpack_rgba_uint(dst, dst_stride, src_row, src_stride, w, h); - else - format_desc->unpack_rgba_float(dst, dst_stride, src_row, src_stride, w, h); + format_desc->unpack_rgba(dst, dst_stride, src_row, src_stride, w, h); } @@ -695,8 +690,8 @@ util_format_translate(enum pipe_format dst_format, unsigned tmp_stride; int *tmp_row; - if (!src_format_desc->unpack_rgba_sint || - !dst_format_desc->pack_rgba_sint) { + if (util_format_is_pure_sint(src_format) != + util_format_is_pure_sint(dst_format)) { return FALSE; } @@ -706,7 +701,7 @@ util_format_translate(enum pipe_format dst_format, return FALSE; while (height >= y_step) { - src_format_desc->unpack_rgba_sint(tmp_row, tmp_stride, src_row, src_stride, width, y_step); + src_format_desc->unpack_rgba(tmp_row, tmp_stride, src_row, src_stride, width, y_step); dst_format_desc->pack_rgba_sint(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step); dst_row += dst_step; @@ -715,7 +710,7 @@ util_format_translate(enum pipe_format dst_format, } if (height) { - src_format_desc->unpack_rgba_sint(tmp_row, tmp_stride, src_row, src_stride, width, height); + src_format_desc->unpack_rgba(tmp_row, tmp_stride, src_row, src_stride, width, height); dst_format_desc->pack_rgba_sint(dst_row, dst_stride, tmp_row, tmp_stride, width, height); } @@ -726,7 +721,7 @@ util_format_translate(enum pipe_format dst_format, unsigned tmp_stride; unsigned int *tmp_row; - if (!src_format_desc->unpack_rgba_uint || + if (!src_format_desc->unpack_rgba || !dst_format_desc->pack_rgba_uint) { return FALSE; } @@ -737,7 +732,7 @@ util_format_translate(enum pipe_format dst_format, return FALSE; while (height >= y_step) { - src_format_desc->unpack_rgba_uint(tmp_row, tmp_stride, src_row, src_stride, width, y_step); + src_format_desc->unpack_rgba(tmp_row, tmp_stride, src_row, src_stride, width, y_step); dst_format_desc->pack_rgba_uint(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step); dst_row += dst_step; @@ -746,7 +741,7 @@ util_format_translate(enum pipe_format dst_format, } if (height) { - src_format_desc->unpack_rgba_uint(tmp_row, tmp_stride, src_row, src_stride, width, height); + src_format_desc->unpack_rgba(tmp_row, tmp_stride, src_row, src_stride, width, height); dst_format_desc->pack_rgba_uint(dst_row, dst_stride, tmp_row, tmp_stride, width, height); } @@ -756,7 +751,7 @@ util_format_translate(enum pipe_format dst_format, unsigned tmp_stride; float *tmp_row; - if (!src_format_desc->unpack_rgba_float || + if (!src_format_desc->unpack_rgba || !dst_format_desc->pack_rgba_float) { return FALSE; } @@ -767,7 +762,7 @@ util_format_translate(enum pipe_format dst_format, return FALSE; while (height >= y_step) { - src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, y_step); + src_format_desc->unpack_rgba(tmp_row, tmp_stride, src_row, src_stride, width, y_step); dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step); dst_row += dst_step; @@ -776,7 +771,7 @@ util_format_translate(enum pipe_format dst_format, } if (height) { - src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, height); + src_format_desc->unpack_rgba(tmp_row, tmp_stride, src_row, src_stride, width, height); dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, height); } diff --git a/src/util/format/u_format.h b/src/util/format/u_format.h index 4ce3b58bde2..4b182ff558d 100644 --- a/src/util/format/u_format.h +++ b/src/util/format/u_format.h @@ -274,15 +274,17 @@ struct util_format_description unsigned i, unsigned j); /** - * Unpack pixel blocks to R32G32B32A32_FLOAT. + * Unpack pixel blocks to R32G32B32A32_UINT/_INT_FLOAT based on whether the + * type is pure uint, int, or other. + * * Note: strides are in bytes. * * Only defined for non-depth-stencil formats. */ void - (*unpack_rgba_float)(float *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); + (*unpack_rgba)(void *dst, unsigned dst_stride, + const uint8_t *src, unsigned src_stride, + unsigned width, unsigned height); /** * Pack pixel blocks from R32G32B32A32_FLOAT. @@ -371,33 +373,11 @@ struct util_format_description const uint8_t *src, unsigned src_stride, unsigned width, unsigned height); - /** - * Unpack pixel blocks to R32G32B32A32_UINT. - * Note: strides are in bytes. - * - * Only defined for INT formats. - */ - void - (*unpack_rgba_uint)(uint32_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - void (*pack_rgba_uint)(uint8_t *dst, unsigned dst_stride, const uint32_t *src, unsigned src_stride, unsigned width, unsigned height); - /** - * Unpack pixel blocks to R32G32B32A32_SINT. - * Note: strides are in bytes. - * - * Only defined for INT formats. - */ - void - (*unpack_rgba_sint)(int32_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - void (*pack_rgba_sint)(uint8_t *dst, unsigned dst_stride, const int32_t *src, unsigned src_stride, @@ -1473,15 +1453,6 @@ util_format_unpack_s_8uint(enum pipe_format format, uint8_t *dst, desc->unpack_s_8uint(dst, 0, (const uint8_t *)src, 0, w, 1); } -static inline void -util_format_unpack_rgba_float(enum pipe_format format, float *dst, - const void *src, unsigned w) -{ - const struct util_format_description *desc = util_format_description(format); - - desc->unpack_rgba_float(dst, 0, (const uint8_t *)src, 0, w, 1); -} - /** * Unpacks a row of color data to 32-bit RGBA, either integers for pure * integer formats (sign-extended for signed data), or 32-bit floats. @@ -1492,12 +1463,7 @@ util_format_unpack_rgba(enum pipe_format format, void *dst, { const struct util_format_description *desc = util_format_description(format); - if (util_format_is_pure_uint(format)) - desc->unpack_rgba_uint((uint32_t *)dst, 0, (const uint8_t *)src, 0, w, 1); - else if (util_format_is_pure_sint(format)) - desc->unpack_rgba_sint((int32_t *)dst, 0, (const uint8_t *)src, 0, w, 1); - else - desc->unpack_rgba_float((float *)dst, 0, (const uint8_t *)src, 0, w, 1); + desc->unpack_rgba(dst, 0, (const uint8_t *)src, 0, w, 1); } static inline void diff --git a/src/util/format/u_format_bptc.c b/src/util/format/u_format_bptc.c index 60f789ce0e0..142e6c8cc28 100644 --- a/src/util/format/u_format_bptc.c +++ b/src/util/format/u_format_bptc.c @@ -52,7 +52,7 @@ util_format_bptc_rgba_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri } void -util_format_bptc_rgba_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_bptc_rgba_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -121,7 +121,7 @@ util_format_bptc_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } void -util_format_bptc_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_bptc_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -191,7 +191,7 @@ util_format_bptc_rgb_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid } void -util_format_bptc_rgb_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_bptc_rgb_float_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -249,7 +249,7 @@ util_format_bptc_rgb_ufloat_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri } void -util_format_bptc_rgb_ufloat_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_bptc_rgb_ufloat_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { diff --git a/src/util/format/u_format_bptc.h b/src/util/format/u_format_bptc.h index eaf3ec396ab..e093ae3ce36 100644 --- a/src/util/format/u_format_bptc.h +++ b/src/util/format/u_format_bptc.h @@ -45,7 +45,7 @@ util_format_bptc_rgba_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_bptc_rgba_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_bptc_rgba_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void @@ -65,7 +65,7 @@ util_format_bptc_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_bptc_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_bptc_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void @@ -85,7 +85,7 @@ util_format_bptc_rgb_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_bptc_rgb_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_bptc_rgb_float_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void @@ -105,7 +105,7 @@ util_format_bptc_rgb_ufloat_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_bptc_rgb_ufloat_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_bptc_rgb_ufloat_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void diff --git a/src/util/format/u_format_etc.c b/src/util/format/u_format_etc.c index 505e57b41f1..8931242a52d 100644 --- a/src/util/format/u_format_etc.c +++ b/src/util/format/u_format_etc.c @@ -25,7 +25,7 @@ util_format_etc1_rgb8_pack_rgba_8unorm(UNUSED uint8_t *dst_row, UNUSED unsigned } void -util_format_etc1_rgb8_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_etc1_rgb8_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { const unsigned bw = 4, bh = 4, bs = 8, comps = 4; struct etc1_block block; @@ -38,7 +38,7 @@ util_format_etc1_rgb8_unpack_rgba_float(float *dst_row, unsigned dst_stride, con etc1_parse_block(&block, src); for (j = 0; j < bh; j++) { - float *dst = dst_row + (y + j) * dst_stride / sizeof(*dst_row) + x * comps; + float *dst = (float *)((uint8_t *)dst_row + (y + j) * dst_stride + x * comps * 4); uint8_t tmp[3]; for (i = 0; i < bw; i++) { diff --git a/src/util/format/u_format_etc.h b/src/util/format/u_format_etc.h index 30c3dcb920d..96795e1aec4 100644 --- a/src/util/format/u_format_etc.h +++ b/src/util/format/u_format_etc.h @@ -35,7 +35,7 @@ void util_format_etc1_rgb8_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_etc1_rgb8_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_etc1_rgb8_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_etc1_rgb8_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); diff --git a/src/util/format/u_format_latc.c b/src/util/format/u_format_latc.c index 1f26cb18f3a..f5b2a649787 100644 --- a/src/util/format/u_format_latc.c +++ b/src/util/format/u_format_latc.c @@ -56,7 +56,7 @@ util_format_latc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } void -util_format_latc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_latc1_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { unsigned x, y, i, j; int block_size = 8; @@ -66,7 +66,7 @@ util_format_latc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c for(x = 0; x < width; x += 4) { for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16); uint8_t tmp_r; util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1); dst[0] = @@ -129,7 +129,7 @@ util_format_latc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c } void -util_format_latc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_latc1_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { unsigned x, y, i, j; int block_size = 8; @@ -139,7 +139,7 @@ util_format_latc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c for(x = 0; x < width; x += 4) { for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16); int8_t tmp_r; util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1); dst[0] = @@ -195,7 +195,7 @@ util_format_latc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c } void -util_format_latc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_latc2_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { unsigned x, y, i, j; int block_size = 16; @@ -205,7 +205,7 @@ util_format_latc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c for(x = 0; x < width; x += 4) { for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16); uint8_t tmp_r, tmp_g; util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2); util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2); @@ -259,7 +259,7 @@ util_format_latc2_snorm_pack_rgba_8unorm(UNUSED uint8_t *dst_row, UNUSED unsigne } void -util_format_latc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_latc2_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { unsigned x, y, i, j; int block_size = 16; @@ -269,7 +269,7 @@ util_format_latc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c for(x = 0; x < width; x += 4) { for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + float *dst = (float *)(uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16; int8_t tmp_r, tmp_g; util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2); util_format_signed_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2); diff --git a/src/util/format/u_format_latc.h b/src/util/format/u_format_latc.h index 1f08887533d..1328df6496a 100644 --- a/src/util/format/u_format_latc.h +++ b/src/util/format/u_format_latc.h @@ -38,7 +38,7 @@ void util_format_latc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_latc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_latc1_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_latc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -61,7 +61,7 @@ void util_format_latc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_latc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_latc1_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_latc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); @@ -80,7 +80,7 @@ void util_format_latc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_latc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_latc2_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_latc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); @@ -96,7 +96,7 @@ void util_format_latc2_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_latc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_latc2_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_latc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); diff --git a/src/util/format/u_format_other.c b/src/util/format/u_format_other.c index 5599bfde387..4f304e00130 100644 --- a/src/util/format/u_format_other.c +++ b/src/util/format/u_format_other.c @@ -33,7 +33,7 @@ void -util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_r9g9b9e5_float_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -49,7 +49,7 @@ util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride dst += 4; } src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); + dst_row = (uint8_t *)dst_row + dst_stride; } } @@ -136,7 +136,7 @@ util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid void -util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_r11g11b10_float_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -152,7 +152,7 @@ util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_strid dst += 4; } src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); + dst_row = (uint8_t *)dst_row + dst_stride; } } @@ -239,7 +239,7 @@ util_format_r11g11b10_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri void -util_format_r1_unorm_unpack_rgba_float(UNUSED float *dst_row, UNUSED unsigned dst_stride, +util_format_r1_unorm_unpack_rgba_float(UNUSED void *dst_row, UNUSED unsigned dst_stride, UNUSED const uint8_t *src_row, UNUSED unsigned src_stride, UNUSED unsigned width, UNUSED unsigned height) { @@ -298,7 +298,7 @@ r8g8bx_derive(int16_t r, int16_t g) } void -util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_r8g8bx_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -321,7 +321,7 @@ util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, dst += 4; } src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); + dst_row = (uint8_t *)dst_row + dst_stride; } } diff --git a/src/util/format/u_format_other.h b/src/util/format/u_format_other.h index 2f6a908bbe8..8ca5d05bc8f 100644 --- a/src/util/format/u_format_other.h +++ b/src/util/format/u_format_other.h @@ -34,7 +34,7 @@ void -util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_r9g9b9e5_float_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -59,7 +59,7 @@ util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid void -util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_r11g11b10_float_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -84,7 +84,7 @@ util_format_r11g11b10_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri void -util_format_r1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_r1_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -108,7 +108,7 @@ util_format_r1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, unsigned width, unsigned height); void -util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_r8g8bx_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); diff --git a/src/util/format/u_format_pack.py b/src/util/format/u_format_pack.py index c8749a2c047..3307027bbbd 100644 --- a/src/util/format/u_format_pack.py +++ b/src/util/format/u_format_pack.py @@ -624,8 +624,13 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): name = format.short_name() + if "8unorm" in dst_suffix: + dst_proto_type = dst_native_type + else: + dst_proto_type = 'void' + print('static inline void') - print('util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type)) + print('util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_proto_type)) print('{') if is_format_supported(format): @@ -641,7 +646,7 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): print(' dst += 4;') print(' }') print(' src_row += src_stride;') - print(' dst_row += dst_stride/sizeof(*dst_row);') + print(' dst_row = (uint8_t *)dst_row + dst_stride;') print(' }') print('}') diff --git a/src/util/format/u_format_rgtc.c b/src/util/format/u_format_rgtc.c index a663b8a75cc..1839dc55e70 100644 --- a/src/util/format/u_format_rgtc.c +++ b/src/util/format/u_format_rgtc.c @@ -86,7 +86,7 @@ util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } void -util_format_rgtc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_rgtc1_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { unsigned x, y, i, j; int block_size = 8; @@ -95,7 +95,7 @@ util_format_rgtc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c for(x = 0; x < width; x += 4) { for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16); uint8_t tmp_r; util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1); dst[0] = ubyte_to_float(tmp_r); @@ -189,7 +189,7 @@ util_format_rgtc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c } void -util_format_rgtc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_rgtc1_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { unsigned x, y, i, j; int block_size = 8; @@ -198,7 +198,7 @@ util_format_rgtc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c for(x = 0; x < width; x += 4) { for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16); int8_t tmp_r; util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1); dst[0] = byte_to_float_tex(tmp_r); @@ -316,7 +316,7 @@ util_format_rgtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c } void -util_format_rgtc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_rgtc2_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { unsigned x, y, i, j; int block_size = 16; @@ -325,7 +325,7 @@ util_format_rgtc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c for(x = 0; x < width; x += 4) { for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16); uint8_t tmp_r, tmp_g; util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2); util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2); @@ -378,7 +378,7 @@ util_format_rgtc2_snorm_pack_rgba_8unorm(UNUSED uint8_t *dst_row, UNUSED unsigne } void -util_format_rgtc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_rgtc2_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { unsigned x, y, i, j; int block_size = 16; @@ -387,7 +387,7 @@ util_format_rgtc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c for(x = 0; x < width; x += 4) { for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16); int8_t tmp_r, tmp_g; util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2); util_format_signed_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2); diff --git a/src/util/format/u_format_rgtc.h b/src/util/format/u_format_rgtc.h index 67ac4728e56..5f5f8151278 100644 --- a/src/util/format/u_format_rgtc.h +++ b/src/util/format/u_format_rgtc.h @@ -38,7 +38,7 @@ void util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_rgtc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_rgtc1_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_rgtc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -61,7 +61,7 @@ void util_format_rgtc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_rgtc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_rgtc1_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_rgtc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); @@ -83,7 +83,7 @@ void util_format_rgtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_rgtc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_rgtc2_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_rgtc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); @@ -99,7 +99,7 @@ void util_format_rgtc2_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void -util_format_rgtc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_rgtc2_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_rxtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off); diff --git a/src/util/format/u_format_s3tc.c b/src/util/format/u_format_s3tc.c index 498039841fb..4f61d614732 100644 --- a/src/util/format/u_format_s3tc.c +++ b/src/util/format/u_format_s3tc.c @@ -228,7 +228,7 @@ util_format_dxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, } void -util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_dxt1_rgb_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -240,7 +240,7 @@ util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, } void -util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_dxt1_rgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -252,7 +252,7 @@ util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, } void -util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_dxt3_rgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -264,7 +264,7 @@ util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, } void -util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_dxt5_rgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -568,7 +568,7 @@ util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } void -util_format_dxt1_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_srgb_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, @@ -578,7 +578,7 @@ util_format_dxt1_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, con } void -util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, @@ -588,7 +588,7 @@ util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, co } void -util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt3_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, @@ -598,7 +598,7 @@ util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, co } void -util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt5_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, diff --git a/src/util/format/u_format_s3tc.h b/src/util/format/u_format_s3tc.h index 6f188c67f95..c5cb7ad26da 100644 --- a/src/util/format/u_format_s3tc.h +++ b/src/util/format/u_format_s3tc.h @@ -140,7 +140,7 @@ util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsig void -util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_dxt1_rgb_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -149,7 +149,7 @@ void util_format_dxt1_rgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_dxt1_rgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_dxt1_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -158,7 +158,7 @@ void util_format_dxt1_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_dxt3_rgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_dxt3_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -167,7 +167,7 @@ void util_format_dxt3_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_dxt5_rgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_dxt5_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -176,7 +176,7 @@ void util_format_dxt5_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_dxt1_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_dxt1_srgb_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_dxt1_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -185,7 +185,7 @@ void util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_dxt1_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_dxt1_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -194,7 +194,7 @@ void util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_dxt3_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_dxt3_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -203,7 +203,7 @@ void util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +util_format_dxt5_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); void util_format_dxt5_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); diff --git a/src/util/format/u_format_table.py b/src/util/format/u_format_table.py index dc73f510391..8ca8ec33cde 100644 --- a/src/util/format/u_format_table.py +++ b/src/util/format/u_format_table.py @@ -179,7 +179,7 @@ def write_format_table(formats): print(" .pack_rgba_8unorm = &util_format_%s_pack_rgba_8unorm," % sn) if format.layout == 's3tc' or format.layout == 'rgtc': print(" .fetch_rgba_8unorm = &util_format_%s_fetch_rgba_8unorm," % sn) - print(" .unpack_rgba_float = &util_format_%s_unpack_rgba_float," % sn) + print(" .unpack_rgba = &util_format_%s_unpack_rgba_float," % sn) print(" .pack_rgba_float = &util_format_%s_pack_rgba_float," % sn) print(" .fetch_rgba_float = &util_format_%s_fetch_rgba_float," % sn) @@ -194,13 +194,13 @@ def write_format_table(formats): print(" .pack_s_8uint = &util_format_%s_pack_s_8uint," % sn) if format.is_pure_unsigned(): - print(" .unpack_rgba_uint = &util_format_%s_unpack_unsigned," % sn) + print(" .unpack_rgba = &util_format_%s_unpack_unsigned," % sn) print(" .pack_rgba_uint = &util_format_%s_pack_unsigned," % sn) print(" .pack_rgba_sint = &util_format_%s_pack_signed," % sn) print(" .fetch_rgba_uint = &util_format_%s_fetch_unsigned," % sn) elif format.is_pure_signed(): print(" .pack_rgba_uint = &util_format_%s_pack_unsigned," % sn) - print(" .unpack_rgba_sint = &util_format_%s_unpack_signed," % sn) + print(" .unpack_rgba = &util_format_%s_unpack_signed," % sn) print(" .pack_rgba_sint = &util_format_%s_pack_signed," % sn) print(" .fetch_rgba_sint = &util_format_%s_fetch_signed," % sn) print("};") diff --git a/src/util/format/u_format_yuv.c b/src/util/format/u_format_yuv.c index 0b2eb821d4d..21d082548c6 100644 --- a/src/util/format/u_format_yuv.c +++ b/src/util/format/u_format_yuv.c @@ -39,7 +39,7 @@ void -util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_r8g8_b8g8_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -86,8 +86,8 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid dst[3] = 1.0f; /* a */ } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); + src_row = (uint8_t *)src_row + src_stride; + dst_row = (uint8_t *)dst_row + dst_stride; } } @@ -259,7 +259,7 @@ util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, void -util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_g8r8_g8b8_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -306,8 +306,8 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid dst[3] = 1.0f; /* a */ } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); + src_row = (uint8_t *)src_row + src_stride; + dst_row = (uint8_t *)dst_row + dst_stride; } } @@ -479,7 +479,7 @@ util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, void -util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_uyvy_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -520,8 +520,8 @@ util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, dst[3] = 1.0f; /* a */ } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); + src_row = (uint8_t *)src_row + src_stride; + dst_row = (uint8_t *)dst_row + dst_stride; } } @@ -700,7 +700,7 @@ util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src, void -util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_yuyv_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { @@ -741,8 +741,8 @@ util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, dst[3] = 1.0f; /* a */ } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); + src_row = (uint8_t *)src_row + src_stride; + dst_row = (uint8_t *)dst_row + dst_stride; } } diff --git a/src/util/format/u_format_yuv.h b/src/util/format/u_format_yuv.h index 862744e8a30..229adac9b39 100644 --- a/src/util/format/u_format_yuv.h +++ b/src/util/format/u_format_yuv.h @@ -122,7 +122,7 @@ util_format_yuv_to_rgb_8unorm(uint8_t y, uint8_t u, uint8_t v, void -util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_uyvy_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -146,7 +146,7 @@ util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_yuyv_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -170,7 +170,7 @@ util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_r8g8_b8g8_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); @@ -194,7 +194,7 @@ util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); void -util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, +util_format_g8r8_g8b8_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); diff --git a/src/util/tests/format/u_format_test.c b/src/util/tests/format/u_format_test.c index 69e3b5aebfd..a6f1d608c84 100644 --- a/src/util/tests/format/u_format_test.c +++ b/src/util/tests/format/u_format_test.c @@ -235,16 +235,16 @@ test_format_fetch_rgba_float(const struct util_format_description *format_desc, static boolean -test_format_unpack_rgba_float(const struct util_format_description *format_desc, - const struct util_format_test_case *test) +test_format_unpack_rgba(const struct util_format_description *format_desc, + const struct util_format_test_case *test) { float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } }; unsigned i, j, k; boolean success; - format_desc->unpack_rgba_float(&unpacked[0][0][0], sizeof unpacked[0], - test->packed, 0, - format_desc->block.width, format_desc->block.height); + format_desc->unpack_rgba(&unpacked[0][0][0], sizeof unpacked[0], + test->packed, 0, + format_desc->block.width, format_desc->block.height); success = TRUE; for (i = 0; i < format_desc->block.height; ++i) { @@ -359,6 +359,9 @@ test_format_unpack_rgba_8unorm(const struct util_format_description *format_desc unsigned i, j, k; boolean success; + if (util_format_is_pure_integer(format_desc->format)) + return FALSE; + format_desc->unpack_rgba_8unorm(&unpacked[0][0][0], sizeof unpacked[0], test->packed, 0, format_desc->block.width, format_desc->block.height); @@ -788,7 +791,7 @@ test_all(void) TEST_ONE_FUNC(fetch_rgba_float); TEST_ONE_FUNC(pack_rgba_float); - TEST_ONE_FUNC(unpack_rgba_float); + TEST_ONE_FUNC(unpack_rgba); TEST_ONE_FUNC(pack_rgba_8unorm); TEST_ONE_FUNC(unpack_rgba_8unorm);