From 0e063c5deb60e6a116dd6cef33dd5be5585e3db7 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 5 May 2026 14:13:44 -0400 Subject: [PATCH] util/half: Stop whacking CPU flags to test float_to_half_slow() Smashing bits is super sketchy. However, all the bits do is force the test down the _slow path so let's explicitly test that instead. Reviewed-by: Erik Faye-Lund Part-of: --- src/util/tests/half_float_test.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/util/tests/half_float_test.cpp b/src/util/tests/half_float_test.cpp index b867f2c3fdc..695f765ec35 100644 --- a/src/util/tests/half_float_test.cpp +++ b/src/util/tests/half_float_test.cpp @@ -137,7 +137,7 @@ test_float_to_half_limits(uint16_t (*func)(float)) } static void -u_half_test_test(void) +test_float_to_half_roundtrip(uint16_t (*func)(float)) { unsigned i; unsigned roundtrip_fails = 0; @@ -149,7 +149,7 @@ u_half_test_test(void) uint16_t rh; f.f = _mesa_half_to_float(h); - rh = _mesa_float_to_half(f.f); + rh = func(f.f); if (h != rh && !(util_is_half_nan(h) && util_is_half_nan(rh))) { printf("Roundtrip failed: %x -> %x = %f -> %x\n", h, f.ui, f.f, rh); @@ -162,13 +162,8 @@ u_half_test_test(void) TEST(u_half_test, u_half_test) { - u_half_test_test(); - - /* Test non-f16c. */ - if (util_get_cpu_caps()->has_f16c) { - ((struct util_cpu_caps_t *)util_get_cpu_caps())->has_f16c = false; - u_half_test_test(); - } + test_float_to_half_roundtrip(_mesa_float_to_half); + test_float_to_half_roundtrip(_mesa_float_to_half_slow); } TEST(float_to_half_test, float_to_half_test)