Mesa (master): util: Make all 3 fetch_rgba functions occupy the same function slot.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Aug 16 21:42:25 UTC 2020
Module: Mesa
Branch: master
Commit: 35b22b5da0277ba12fdb45fee79bca75cc6bcf5c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=35b22b5da0277ba12fdb45fee79bca75cc6bcf5c
Author: Eric Anholt <eric at anholt.net>
Date: Thu Aug 13 09:15:16 2020 -0700
util: Make all 3 fetch_rgba functions occupy the same function slot.
A single format either had the float, the sint, or the uint version.
Making the dst be void * lets us store them in the same slot and not have
logic in the callers to call the right one.
-6kb on gallium drivers
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6305>
---
src/gallium/auxiliary/gallivm/lp_bld_format_aos.c | 4 ++--
.../auxiliary/translate/translate_generic.c | 12 +----------
src/gallium/drivers/llvmpipe/lp_test_format.c | 2 +-
src/gallium/tests/unit/translate_test.c | 8 ++++----
src/util/format/u_format.h | 24 +---------------------
src/util/format/u_format_bptc.c | 8 ++++----
src/util/format/u_format_bptc.h | 8 ++++----
src/util/format/u_format_etc.c | 3 ++-
src/util/format/u_format_etc.h | 2 +-
src/util/format/u_format_latc.c | 12 +++++++----
src/util/format/u_format_latc.h | 8 ++++----
src/util/format/u_format_other.c | 9 +++++---
src/util/format/u_format_other.h | 6 +++---
src/util/format/u_format_pack.py | 11 +++++-----
src/util/format/u_format_rgtc.c | 12 +++++++----
src/util/format/u_format_rgtc.h | 8 ++++----
src/util/format/u_format_s3tc.c | 24 ++++++++++++++--------
src/util/format/u_format_s3tc.h | 16 +++++++--------
src/util/format/u_format_table.py | 6 +++---
src/util/format/u_format_yuv.c | 14 +++++++++----
src/util/format/u_format_yuv.h | 8 ++++----
src/util/tests/format/u_format_test.c | 6 +++---
22 files changed, 103 insertions(+), 108 deletions(-)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
index 4d23047ada2..aa99c2a7e2e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
@@ -897,7 +897,7 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
* Fallback to util_format_description::fetch_rgba_float().
*/
- if (unpack->fetch_rgba_float) {
+ if (unpack->fetch_rgba) {
/*
* Fallback to calling util_format_description::fetch_rgba_float.
*
@@ -944,7 +944,7 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
if (gallivm->cache)
gallivm->cache->dont_cache = true;
function = lp_build_const_func_pointer(gallivm,
- func_to_pointer((func_pointer) unpack->fetch_rgba_float),
+ func_to_pointer((func_pointer) unpack->fetch_rgba),
ret_type,
arg_types, ARRAY_SIZE(arg_types),
format_desc->short_name);
diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c
index 22d8d90b8a3..311fc384ffe 100644
--- a/src/gallium/auxiliary/translate/translate_generic.c
+++ b/src/gallium/auxiliary/translate/translate_generic.c
@@ -814,19 +814,9 @@ translate_generic_create(const struct translate_key *key)
FREE(tg);
return NULL;
}
-
- if (format_desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) {
- assert(unpack->fetch_rgba_sint);
- tg->attrib[i].fetch = (fetch_func)unpack->fetch_rgba_sint;
- } else {
- assert(unpack->fetch_rgba_uint);
- tg->attrib[i].fetch = (fetch_func)unpack->fetch_rgba_uint;
- }
- } else {
- assert(unpack->fetch_rgba_float);
- tg->attrib[i].fetch = (fetch_func)unpack->fetch_rgba_float;
}
+ tg->attrib[i].fetch = (fetch_func)unpack->fetch_rgba;
tg->attrib[i].buffer = key->element[i].input_buffer;
tg->attrib[i].input_offset = key->element[i].input_offset;
tg->attrib[i].instance_divisor = key->element[i].instance_divisor;
diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c
index 583e5fc0b4d..5facd85e309 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_format.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_format.c
@@ -392,7 +392,7 @@ test_all(unsigned verbose, FILE *fp)
* precompiled fetch func for any format before we write LLVM code to
* fetch from it.
*/
- if (!unpack->fetch_rgba_float)
+ if (!unpack->fetch_rgba)
continue;
/* only test twice with formats which can use cache */
diff --git a/src/gallium/tests/unit/translate_test.c b/src/gallium/tests/unit/translate_test.c
index 49a9c968300..807995cd256 100644
--- a/src/gallium/tests/unit/translate_test.c
+++ b/src/gallium/tests/unit/translate_test.c
@@ -178,7 +178,7 @@ int main(int argc, char** argv)
unsigned output_normalized = 0;
if (!output_format_desc
- || !output_format_unpack->fetch_rgba_float
+ || !output_format_unpack->fetch_rgba
|| !output_format_pack->pack_rgba_float
|| output_format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB
|| output_format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN
@@ -206,7 +206,7 @@ int main(int argc, char** argv)
boolean input_is_float = FALSE;
if (!input_format_desc
- || !input_format_unpack->fetch_rgba_float
+ || !input_format_unpack->fetch_rgba
|| !input_format_pack->pack_rgba_float
|| input_format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB
|| input_format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN
@@ -277,8 +277,8 @@ int main(int argc, char** argv)
{
float a[4];
float b[4];
- input_format_unpack->fetch_rgba_float(a, buffer[2] + i * input_format_size, 0, 0);
- input_format_unpack->fetch_rgba_float(b, buffer[4] + i * input_format_size, 0, 0);
+ input_format_unpack->fetch_rgba(a, buffer[2] + i * input_format_size, 0, 0);
+ input_format_unpack->fetch_rgba(b, buffer[4] + i * input_format_size, 0, 0);
for (j = 0; j < count; ++j)
{
diff --git a/src/util/format/u_format.h b/src/util/format/u_format.h
index 91198f65301..41d795e7b3f 100644
--- a/src/util/format/u_format.h
+++ b/src/util/format/u_format.h
@@ -351,9 +351,7 @@ struct util_format_unpack_description {
* Only defined for non-depth-stencil and non-integer formats.
*/
void
- (*fetch_rgba_float)(float *dst,
- const uint8_t *src,
- unsigned i, unsigned j);
+ (*fetch_rgba)(void *dst, const uint8_t *src, unsigned i, unsigned j);
/**
* Unpack pixels to Z32_UNORM.
@@ -387,26 +385,6 @@ struct util_format_unpack_description {
(*unpack_s_8uint)(uint8_t *dst, unsigned dst_stride,
const uint8_t *src, unsigned src_stride,
unsigned width, unsigned height);
-
- /**
- * Fetch a single pixel (i, j) from a block.
- *
- * Only defined for unsigned (pure) integer formats.
- */
- void
- (*fetch_rgba_uint)(uint32_t *dst,
- const uint8_t *src,
- unsigned i, unsigned j);
-
- /**
- * Fetch a single pixel (i, j) from a block.
- *
- * Only defined for signed (pure) integer formats.
- */
- void
- (*fetch_rgba_sint)(int32_t *dst,
- const uint8_t *src,
- unsigned i, unsigned j);
};
const struct util_format_description *
diff --git a/src/util/format/u_format_bptc.c b/src/util/format/u_format_bptc.c
index 142e6c8cc28..5482da3b7ec 100644
--- a/src/util/format/u_format_bptc.c
+++ b/src/util/format/u_format_bptc.c
@@ -86,7 +86,7 @@ util_format_bptc_rgba_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
}
void
-util_format_bptc_rgba_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_rgba_unorm_fetch_rgba(void *dst, const uint8_t *src,
unsigned width, unsigned height)
{
uint8_t temp_block[4];
@@ -149,7 +149,7 @@ util_format_bptc_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
}
void
-util_format_bptc_srgba_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_srgba_fetch_rgba(void *dst, const uint8_t *src,
unsigned width, unsigned height)
{
uint8_t temp_block[4];
@@ -213,7 +213,7 @@ util_format_bptc_rgb_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride
}
void
-util_format_bptc_rgb_float_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_rgb_float_fetch_rgba(void *dst, const uint8_t *src,
unsigned width, unsigned height)
{
fetch_rgb_float_from_block(src + ((width * sizeof(uint8_t)) * (height / 4) + (width / 4)) * 16,
@@ -271,7 +271,7 @@ util_format_bptc_rgb_ufloat_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
}
void
-util_format_bptc_rgb_ufloat_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_rgb_ufloat_fetch_rgba(void *dst, const uint8_t *src,
unsigned width, unsigned height)
{
fetch_rgb_float_from_block(src + ((width * sizeof(uint8_t)) * (height / 4) + (width / 4)) * 16,
diff --git a/src/util/format/u_format_bptc.h b/src/util/format/u_format_bptc.h
index e093ae3ce36..c98a54e902f 100644
--- a/src/util/format/u_format_bptc.h
+++ b/src/util/format/u_format_bptc.h
@@ -53,7 +53,7 @@ util_format_bptc_rgba_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_bptc_rgba_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_rgba_unorm_fetch_rgba(void *dst, const uint8_t *src,
unsigned width, unsigned height);
void
@@ -73,7 +73,7 @@ util_format_bptc_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_bptc_srgba_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_srgba_fetch_rgba(void *dst, const uint8_t *src,
unsigned width, unsigned height);
void
@@ -93,7 +93,7 @@ util_format_bptc_rgb_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_bptc_rgb_float_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_rgb_float_fetch_rgba(void *dst, const uint8_t *src,
unsigned width, unsigned height);
void
@@ -113,7 +113,7 @@ util_format_bptc_rgb_ufloat_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
const float *src_row, unsigned src_stride,
unsigned width, unsigned height);
void
-util_format_bptc_rgb_ufloat_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_rgb_ufloat_fetch_rgba(void *dst, const uint8_t *src,
unsigned width, unsigned height);
#ifdef __cplusplus
}
diff --git a/src/util/format/u_format_etc.c b/src/util/format/u_format_etc.c
index 8931242a52d..bde940e3ce2 100644
--- a/src/util/format/u_format_etc.c
+++ b/src/util/format/u_format_etc.c
@@ -67,8 +67,9 @@ util_format_etc1_rgb8_pack_rgba_float(UNUSED uint8_t *dst_row, UNUSED unsigned d
}
void
-util_format_etc1_rgb8_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_etc1_rgb8_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
struct etc1_block block;
uint8_t tmp[3];
diff --git a/src/util/format/u_format_etc.h b/src/util/format/u_format_etc.h
index 96795e1aec4..7093552b581 100644
--- a/src/util/format/u_format_etc.h
+++ b/src/util/format/u_format_etc.h
@@ -41,6 +41,6 @@ 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);
void
-util_format_etc1_rgb8_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_etc1_rgb8_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
#endif /* U_FORMAT_ETC1_H_ */
diff --git a/src/util/format/u_format_latc.c b/src/util/format/u_format_latc.c
index f5b2a649787..7c96c6601bd 100644
--- a/src/util/format/u_format_latc.c
+++ b/src/util/format/u_format_latc.c
@@ -88,8 +88,9 @@ util_format_latc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c
}
void
-util_format_latc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_latc1_unorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp_r;
util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
@@ -155,8 +156,9 @@ util_format_latc1_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, co
}
void
-util_format_latc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_latc1_snorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
int8_t tmp_r;
util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 1);
@@ -222,8 +224,9 @@ util_format_latc2_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, co
}
void
-util_format_latc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_latc2_unorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp_r, tmp_g;
util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
@@ -292,8 +295,9 @@ util_format_latc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c
}
void
-util_format_latc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_latc2_snorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
int8_t tmp_r, tmp_g;
util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 2);
diff --git a/src/util/format/u_format_latc.h b/src/util/format/u_format_latc.h
index 1328df6496a..d28bb844842 100644
--- a/src/util/format/u_format_latc.h
+++ b/src/util/format/u_format_latc.h
@@ -44,7 +44,7 @@ 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);
void
-util_format_latc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_latc1_unorm_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
@@ -64,7 +64,7 @@ void
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);
+util_format_latc1_snorm_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
@@ -83,7 +83,7 @@ void
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);
+util_format_latc2_unorm_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
@@ -102,7 +102,7 @@ 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);
void
-util_format_latc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_latc2_snorm_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
#endif
diff --git a/src/util/format/u_format_other.c b/src/util/format/u_format_other.c
index 6dd66c7d346..bd68966a580 100644
--- a/src/util/format/u_format_other.c
+++ b/src/util/format/u_format_other.c
@@ -74,9 +74,10 @@ util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride
}
void
-util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_r9g9b9e5_float_fetch_rgba(void *in_dst, const uint8_t *src,
UNUSED unsigned i, UNUSED unsigned j)
{
+ float *dst = in_dst;
uint32_t value = util_cpu_to_le32(*(const uint32_t *)src);
rgb9e5_to_float3(value, dst);
dst[3] = 1; /* a */
@@ -177,9 +178,10 @@ util_format_r11g11b10_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
}
void
-util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_r11g11b10_float_fetch_rgba(void *in_dst, const uint8_t *src,
UNUSED unsigned i, UNUSED unsigned j)
{
+ float *dst = in_dst;
uint32_t value = util_cpu_to_le32(*(const uint32_t *)src);
r11g11b10f_to_float3(value, dst);
dst[3] = 1; /* a */
@@ -362,9 +364,10 @@ util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
void
-util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_r8g8bx_snorm_fetch_rgba(void *in_dst, const uint8_t *src,
UNUSED unsigned i, UNUSED unsigned j)
{
+ float *dst = in_dst;
uint16_t value = util_cpu_to_le16(*(const uint16_t *)src);
int16_t r, g;
diff --git a/src/util/format/u_format_other.h b/src/util/format/u_format_other.h
index df9d057754f..c02b38a124b 100644
--- a/src/util/format/u_format_other.h
+++ b/src/util/format/u_format_other.h
@@ -44,7 +44,7 @@ util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride
unsigned width, unsigned height);
void
-util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_r9g9b9e5_float_fetch_rgba(void *dst, const uint8_t *src,
unsigned i, unsigned j);
void
@@ -69,7 +69,7 @@ util_format_r11g11b10_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
unsigned width, unsigned height);
void
-util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_r11g11b10_float_fetch_rgba(void *dst, const uint8_t *src,
unsigned i, unsigned j);
void
@@ -94,7 +94,7 @@ util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
unsigned width, unsigned height);
void
-util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_r8g8bx_snorm_fetch_rgba(void *dst, const uint8_t *src,
unsigned i, unsigned j);
void
diff --git a/src/util/format/u_format_pack.py b/src/util/format/u_format_pack.py
index e2fbc4cce91..7792f44ffde 100644
--- a/src/util/format/u_format_pack.py
+++ b/src/util/format/u_format_pack.py
@@ -683,14 +683,15 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix):
print()
-def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix):
+def generate_format_fetch(format, dst_channel, dst_native_type):
'''Generate the function to unpack pixels from a particular format'''
name = format.short_name()
print('static inline void')
- print('util_format_%s_fetch_%s(%s *dst, const uint8_t *src, UNUSED unsigned i, UNUSED unsigned j)' % (name, dst_suffix, dst_native_type))
+ print('util_format_%s_fetch_rgba(void *in_dst, const uint8_t *src, UNUSED unsigned i, UNUSED unsigned j)' % (name))
print('{')
+ print(' %s *dst = in_dst;' % dst_native_type)
if is_format_supported(format):
generate_unpack_kernel(format, dst_channel, dst_native_type)
@@ -729,7 +730,7 @@ def generate(formats):
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
- generate_format_fetch(format, channel, native_type, suffix)
+ generate_format_fetch(format, channel, native_type)
channel = Channel(SIGNED, False, True, 32)
native_type = 'int'
@@ -742,7 +743,7 @@ def generate(formats):
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
- generate_format_fetch(format, channel, native_type, suffix)
+ generate_format_fetch(format, channel, native_type)
native_type = 'unsigned'
suffix = 'unsigned'
@@ -755,7 +756,7 @@ def generate(formats):
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
- generate_format_fetch(format, channel, native_type, suffix)
+ generate_format_fetch(format, channel, native_type)
channel = Channel(UNSIGNED, True, False, 8)
native_type = 'uint8_t'
diff --git a/src/util/format/u_format_rgtc.c b/src/util/format/u_format_rgtc.c
index 1839dc55e70..fa65a71cd4a 100644
--- a/src/util/format/u_format_rgtc.c
+++ b/src/util/format/u_format_rgtc.c
@@ -133,8 +133,9 @@ util_format_rgtc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c
}
void
-util_format_rgtc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_rgtc1_unorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp_r;
util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
dst[0] = ubyte_to_float(tmp_r);
@@ -214,8 +215,9 @@ util_format_rgtc1_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, co
}
void
-util_format_rgtc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_rgtc1_snorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
int8_t tmp_r;
util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 1);
dst[0] = byte_to_float_tex(tmp_r);
@@ -342,8 +344,9 @@ util_format_rgtc2_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, co
}
void
-util_format_rgtc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_rgtc2_unorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
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);
@@ -435,8 +438,9 @@ util_format_rgtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c
}
void
-util_format_rgtc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_rgtc2_snorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
int8_t tmp_r, tmp_g;
util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 2);
util_format_signed_fetch_texel_rgtc(0, (int8_t *)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 5f5f8151278..1c600428fbf 100644
--- a/src/util/format/u_format_rgtc.h
+++ b/src/util/format/u_format_rgtc.h
@@ -44,7 +44,7 @@ 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);
void
-util_format_rgtc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_rgtc1_unorm_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
@@ -64,7 +64,7 @@ void
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);
+util_format_rgtc1_snorm_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
@@ -86,7 +86,7 @@ void
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);
+util_format_rgtc2_unorm_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
@@ -108,7 +108,7 @@ void
util_format_rgtc2_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_rgtc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_rgtc2_snorm_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
#endif
diff --git a/src/util/format/u_format_s3tc.c b/src/util/format/u_format_s3tc.c
index 4f61d614732..05889a4cc16 100644
--- a/src/util/format/u_format_s3tc.c
+++ b/src/util/format/u_format_s3tc.c
@@ -67,8 +67,9 @@ util_format_dxt5_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsign
}
void
-util_format_dxt1_rgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_rgb_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp[4];
util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
dst[0] = ubyte_to_float(tmp[0]);
@@ -78,8 +79,9 @@ util_format_dxt1_rgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i
}
void
-util_format_dxt1_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_rgba_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp[4];
util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
dst[0] = ubyte_to_float(tmp[0]);
@@ -89,8 +91,9 @@ util_format_dxt1_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned
}
void
-util_format_dxt3_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt3_rgba_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp[4];
util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
dst[0] = ubyte_to_float(tmp[0]);
@@ -100,8 +103,9 @@ util_format_dxt3_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned
}
void
-util_format_dxt5_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt5_rgba_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp[4];
util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
dst[0] = ubyte_to_float(tmp[0]);
@@ -484,8 +488,9 @@ util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsig
}
void
-util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_srgb_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp[4];
util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
@@ -495,8 +500,9 @@ util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned
}
void
-util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt1_srgba_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp[4];
util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
@@ -506,8 +512,9 @@ util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned
}
void
-util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt3_srgba_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp[4];
util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
@@ -517,8 +524,9 @@ util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned
}
void
-util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
+util_format_dxt5_srgba_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
{
+ float *dst = in_dst;
uint8_t tmp[4];
util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
diff --git a/src/util/format/u_format_s3tc.h b/src/util/format/u_format_s3tc.h
index c5cb7ad26da..4fe58fb1186 100644
--- a/src/util/format/u_format_s3tc.h
+++ b/src/util/format/u_format_s3tc.h
@@ -146,7 +146,7 @@ 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);
void
-util_format_dxt1_rgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_rgb_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
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);
@@ -155,7 +155,7 @@ 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);
void
-util_format_dxt1_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_rgba_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
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);
@@ -164,7 +164,7 @@ 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);
void
-util_format_dxt3_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt3_rgba_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
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);
@@ -173,7 +173,7 @@ 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);
void
-util_format_dxt5_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt5_rgba_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
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);
@@ -182,7 +182,7 @@ 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);
void
-util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_srgb_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
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);
@@ -191,7 +191,7 @@ 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);
void
-util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt1_srgba_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
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);
@@ -200,7 +200,7 @@ 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);
void
-util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt3_srgba_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
void
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);
@@ -209,7 +209,7 @@ 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);
void
-util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
+util_format_dxt5_srgba_fetch_rgba(void *dst, const uint8_t *src, unsigned i, unsigned j);
#ifdef __cplusplus
}
diff --git a/src/util/format/u_format_table.py b/src/util/format/u_format_table.py
index 3699e025290..7be1d4fdb5b 100644
--- a/src/util/format/u_format_table.py
+++ b/src/util/format/u_format_table.py
@@ -240,12 +240,14 @@ def write_format_table(formats):
continue
print(" [%s] = {" % (format.name,))
+ if format.colorspace != ZS:
+ print(" .fetch_rgba = &util_format_%s_fetch_rgba," % sn)
+
if format.colorspace != ZS and not format.is_pure_color():
print(" .unpack_rgba_8unorm = &util_format_%s_unpack_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 = &util_format_%s_unpack_rgba_float," % sn)
- print(" .fetch_rgba_float = &util_format_%s_fetch_rgba_float," % sn)
if format.has_depth():
print(" .unpack_z_32unorm = &util_format_%s_unpack_z_32unorm," % sn)
@@ -256,10 +258,8 @@ def write_format_table(formats):
if format.is_pure_unsigned():
print(" .unpack_rgba = &util_format_%s_unpack_unsigned," % sn)
- print(" .fetch_rgba_uint = &util_format_%s_fetch_unsigned," % sn)
elif format.is_pure_signed():
print(" .unpack_rgba = &util_format_%s_unpack_signed," % sn)
- print(" .fetch_rgba_sint = &util_format_%s_fetch_signed," % sn)
print(" },")
print("};")
print()
diff --git a/src/util/format/u_format_yuv.c b/src/util/format/u_format_yuv.c
index 21d082548c6..b5f75bdc0cf 100644
--- a/src/util/format/u_format_yuv.c
+++ b/src/util/format/u_format_yuv.c
@@ -245,9 +245,11 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
void
-util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_r8g8_b8g8_unorm_fetch_rgba(void *in_dst, const uint8_t *src,
unsigned i, ASSERTED unsigned j)
{
+ float *dst = in_dst;
+
assert(i < 2);
assert(j < 1);
@@ -465,9 +467,11 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
void
-util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_g8r8_g8b8_unorm_fetch_rgba(void *in_dst, const uint8_t *src,
unsigned i, ASSERTED unsigned j)
{
+ float *dst = in_dst;
+
assert(i < 2);
assert(j < 1);
@@ -681,9 +685,10 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
void
-util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_uyvy_fetch_rgba(void *in_dst, const uint8_t *src,
unsigned i, ASSERTED unsigned j)
{
+ float *dst = in_dst;
uint8_t y, u, v;
assert(i < 2);
@@ -902,9 +907,10 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
void
-util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_yuyv_fetch_rgba(void *in_dst, const uint8_t *src,
unsigned i, ASSERTED unsigned j)
{
+ float *dst = in_dst;
uint8_t y, u, v;
assert(i < 2);
diff --git a/src/util/format/u_format_yuv.h b/src/util/format/u_format_yuv.h
index 229adac9b39..20c5176e8dd 100644
--- a/src/util/format/u_format_yuv.h
+++ b/src/util/format/u_format_yuv.h
@@ -142,7 +142,7 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
unsigned width, unsigned height);
void
-util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_uyvy_fetch_rgba(void *dst, const uint8_t *src,
unsigned i, unsigned j);
void
@@ -166,7 +166,7 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
unsigned width, unsigned height);
void
-util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_yuyv_fetch_rgba(void *dst, const uint8_t *src,
unsigned i, unsigned j);
void
@@ -190,7 +190,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
unsigned width, unsigned height);
void
-util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_r8g8_b8g8_unorm_fetch_rgba(void *dst, const uint8_t *src,
unsigned i, unsigned j);
void
@@ -214,7 +214,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
unsigned width, unsigned height);
void
-util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_g8r8_g8b8_unorm_fetch_rgba(void *dst, const uint8_t *src,
unsigned i, unsigned j);
#endif /* U_FORMAT_YUV_H_ */
diff --git a/src/util/tests/format/u_format_test.c b/src/util/tests/format/u_format_test.c
index c93199ebd02..992bf5f3a95 100644
--- a/src/util/tests/format/u_format_test.c
+++ b/src/util/tests/format/u_format_test.c
@@ -201,7 +201,7 @@ print_unpacked_s_8uint(const struct util_format_description *format_desc,
static boolean
-test_format_fetch_rgba_float(const struct util_format_description *format_desc,
+test_format_fetch_rgba(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
const struct util_format_unpack_description *unpack =
@@ -213,7 +213,7 @@ test_format_fetch_rgba_float(const struct util_format_description *format_desc,
success = TRUE;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
- unpack->fetch_rgba_float(unpacked[i][j], test->packed, j, i);
+ unpack->fetch_rgba(unpacked[i][j], test->packed, j, i);
for (k = 0; k < 4; ++k) {
if (!compare_float(test->unpacked[i][j][k], unpacked[i][j][k])) {
success = FALSE;
@@ -818,7 +818,7 @@ test_all(void)
success = FALSE; \
} \
- TEST_ONE_UNPACK_FUNC(fetch_rgba_float);
+ TEST_ONE_UNPACK_FUNC(fetch_rgba);
TEST_ONE_PACK_FUNC(pack_rgba_float);
TEST_ONE_UNPACK_FUNC(unpack_rgba);
TEST_ONE_PACK_FUNC(pack_rgba_8unorm);
More information about the mesa-commit
mailing list