freedreno/a6xx: Sysmem clear fixes

Handled signed/unsigned channel clamping.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11676
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30794>
This commit is contained in:
Rob Clark 2024-08-22 09:53:38 -07:00 committed by Marge Bot
parent 2cf590dd60
commit 76e350671f

View file

@ -850,8 +850,26 @@ FD_GENX(fd6_clear_lrz);
static union pipe_color_union static union pipe_color_union
convert_color(enum pipe_format format, union pipe_color_union *pcolor) convert_color(enum pipe_format format, union pipe_color_union *pcolor)
{ {
const struct util_format_description *desc = util_format_description(format);
union pipe_color_union color = *pcolor; union pipe_color_union color = *pcolor;
for (unsigned i = 0; i < 4; i++) {
unsigned channel = desc->swizzle[i];
if (desc->channel[channel].normalized)
continue;
switch (desc->channel[channel].type) {
case UTIL_FORMAT_TYPE_SIGNED:
color.i[i] = MAX2(color.i[i], -(1<<(desc->channel[channel].size - 1)));
color.i[i] = MIN2(color.i[i], (1 << (desc->channel[channel].size - 1)) - 1);
break;
case UTIL_FORMAT_TYPE_UNSIGNED:
color.ui[i] = MIN2(color.ui[i], BITFIELD_MASK(desc->channel[channel].size));
break;
}
}
/* For solid-fill blits, the hw isn't going to convert from /* For solid-fill blits, the hw isn't going to convert from
* linear to srgb for us: * linear to srgb for us:
*/ */
@ -865,8 +883,6 @@ convert_color(enum pipe_format format, union pipe_color_union *pcolor)
color.f[i] = CLAMP(color.f[i], -1.0f, 1.0f); color.f[i] = CLAMP(color.f[i], -1.0f, 1.0f);
} }
/* Note that float_to_ubyte() already clamps, for the unorm case */
return color; return color;
} }