radeonsi: fix divide by zero in si_get_small_prim_cull_info()

This fixes a crash on startup with the game
"Ty the Tasmanian Tiger 3"

Fixes: f8a0aa6852 ("radeonsi: fix view culling for wide lines")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26661>
This commit is contained in:
Timothy Arceri 2023-12-13 16:48:01 +11:00 committed by Marge Bot
parent d376d8c5ea
commit bed1b8b90d

View file

@ -33,8 +33,14 @@ static void si_get_small_prim_cull_info(struct si_context *sctx, struct si_small
line_width = roundf(line_width);
line_width = MAX2(line_width, 1);
info.clip_half_line_width[0] = line_width * 0.5 / fabs(info.scale[0]);
info.clip_half_line_width[1] = line_width * 0.5 / fabs(info.scale[1]);
float half_line_width = line_width * 0.5;
if (info.scale[0] == 0 || info.scale[1] == 0) {
info.clip_half_line_width[0] = 0;
info.clip_half_line_width[1] = 0;
} else {
info.clip_half_line_width[0] = half_line_width / fabs(info.scale[0]);
info.clip_half_line_width[1] = half_line_width / fabs(info.scale[1]);
}
/* If the Y axis is inverted (OpenGL default framebuffer), reverse it.
* This is because the viewport transformation inverts the clip space