st/mesa: avoid integer overflows with buffers >= 512MB
authorIlia Mirkin <imirkin@alum.mit.edu>
Tue, 15 Sep 2015 23:32:10 +0000 (19:32 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Wed, 16 Sep 2015 16:51:58 +0000 (12:51 -0400)
This fixes failures with the newly-submitted max-size texture buffer
piglit test for GPUs exposing >= 128M max texels.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.6 11.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Glenn Kennard <glenn.kennard@gmail.com>
src/mesa/state_tracker/st_atom_texture.c

index 31e0f6ba06cb8acbb8485d30f2259ea16b764f72..3e3775200a8cf040ecb96c3621c73a439a82569d 100644 (file)
@@ -274,8 +274,8 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
          return NULL;
       size = MIN2(stObj->pt->width0 - base, (unsigned)stObj->base.BufferSize);
 
-      f = ((base * 8) / desc->block.bits) * desc->block.width;
-      n = ((size * 8) / desc->block.bits) * desc->block.width;
+      f = (base / (desc->block.bits / 8)) * desc->block.width;
+      n = (size / (desc->block.bits / 8)) * desc->block.width;
       if (!n)
          return NULL;
       templ.u.buf.first_element = f;