From 09a47a9a88c4bc55aa8b20a8b367d408ef2f0c93 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Thu, 24 Jul 2025 09:50:46 +0300 Subject: [PATCH] Cleanup: remove manually-ran IMB_performance_test The performance test was added in 6d93bf6b44a3d4, but I don't think anyone has ever ran it since then. And due to how IMB library depends on BKE, this drags in "almost all of blender" into the test executable, resulting in non-trivial link times that everyone pays for. Just remove it. --- source/blender/imbuf/CMakeLists.txt | 1 - .../imbuf/tests/performance/CMakeLists.txt | 24 --- .../IMB_scaling_performance_test.cc | 144 ------------------ 3 files changed, 169 deletions(-) delete mode 100644 source/blender/imbuf/tests/performance/CMakeLists.txt delete mode 100644 source/blender/imbuf/tests/performance/IMB_scaling_performance_test.cc diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index a4faef400d2..a268adb904f 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -168,5 +168,4 @@ if(WITH_GTESTS) tests/IMB_transform_test.cc ) blender_add_test_suite_lib(imbuf "${TEST_SRC}" "${INC}" "${INC_SYS}" "${LIB}") - add_subdirectory(tests/performance) endif() diff --git a/source/blender/imbuf/tests/performance/CMakeLists.txt b/source/blender/imbuf/tests/performance/CMakeLists.txt deleted file mode 100644 index 42f16b1cdbe..00000000000 --- a/source/blender/imbuf/tests/performance/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Blender Authors -# -# SPDX-License-Identifier: GPL-2.0-or-later - -set(INC - ../.. -) - -set(INC_SYS -) - -set(LIB - PRIVATE bf_blenlib - PRIVATE bf_imbuf -) - -set(SRC - IMB_scaling_performance_test.cc -) - -blender_add_test_performance_executable(IMB_performance "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") -if(WITH_BUILDINFO) - target_link_libraries(IMB_performance_test PRIVATE buildinfoobj) -endif() diff --git a/source/blender/imbuf/tests/performance/IMB_scaling_performance_test.cc b/source/blender/imbuf/tests/performance/IMB_scaling_performance_test.cc deleted file mode 100644 index 2b9e61be589..00000000000 --- a/source/blender/imbuf/tests/performance/IMB_scaling_performance_test.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: Apache-2.0 */ - -#include "testing/testing.h" - -#include "IMB_imbuf.hh" - -#include "BLI_math_base.hh" -#include "BLI_math_matrix.hh" -#include "BLI_timeit.hh" - -using namespace blender; - -static constexpr int SRC_X = 5123; -static constexpr int SRC_Y = 4091; - -static constexpr int DST_SMALLER_X = int(SRC_X * 0.21f); -static constexpr int DST_SMALLER_Y = int(SRC_Y * 0.67f); - -static constexpr int DST_LARGER_X = int(SRC_X * 1.19f); -static constexpr int DST_LARGER_Y = int(SRC_Y * 2.13f); - -static ImBuf *create_src_image(bool use_float) -{ - ImBuf *img = IMB_allocImBuf(SRC_X, SRC_Y, 32, use_float ? IB_float_data : IB_byte_data); - if (use_float) { - const size_t img_pixel_count = IMB_get_pixel_count(img); - float *pix = img->float_buffer.data; - for (size_t i = 0; i < img_pixel_count; i++) { - pix[0] = i * 0.1f; - pix[1] = i * 2.1f; - pix[2] = i * 0.01f; - pix[3] = math::mod(i * 0.03f, 2.0f); - pix += 4; - } - } - else { - const size_t img_pixel_count = IMB_get_pixel_count(img); - uchar *pix = img->byte_buffer.data; - for (size_t i = 0; i < img_pixel_count; i++) { - pix[0] = i & 0xFF; - pix[1] = (i * 3) & 0xFF; - pix[2] = (i + 12345) & 0xFF; - pix[3] = (i / 4) & 0xFF; - pix += 4; - } - } - return img; -} - -static void imb_scale_via_transform(ImBuf *&src, - int width, - int height, - eIMBInterpolationFilterMode filter) -{ - ImBuf *dst = IMB_allocImBuf(width, height, src->planes, src->flags); - float3x3 matrix = math::from_scale( - float3(float(src->x) / dst->x, float(src->y) / dst->y, 1.0f)); - IMB_transform(src, dst, IMB_TRANSFORM_MODE_REGULAR, filter, matrix, nullptr); - IMB_freeImBuf(src); - src = dst; -} - -static void imb_xform_nearest(ImBuf *&src, int width, int height) -{ - imb_scale_via_transform(src, width, height, IMB_FILTER_NEAREST); -} -static void imb_xform_bilinear(ImBuf *&src, int width, int height) -{ - imb_scale_via_transform(src, width, height, IMB_FILTER_BILINEAR); -} -static void imb_xform_box(ImBuf *&src, int width, int height) -{ - imb_scale_via_transform(src, - width, - height, - width < src->x && height < src->y ? IMB_FILTER_BOX : - IMB_FILTER_BILINEAR); -} -static void imb_scale_nearest_st(ImBuf *&src, int width, int height) -{ - IMB_scale(src, width, height, IMBScaleFilter::Nearest, false); -} -static void imb_scale_nearest(ImBuf *&src, int width, int height) -{ - IMB_scale(src, width, height, IMBScaleFilter::Nearest, true); -} -static void imb_scale_bilinear_st(ImBuf *&src, int width, int height) -{ - IMB_scale(src, width, height, IMBScaleFilter::Bilinear, false); -} -static void imb_scale_bilinear(ImBuf *&src, int width, int height) -{ - IMB_scale(src, width, height, IMBScaleFilter::Bilinear, true); -} -static void imb_scale_box_st(ImBuf *&src, int width, int height) -{ - IMB_scale(src, width, height, IMBScaleFilter::Box, false); -} -static void imb_scale_box(ImBuf *&src, int width, int height) -{ - IMB_scale(src, width, height, IMBScaleFilter::Box, true); -} - -static void scale_perf_impl(const char *name, - bool use_float, - void (*func)(ImBuf *&src, int width, int height)) -{ - ImBuf *img = create_src_image(use_float); - { - SCOPED_TIMER(name); - func(img, DST_LARGER_X, DST_LARGER_Y); - func(img, SRC_X, SRC_Y); - func(img, DST_SMALLER_X, DST_SMALLER_Y); - func(img, DST_LARGER_X, DST_LARGER_Y); - } - IMB_freeImBuf(img); -} - -static void test_scaling_perf(bool use_float) -{ - scale_perf_impl("scale_neare_s", use_float, imb_scale_nearest_st); - scale_perf_impl("scale_neare_m", use_float, imb_scale_nearest); - scale_perf_impl("xform_neare_m", use_float, imb_xform_nearest); - - scale_perf_impl("scale_bilin_s", use_float, imb_scale_bilinear_st); - scale_perf_impl("scale_bilin_m", use_float, imb_scale_bilinear); - scale_perf_impl("xform_bilin_m", use_float, imb_xform_bilinear); - - scale_perf_impl("scale_boxfl_s", use_float, imb_scale_box_st); - scale_perf_impl("scale_boxfl_m", use_float, imb_scale_box); - scale_perf_impl("xform_boxfl_m", use_float, imb_xform_box); -} - -TEST(imbuf_scaling, scaling_perf_byte) -{ - test_scaling_perf(false); -} - -TEST(imbuf_scaling, scaling_perf_float) -{ - test_scaling_perf(true); -}