[Mesa-dev] [PATCH 04/17] swrast: Clean up and explain the mapping process.

Eric Anholt eric at anholt.net
Mon Apr 22 09:14:45 PDT 2013


---
 src/mesa/swrast/s_texture.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 36a90dd..b6dd8cb 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -218,18 +218,17 @@ _swrast_map_teximage(struct gl_context *ctx,
    map = swImage->Buffer;
 
    assert(slice < texture_slices(texImage));
+   if (slice != 0) {
+      int sliceHeight = texImage->Height;
+      /* 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)
+         sliceHeight = 1;
 
-   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) {
-      GLuint sliceSize = _mesa_format_image_size(texImage->TexFormat,
-                                                 texImage->Width,
-                                                 1,
+                                                 sliceHeight,
                                                  1);
       map += slice * sliceSize;
    }
-- 
1.7.10.4



More information about the mesa-dev mailing list