radeon: add miptree offset functions
authorDave Airlie <airlied@linux.ie>
Sun, 22 Mar 2009 01:56:41 +0000 (11:56 +1000)
committerDave Airlie <airlied@linux.ie>
Sun, 22 Mar 2009 01:56:41 +0000 (11:56 +1000)
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h

index 3203ee1cba7ae434c3de7ed747818e0af4620824..228629e3c45405b7ae19e4caa9c2dc0c37f0b9cc 100644 (file)
@@ -358,3 +358,29 @@ void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
                texImage->Width, texImage->Height, texImage->Depth,
                texImage->TexFormat->TexelBytes, t->tile_bits, compressed);
 }
+
+/* Although we use the image_offset[] array to store relative offsets
+ * to cube faces, Mesa doesn't know anything about this and expects
+ * each cube face to be treated as a separate image.
+ *
+ * These functions present that view to mesa:
+ */
+const GLuint *
+radeon_miptree_depth_offsets(radeon_mipmap_tree *mt, GLuint level)
+{
+     static const GLuint zero = 0;
+     if (mt->target != GL_TEXTURE_3D || mt->faces == 1)
+       return &zero;
+     else
+       return mt->levels[level].faces[0].offset;
+}
+
+GLuint
+radeon_miptree_image_offset(radeon_mipmap_tree *mt,
+                           GLuint face, GLuint level)
+{
+   if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
+      return (mt->levels[level].faces[face].offset);
+   else
+      return mt->levels[level].faces[0].offset;
+}
index 43dfa48aa7178c7382e53ff94520ac3daf025174..d9ad5ad39a3e1d39e043fb86c3e2ea0be28ece1e 100644 (file)
@@ -92,6 +92,8 @@ GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
 GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_texture_object *texObj);
 void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
                              struct gl_texture_image *texImage, GLuint face, GLuint level);
-
-
+GLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt,
+                                  GLuint face, GLuint level);
+const GLuint *
+radeon_miptree_depth_offsets(radeon_mipmap_tree *mt, GLuint level);
 #endif /* __RADEON_MIPMAP_TREE_H_ */