Mesa (master): llvmpipe: Bump the maximum texture size (in pixels).

Jose Fonseca jrfonseca at kemper.freedesktop.org
Tue Aug 28 14:24:50 UTC 2012


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

Author: José Fonseca <jfonseca at vmware.com>
Date:   Fri Jul  6 19:14:37 2012 +0100

llvmpipe: Bump the maximum texture size (in pixels).

But cap the size in bytes, to avoid depleting the whole system memory,
with humongus textures.

Tested with max-texture-size piglit test.

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/gallium/drivers/llvmpipe/lp_limits.h  |    5 +++--
 src/gallium/drivers/llvmpipe/lp_texture.c |    6 ++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_limits.h b/src/gallium/drivers/llvmpipe/lp_limits.h
index 43b00c5..fac3404 100644
--- a/src/gallium/drivers/llvmpipe/lp_limits.h
+++ b/src/gallium/drivers/llvmpipe/lp_limits.h
@@ -43,8 +43,9 @@
 /**
  * Max texture sizes
  */
-#define LP_MAX_TEXTURE_2D_LEVELS 13  /* 4K x 4K for now */
-#define LP_MAX_TEXTURE_3D_LEVELS 10  /* 512 x 512 x 512 for now */
+#define LP_MAX_TEXTURE_SIZE (1 * 1024 * 1024 * 1024ULL)  /* 1GB for now */
+#define LP_MAX_TEXTURE_2D_LEVELS 14  /* 8K x 8K for now */
+#define LP_MAX_TEXTURE_3D_LEVELS 11  /* 1K x 1K x 1K for now */
 
 
 /** This must be the larger of LP_MAX_TEXTURE_2D/3D_LEVELS */
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 4495e8d..3604143 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -112,6 +112,7 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen,
    unsigned width = pt->width0;
    unsigned height = pt->height0;
    unsigned depth = pt->depth0;
+   size_t total_size = 0;
 
    assert(LP_MAX_TEXTURE_2D_LEVELS <= LP_MAX_TEXTURE_LEVELS);
    assert(LP_MAX_TEXTURE_3D_LEVELS <= LP_MAX_TEXTURE_LEVELS);
@@ -168,6 +169,11 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen,
          }
       }
 
+      total_size += lpr->num_slices_faces[level] * lpr->img_stride[level];
+      if (total_size > LP_MAX_TEXTURE_SIZE) {
+         goto fail;
+      }
+
       /* Compute size of next mipmap level */
       width = u_minify(width, 1);
       height = u_minify(height, 1);




More information about the mesa-commit mailing list