[Mesa-dev] [PATCH] i965: Avoid division by zero.
Kenneth Graunke
kenneth at whitecape.org
Thu Jun 23 04:14:31 UTC 2016
On Wednesday, June 22, 2016 7:05:04 PM PDT Matt Turner wrote:
> From: Ardinartsev Nikita <ardinar23 at gmail.com>
>
> Fixes regression introduced by af5ca43f2676bff7499f93277f908b681cb821d0
>
> Reviewed-by: Matt Turner <mattst88 at gmail.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95419
> ---
> src/mesa/drivers/dri/i965/gen7_urb.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/gen7_urb.c b/src/mesa/drivers/dri/i965/gen7_urb.c
> index 387ed2e..797d1b6 100644
> --- a/src/mesa/drivers/dri/i965/gen7_urb.c
> +++ b/src/mesa/drivers/dri/i965/gen7_urb.c
> @@ -300,17 +300,21 @@ gen7_upload_urb(struct brw_context *brw)
> remaining_space -= vs_additional;
> total_wants -= vs_wants;
>
> - unsigned hs_additional = (unsigned)
> - round(hs_wants * (((double) remaining_space) / total_wants));
> - hs_chunks += hs_additional;
> - remaining_space -= hs_additional;
> - total_wants -= hs_wants;
> -
> - unsigned ds_additional = (unsigned)
> - round(ds_wants * (((double) remaining_space) / total_wants));
> - ds_chunks += ds_additional;
> - remaining_space -= ds_additional;
> - total_wants -= ds_wants;
> + if (total_wants > 0) {
> + unsigned hs_additional = (unsigned)
> + round(hs_wants * (((double) remaining_space) / total_wants));
> + hs_chunks += hs_additional;
> + remaining_space -= hs_additional;
> + total_wants -= hs_wants;
> + }
> +
> + if (total_wants > 0) {
> + unsigned ds_additional = (unsigned)
> + round(ds_wants * (((double) remaining_space) / total_wants));
> + ds_chunks += ds_additional;
> + remaining_space -= ds_additional;
> + total_wants -= ds_wants;
> + }
>
> gs_chunks += remaining_space;
> }
>
Right, the total_wants may have been entirely VS, at which point HS and
DS won't need anything. Looks good to me!
Cc: "12.0 11.2" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160622/657628d1/attachment.sig>
More information about the mesa-dev
mailing list