mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 13:38:06 +02:00
dri: Fix "cosmetic" undefined behaviour warning for RGB[A]16_UNORM formats.
Ian Romanick reported some "undefined behaviour" warnings during some not specified tests, relating to introduction of RGB[A}16_UNORM formats in merge request https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38588 This due to overflowing the 32-bits masks[], and then during assignment the red/green/blue/alphaMask fields in struct gl_config when using a 16 bpc format. Iow. the red/green/blue/alphaMask would not be usable. Suppress this warning by setting masks[] to zero for unorm16 formats, just as was previously done for is_float16, ie. fp16 formats. 16 bpc formats are only exposed for display on non-X11 WSI target platforms like GBM+DRM, Wayland, surfaceless, and these platforms do not use the info in red/green/blue/alphaMask at all, so the "undefined behaviour" is meaningless. Fixes:f2aaa9ce00("dri,gallium: Add support for RGB[A]16_UNORM display formats.") Reported-by: Ian Romanick @idr Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> (cherry picked from commitab94515b0a) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40752>
This commit is contained in:
parent
58ab5760c1
commit
af53a9bfbc
2 changed files with 8 additions and 2 deletions
|
|
@ -74,7 +74,7 @@
|
|||
"description": "dri: Fix \"cosmetic\" undefined behaviour warning for RGB[A]16_UNORM formats.",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "f2aaa9ce00ffe7310bddcd5e884f34afb741f460",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -153,9 +153,11 @@ driCreateConfigs(enum pipe_format format,
|
|||
unsigned num_accum_bits = (enable_accum) ? 2 : 1;
|
||||
bool is_srgb;
|
||||
bool is_float;
|
||||
bool is_unorm16;
|
||||
|
||||
is_srgb = util_format_is_srgb(format);
|
||||
is_float = util_format_is_float(format);
|
||||
is_unorm16 = util_format_is_unorm16(util_format_description(format));
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
color_bits[i] =
|
||||
|
|
@ -168,7 +170,11 @@ driCreateConfigs(enum pipe_format format,
|
|||
shifts[i] = -1;
|
||||
}
|
||||
|
||||
if (is_float || color_bits[i] == 0)
|
||||
/* is_float and is_unorm16 is only true on non-x11 target platforms, which
|
||||
* don't actually use redMask, greenMask, ..., so avoid setting masks[]
|
||||
* to prevent a meaningless "undefined behaviour" build warning.
|
||||
*/
|
||||
if (is_float || is_unorm16 || color_bits[i] == 0)
|
||||
masks[i] = 0;
|
||||
else
|
||||
masks[i] = ((1u << color_bits[i]) - 1) << shifts[i];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue