llvmpipe: added llvmpipe_resource_size()
authorBrian Paul <brianp@vmware.com>
Tue, 27 Apr 2010 17:32:25 +0000 (11:32 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 27 Apr 2010 17:32:25 +0000 (11:32 -0600)
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/llvmpipe/lp_texture.h

index 29bdfe36ae63cd5d0b86fdf347c08abf961d7153..9d10a9f2d387c3e625b507156fcaa50a3134f887 100644 (file)
@@ -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)
 {
index 7d0ae263e51f5055995a0344fccf8ca7305b0ac6..a8d08d6247f0011aa587bde030d3cc8eeeec0f27 100644 (file)
@@ -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,