mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 13:48:06 +02:00
radv: fix UB in radv_format_pack_clear_color for snorm formats
Casting a negative float to uint64_t is undefined behavior. GCC 15 with
-O2 produces 0xFFFFFFFFFFFFFFFF for (uint64_t)(-32767.5f), causing snorm
clear values to be packed incorrectly (e.g. 0xFFFF instead of 0x8001 for
snorm16 -1.0). This results in wrong DCC comp-to-single clear colors and
~966 CTS snorm multisample_resolve test failures.
Fix by casting through int64_t first, which is well-defined (truncation
toward zero) and preserves the two's complement bit pattern.
Fixes: 585c25be1e ("radv: fix color conversions for normalized uint/sint formats")
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41164>
This commit is contained in:
parent
12f43d048e
commit
2595940b0d
1 changed files with 1 additions and 1 deletions
|
|
@ -615,7 +615,7 @@ radv_format_pack_clear_color(VkFormat format, uint32_t clear_vals[2], VkClearCol
|
|||
else
|
||||
f -= 0.5f;
|
||||
|
||||
v = (uint64_t)f;
|
||||
v = (uint64_t)(int64_t)f;
|
||||
}
|
||||
} else if (channel->type == UTIL_FORMAT_TYPE_FLOAT) {
|
||||
if (channel->size == 32) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue