diff options
author | Ardinartsev Nikita <[email protected]> | 2016-05-17 02:27:22 +0300 |
---|---|---|
committer | Matt Turner <[email protected]> | 2016-05-18 11:09:37 -0700 |
commit | 2a8aa1e3deb99a1ae16d942318da648c1327ece5 (patch) | |
tree | 6d55238fbe5fb1b44e656fcf39a832abbd3fe487 /src/mesa | |
parent | caab3cd5361d8848e8f8957f697aff7bca5fc6b3 (diff) |
i965/urb: fixes division by zero
Fixes regression introduced by af5ca43f2676bff7499f93277f908b681cb821d0
Reviewed-by: Matt Turner <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95419
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/gen7_urb.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/mesa/drivers/dri/i965/gen7_urb.c b/src/mesa/drivers/dri/i965/gen7_urb.c index a412a4263b3..6d9aa028e95 100644 --- a/src/mesa/drivers/dri/i965/gen7_urb.c +++ b/src/mesa/drivers/dri/i965/gen7_urb.c @@ -292,25 +292,11 @@ gen7_upload_urb(struct brw_context *brw) if (remaining_space > total_wants) remaining_space = total_wants; if (remaining_space > 0) { - unsigned vs_additional = (unsigned) - roundf(vs_wants * (((float) remaining_space) / total_wants)); - vs_chunks += vs_additional; - 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; - - gs_chunks += remaining_space; + float ratio = ((float) remaining_space) / total_wants; + vs_chunks += lroundf(vs_wants * ratio); + hs_chunks += lroundf(hs_wants * ratio); + ds_chunks += lroundf(ds_wants * ratio); + gs_chunks += lroundf(gs_wants * ratio); } /* Sanity check that we haven't over-allocated. */ |