From 53756c172f17457b7093fef736a4ce1c5e497ce8 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Thu, 7 May 2026 13:35:01 +0100 Subject: [PATCH 1/2] Avoid NaN conversion to int --- Source/astcenc_weight_align.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/astcenc_weight_align.cpp b/Source/astcenc_weight_align.cpp index e961b3c22..249fbf8df 100644 --- a/Source/astcenc_weight_align.cpp +++ b/Source/astcenc_weight_align.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- -// Copyright 2011-2025 Arm Limited +// Copyright 2011-2026 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy @@ -130,6 +130,10 @@ static void compute_angular_offsets( } vfloat angle = atan2(anglesum_y, anglesum_x); + + // Suppress NaNs generated if anglesums are both zero + angle = select(vfloat::zero(), angle, angle == angle); + vfloat ofs = angle * mult; storea(ofs, offsets + i); } From 0a4fcb30e425e8018592eabbed91a95a99050dfd Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Thu, 7 May 2026 13:46:13 +0100 Subject: [PATCH 2/2] Add change log entry --- Docs/ChangeLog-5x.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Docs/ChangeLog-5x.md b/Docs/ChangeLog-5x.md index eedf9c46f..f8173a832 100644 --- a/Docs/ChangeLog-5x.md +++ b/Docs/ChangeLog-5x.md @@ -17,6 +17,8 @@ The 5.5.0 release is a minor maintenance release. * **Bug fix:** Add missing low-clamp when storing decompressed HDR data into a UNORM8 image. Prior to this fix, output colors would be incorrect if a HDR void-extent block contained a negative FP16 color value. + * **Bug fix:** Avoid undefined NaN to int conversion behavior that is + triggered by NaNs generated by atan2() calls where both inputs are zero. ## 5.4.0