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> (cherry picked from commit2595940b0d) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41269>
This commit is contained in:
parent
64127c4bd9
commit
ab39d20454
2 changed files with 2 additions and 2 deletions
|
|
@ -1114,7 +1114,7 @@
|
|||
"description": "radv: fix UB in radv_format_pack_clear_color for snorm formats",
|
||||
"nominated": false,
|
||||
"nomination_type": 2,
|
||||
"resolution": 4,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "585c25be1e1a96568829542f2765e97c63d79939",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -592,7 +592,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