Module: Mesa Branch: main Commit: bed1b8b90d844d8bf36d3d1aa7c3f83e086d9cf6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bed1b8b90d844d8bf36d3d1aa7c3f83e086d9cf6
Author: Timothy Arceri <tarc...@itsqueeze.com> Date: Wed Dec 13 16:48:01 2023 +1100 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: f8a0aa685275 ("radeonsi: fix view culling for wide lines") Reviewed-by: Marek Olšák <marek.ol...@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26661> --- src/gallium/drivers/radeonsi/si_state_viewport.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state_viewport.c b/src/gallium/drivers/radeonsi/si_state_viewport.c index e2de5ffe2f0..47135621233 100644 --- a/src/gallium/drivers/radeonsi/si_state_viewport.c +++ b/src/gallium/drivers/radeonsi/si_state_viewport.c @@ -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