Module: Mesa
Branch: master
Commit: b078a613bedb76242af177bee12520203bd63d50
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b078a613bedb76242af177bee12520203bd63d50

Author: Maciej Cencora <[email protected]>
Date:   Sat Jan  9 20:36:47 2010 +0100

radeon: add texture helper function

---

 src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c |   26 ++++++++++++++++++++++
 src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h |    3 ++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c 
b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index cd843d9..117d695 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -81,6 +81,32 @@ static unsigned get_compressed_image_size(
        return rowStride * ((height + blockHeight - 1) / blockHeight);
 }
 
+static unsigned is_pot(unsigned value)
+{
+       unsigned m;
+
+       for (m = 1; m < value; m *= 2) {}
+
+       return value == m;
+}
+
+unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format 
format, unsigned width)
+{
+       if (_mesa_is_format_compressed(format)) {
+               return get_aligned_compressed_row_stride(format, width, 
rmesa->texture_compressed_row_align);
+       } else {
+               unsigned row_align;
+
+               if (is_pot(width)) {
+                       row_align = rmesa->texture_row_align - 1;
+               } else {
+                       row_align = rmesa->texture_rect_row_align - 1;
+               }
+
+               return (_mesa_format_row_stride(format, width) + row_align) & 
~row_align;
+       }
+}
+
 /**
  * Compute sizes and fill in offset and blit information for the given
  * image (determined by \p face and \p level).
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h 
b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h
index c911688..424bf51 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h
@@ -89,4 +89,7 @@ void radeon_try_alloc_miptree(radeonContextPtr rmesa, 
radeonTexObj *t);
 GLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt,
                                   GLuint face, GLuint level);
 uint32_t get_base_teximage_offset(radeonTexObj *texObj);
+
+unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format 
format, unsigned width);
+
 #endif /* __RADEON_MIPMAP_TREE_H_ */

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to