Alpha format only contains one channel, but it is placed in the 4th
position, not 1st.
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23497>
union pipe_color_union clamp_color = *color;
int i;
- for (i = 0; i < util_format_get_nr_components(format); i++) {
+ for (i = 0; i < 4; i++) {
uint8_t bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, i);
+ if (!bits)
+ continue;
+
if (util_format_is_unorm(format))
clamp_color.ui[i] = _mesa_unorm_to_unorm(clamp_color.ui[i], bits, bits);
else if (util_format_is_snorm(format))