[Mesa-stable] [PATCH 07/13] i965/draw: Properly handle rounding when dividing by InstanceDivisor

Jason Ekstrand jason at jlekstrand.net
Thu May 19 07:21:04 UTC 2016


The old code always divided rounded down and then subtracted 1.  What we
wanted was to divide rounded up and then subtract 1 which is equivalent to
subtracting 1 and then dividing rounded down.

Cc: "10.2" <mesa-stable at lists.freedesktop.org>
---
 src/mesa/drivers/dri/i965/brw_draw_upload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 6d9e65e..b651fd2 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -474,8 +474,8 @@ brw_prepare_vertices(struct brw_context *brw)
          if (glarray->InstanceDivisor) {
             if (brw->num_instances) {
                start = offset + glarray->StrideB * brw->baseinstance;
-               range = (glarray->StrideB * ((brw->num_instances /
-                                             glarray->InstanceDivisor) - 1) +
+               range = (glarray->StrideB * ((brw->num_instances - 1) /
+                                            glarray->InstanceDivisor) +
                         glarray->_ElementSize);
             }
          } else {
-- 
2.5.0.400.gff86faf



More information about the mesa-stable mailing list