i965/draw: Properly handle rounding when dividing by InstanceDivisor
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 18 May 2016 20:05:48 +0000 (13:05 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 24 May 2016 02:12:34 +0000 (19:12 -0700)
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: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_draw_upload.c

index 6d9e65e9cfa9af8e063a9949d26463a7d9e90c7e..b651fd202cde80e8e6680bb14fb58f076b76713b 100644 (file)
@@ -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 {