i965: Avoid division by zero.
authorArdinartsev Nikita <ardinar23@gmail.com>
Thu, 23 Jun 2016 01:28:11 +0000 (18:28 -0700)
committerMatt Turner <mattst88@gmail.com>
Thu, 23 Jun 2016 17:08:58 +0000 (10:08 -0700)
Fixes regression introduced by af5ca43f2676bff7499f93277f908b681cb821d0

Cc: "12.0 11.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95419

src/mesa/drivers/dri/i965/gen7_urb.c

index 387ed2e8923e4e7afb7d95fb7c6af0d009d135d8..797d1b675b6515a14a9ff73349e52bbbcd43bb4f 100644 (file)
@@ -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;
    }