From 8d38b25788c9f9bcc1c8bf2a422162328ac663d1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 13 Aug 2020 13:23:35 -0700 Subject: [PATCH] util: Explicitly call the unpack functions from inside bptc pack/unpack. We were calling the table-based unpack functions from inside the pack and unpack table's methods, so if anything included these pack functions (such as a call to a table-based pack function), you'd pull in all of unpack as well. By calling them explicitly, we save some overhead in these functions (switch statement, address math on the zero x,y arguments) anyway. Reviewed-by: Jonathan Marek Part-of: --- src/util/SConscript | 1 + src/util/format/u_format_bptc.c | 36 +++++++++++++++----------------- src/util/format/u_format_pack.py | 1 - 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/util/SConscript b/src/util/SConscript index 410279d2d2d..a4cbc2ffef7 100644 --- a/src/util/SConscript +++ b/src/util/SConscript @@ -17,6 +17,7 @@ env.Prepend(CPPPATH = [ '#src/gallium/auxiliary', '#src/util', '#src/util/format', + env.Dir('format'), # Build path corresponding to src/util/format ]) env.CodeGenerate( diff --git a/src/util/format/u_format_bptc.c b/src/util/format/u_format_bptc.c index 5482da3b7ec..33709746571 100644 --- a/src/util/format/u_format_bptc.c +++ b/src/util/format/u_format_bptc.c @@ -25,6 +25,7 @@ #include "util/format/u_format.h" #include "util/format/u_format_bptc.h" +#include "u_format_pack.h" #include "util/format_srgb.h" #include "util/u_math.h" @@ -61,10 +62,10 @@ util_format_bptc_rgba_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride decompress_rgba_unorm(width, height, src_row, src_stride, temp_block, width * 4 * sizeof(uint8_t)); - util_format_read_4(PIPE_FORMAT_R8G8B8A8_UNORM, + util_format_r8g8b8a8_unorm_unpack_rgba_float( dst_row, dst_stride, temp_block, width * 4 * sizeof(uint8_t), - 0, 0, width, height); + width, height); free((void *) temp_block); } @@ -75,10 +76,10 @@ util_format_bptc_rgba_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid { uint8_t *temp_block; temp_block = malloc(width * height * 4 * sizeof(uint8_t)); - util_format_read_4ub(PIPE_FORMAT_R32G32B32A32_FLOAT, + util_format_r32g32b32a32_float_unpack_rgba_8unorm( temp_block, width * 4 * sizeof(uint8_t), - src_row, src_stride, - 0, 0, width, height); + (uint8_t *)src_row, src_stride, + width, height); compress_rgba_unorm(width, height, temp_block, width * 4 * sizeof(uint8_t), dst_row, dst_stride); @@ -130,10 +131,10 @@ util_format_bptc_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride, decompress_rgba_unorm(width, height, src_row, src_stride, temp_block, width * 4 * sizeof(uint8_t)); - util_format_read_4(PIPE_FORMAT_R8G8B8A8_SRGB, - dst_row, dst_stride, - temp_block, width * 4 * sizeof(uint8_t), - 0, 0, width, height); + util_format_r8g8b8a8_srgb_unpack_rgba_float(dst_row, dst_stride, + temp_block, width * 4 * sizeof(uint8_t), + width, height); + free((void *) temp_block); } @@ -156,10 +157,7 @@ util_format_bptc_srgba_fetch_rgba(void *dst, const uint8_t *src, fetch_rgba_unorm_from_block(src + ((width * sizeof(uint8_t)) * (height / 4) + (width / 4)) * 16, temp_block, (width % 4) + (height % 4) * 4); - util_format_read_4(PIPE_FORMAT_R8G8B8A8_SRGB, - dst, 4 * sizeof(float), - temp_block, width * 4 * sizeof(uint8_t), - 0, 0, 1, 1); + util_format_r8g8b8a8_srgb_fetch_rgba(dst, temp_block, 0, 0); } void @@ -173,10 +171,10 @@ util_format_bptc_rgb_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_str src_row, src_stride, temp_block, width * 4 * sizeof(float), true); - util_format_read_4ub(PIPE_FORMAT_R32G32B32A32_FLOAT, + util_format_r32g32b32a32_float_unpack_rgba_8unorm( dst_row, dst_stride, - temp_block, width * 4 * sizeof(float), - 0, 0, width, height); + (const uint8_t *)temp_block, width * 4 * sizeof(float), + width, height); free((void *) temp_block); } @@ -231,10 +229,10 @@ util_format_bptc_rgb_ufloat_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st src_row, src_stride, temp_block, width * 4 * sizeof(float), false); - util_format_read_4ub(PIPE_FORMAT_R32G32B32A32_FLOAT, + util_format_r32g32b32a32_float_unpack_rgba_8unorm( dst_row, dst_stride, - temp_block, width * 4 * sizeof(float), - 0, 0, width, height); + (const uint8_t *)temp_block, width * 4 * sizeof(float), + width, height); free((void *) temp_block); } diff --git a/src/util/format/u_format_pack.py b/src/util/format/u_format_pack.py index d6554bbf973..a9a77923095 100644 --- a/src/util/format/u_format_pack.py +++ b/src/util/format/u_format_pack.py @@ -692,7 +692,6 @@ def generate_format_fetch(format, dst_channel, dst_native_type): name = format.short_name() proto = 'util_format_%s_fetch_rgba(void *in_dst, const uint8_t *src, UNUSED unsigned i, UNUSED unsigned j)' % (name) - print('void %s;' % proto, file=sys.stdout2) print('void') -- 2.30.2