Mesa (master): softpipe: use 64-bit arithmetic in softpipe_resource_layout ()

Brian Paul brianp at kemper.freedesktop.org
Mon Mar 3 17:45:35 UTC 2014


Module: Mesa
Branch: master
Commit: 465b2c42bca59f0f198aeb8543cfabd5989584b4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=465b2c42bca59f0f198aeb8543cfabd5989584b4

Author: Brian Paul <brianp at vmware.com>
Date:   Sat Mar  1 12:14:15 2014 -0700

softpipe: use 64-bit arithmetic in softpipe_resource_layout()

To avoid 32-bit integer overflow for large textures.  Note: we're
already doing this in llvmpipe.

Cc: "10.0" "10.1" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Roland Scheidegger <sroland at vmware.com>

---

 src/gallium/drivers/softpipe/sp_texture.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index dc89d06..6538e46 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -60,7 +60,7 @@ softpipe_resource_layout(struct pipe_screen *screen,
    unsigned width = pt->width0;
    unsigned height = pt->height0;
    unsigned depth = pt->depth0;
-   unsigned buffer_size = 0;
+   uint64_t buffer_size = 0;
 
    for (level = 0; level <= pt->last_level; level++) {
       unsigned slices;
@@ -76,8 +76,8 @@ softpipe_resource_layout(struct pipe_screen *screen,
 
       spr->level_offset[level] = buffer_size;
 
-      buffer_size += (util_format_get_nblocksy(pt->format, height) *
-                      slices * spr->stride[level]);
+      buffer_size += (uint64_t) util_format_get_nblocksy(pt->format, height) *
+                     slices * spr->stride[level];
 
       width  = u_minify(width, 1);
       height = u_minify(height, 1);




More information about the mesa-commit mailing list