st/mesa: avoid integer overflows with buffers >= 512MB

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>
This commit is contained in:
Ilia Mirkin 2015-09-15 19:32:10 -04:00
parent 1aff899a87
commit eb081681df

View 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;