llvmpipe: Bump the maximum texture size (in pixels).
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 6 Jul 2012 18:14:37 +0000 (19:14 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 28 Aug 2012 14:18:43 +0000 (15:18 +0100)
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@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/llvmpipe/lp_limits.h
src/gallium/drivers/llvmpipe/lp_texture.c

index 43b00c56a5feddbeef3eeb8925e8f01db69f6045..fac34044089b1fe16f703ff3b7da7f96ac7d013e 100644 (file)
@@ -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 */
index 4495e8de6cd07fef6564c8ddcb4670f765d8d949..36041432312ba20ad0aff5e6cf996c696f1ccfe5 100644 (file)
@@ -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);