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

Author: Eric Anholt <e...@anholt.net>
Date:   Fri Apr 19 13:35:31 2013 -0700

swrast: Clean up and explain the mapping process.

v2: Move slice height calculation to a helper function (recommeded by Brian).

Reviewed-by: Kenneth Graunke <kenn...@whitecape.org> (v1)
Reviewed-by: Brian Paul <bri...@vmware.com>

---

 src/mesa/swrast/s_context.h |    3 +++
 src/mesa/swrast/s_texture.c |   24 ++++++++++++++----------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index cf9d5af..5d9354d 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -380,6 +380,9 @@ _swrast_map_textures(struct gl_context *ctx);
 extern void
 _swrast_unmap_textures(struct gl_context *ctx);
 
+extern unsigned int
+_swrast_teximage_slice_height(struct gl_texture_image *texImage);
+
 extern void
 _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj);
 
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 4e11b0a..82b2ce6 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -68,6 +68,18 @@ texture_slices(struct gl_texture_image *texImage)
       return texImage->Depth;
 }
 
+unsigned int
+_swrast_teximage_slice_height(struct gl_texture_image *texImage)
+{
+   /* For 1D array textures, the slices are all 1 pixel high, and Height is
+    * the number of slices.
+    */
+   if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY)
+      return 1;
+   else
+      return texImage->Height;
+}
+
 /**
  * Called via ctx->Driver.AllocTextureImageBuffer()
  */
@@ -219,18 +231,10 @@ _swrast_map_teximage(struct gl_context *ctx,
    map = swImage->Buffer;
 
    assert(slice < texture_slices(texImage));
-
-   if (texImage->TexObject->Target == GL_TEXTURE_3D ||
-       texImage->TexObject->Target == GL_TEXTURE_2D_ARRAY) {
-      GLuint sliceSize = _mesa_format_image_size(texImage->TexFormat,
-                                                 texImage->Width,
-                                                 texImage->Height,
-                                                 1);
-      map += slice * sliceSize;
-   } else if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) {
+   if (slice != 0) {
       GLuint sliceSize = _mesa_format_image_size(texImage->TexFormat,
                                                  texImage->Width,
-                                                 1,
+                                                 
_swrast_teximage_slice_height(texImage),
                                                  1);
       map += slice * sliceSize;
    }

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to