Module: Mesa Branch: staging/23.3 Commit: bc0c064b87c874ef088976c77467aec2964e7507 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc0c064b87c874ef088976c77467aec2964e7507
Author: Timothy Arceri <[email protected]> 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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26661> (cherry picked from commit bed1b8b90d844d8bf36d3d1aa7c3f83e086d9cf6) --- .pick_status.json | 2 +- src/gallium/drivers/radeonsi/si_state_viewport.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 75d03785936..3fa19057d50 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -324,7 +324,7 @@ "description": "radeonsi: fix divide by zero in si_get_small_prim_cull_info()", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "f8a0aa6852756d8f1593ef6627ddb1754ae967be", "notes": null diff --git a/src/gallium/drivers/radeonsi/si_state_viewport.c b/src/gallium/drivers/radeonsi/si_state_viewport.c index c32584bbcf5..826020491ec 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
