From a51b81558f5cbe477ceb93d687a356f945f220af Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 4 Mar 2013 14:38:20 -0700 Subject: llvmpipe: add some scene limit sanity check assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: This is a candidate for the stable branches. Reviewed-by: José Fonseca --- src/gallium/drivers/llvmpipe/lp_scene.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index fec2f7460b..dd0943e9b3 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; } -- cgit v1.2.3