From 1db3a55b9c59093f7bf4df39579287eeb0cf0a2b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Apr 2010 11:32:25 -0600 Subject: [PATCH] llvmpipe: added llvmpipe_resource_size() --- src/gallium/drivers/llvmpipe/lp_texture.c | 21 +++++++++++++++++++++ src/gallium/drivers/llvmpipe/lp_texture.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 29bdfe36ae6..9d10a9f2d38 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -1160,6 +1160,27 @@ llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr, } +/** + * Return size of resource in bytes + */ +unsigned +llvmpipe_resource_size(const struct pipe_resource *resource) +{ + const struct llvmpipe_resource *lpr = llvmpipe_resource_const(resource); + unsigned lvl, size = 0; + + for (lvl = 0; lvl <= lpr->base.last_level; lvl++) { + if (lpr->linear[lvl].data) + size += tex_image_size(lpr, lvl, LP_TEX_LAYOUT_LINEAR); + + if (lpr->tiled[lvl].data) + size += tex_image_size(lpr, lvl, LP_TEX_LAYOUT_TILED); + } + + return size; +} + + void llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen) { diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index 7d0ae263e51..a8d08d6247f 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -184,6 +184,10 @@ void * llvmpipe_resource_data(struct pipe_resource *resource); +unsigned +llvmpipe_resource_size(const struct pipe_resource *resource); + + ubyte * llvmpipe_get_texture_image_address(struct llvmpipe_resource *lpr, unsigned face_slice, unsigned level, -- 2.30.2