summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2013-03-04 14:38:20 -0700
committerAndreas Boll <andreas.boll.dev@gmail.com>2013-04-17 12:52:17 +0200
commit6800f17777c9b91119a26b78462ee62f44008500 (patch)
treec171ab129fdc1d750c8e11a5530170c5c6ff4773
parenta843ae5e3935a0df56f9ff78df0c66ff38246716 (diff)
llvmpipe: add some scene limit sanity check assertions
Note: This is a candidate for the stable branches. Reviewed-by: José Fonseca <jfonseca@vmware.com> (cherry picked from commit a51b81558f5cbe477ceb93d687a356f945f220af)
-rw-r--r--src/gallium/drivers/llvmpipe/lp_scene.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c
index ed998246fb..ae878cce7e 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.c
+++ b/src/gallium/drivers/llvmpipe/lp_scene.c
@@ -64,6 +64,28 @@ lp_scene_create( struct pipe_context *pipe )
pipe_mutex_init(scene->mutex);
+#ifdef DEBUG
+ /* Do some scene limit sanity checks here */
+ {
+ size_t maxBins = TILES_X * TILES_Y;
+ size_t maxCommandBytes = sizeof(struct cmd_block) * maxBins;
+ size_t maxCommandPlusData = maxCommandBytes + DATA_BLOCK_SIZE;
+ /* We'll need at least one command block per bin. Make sure that's
+ * less than the max allowed scene size.
+ */
+ assert(maxCommandBytes < LP_SCENE_MAX_SIZE);
+ /* We'll also need space for at least one other data block */
+ assert(maxCommandPlusData <= LP_SCENE_MAX_SIZE);
+
+ /* Ideally, the size of a cmd_block object will be a power of two
+ * in order to avoid wasting space when we allocation them from
+ * data blocks (which are power of two also).
+ */
+ assert(sizeof(struct cmd_block) ==
+ util_next_power_of_two(sizeof(struct cmd_block)));
+ }
+#endif
+
return scene;
}