Mesa (master): st: make loops over 3D texture slices a litte more intuitive

Brian Paul brianp at kemper.freedesktop.org
Thu Apr 9 14:03:03 PDT 2009


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

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Apr  9 14:32:42 2009 -0600

st: make loops over 3D texture slices a litte more intuitive

---

 src/mesa/state_tracker/st_cb_texture.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 942f4a5..405af02 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -568,7 +568,7 @@ st_TexImage(GLcontext * ctx,
       GLint i;
       const GLubyte *src = (const GLubyte *) pixels;
 
-      for (i = 0; i++ < depth;) {
+      for (i = 0; i < depth; i++) {
 	 if (!texImage->TexFormat->StoreImage(ctx, dims, 
 					      texImage->_BaseFormat, 
 					      texImage->TexFormat, 
@@ -581,9 +581,11 @@ st_TexImage(GLcontext * ctx,
 	    _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
 	 }
 
-	 if (stImage->pt && i < depth) {
+	 if (stImage->pt && i + 1 < depth) {
+            /* unmap this slice */
 	    st_texture_image_unmap(ctx->st, stImage);
-	    texImage->Data = st_texture_image_map(ctx->st, stImage, i,
+            /* map next slice of 3D texture */
+	    texImage->Data = st_texture_image_map(ctx->st, stImage, i + 1,
                                                   PIPE_TRANSFER_WRITE, 0, 0,
                                                   stImage->base.Width,
                                                   stImage->base.Height);
@@ -711,7 +713,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
 
    dest = (GLubyte *) pixels;
 
-   for (i = 0; i++ < depth;) {
+   for (i = 0; i < depth; i++) {
       if (compressed) {
 	 _mesa_get_compressed_teximage(ctx, target, level, dest,
 				       texObj, texImage);
@@ -721,9 +723,11 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
 			    texObj, texImage);
       }
 
-      if (stImage->pt && i < depth) {
+      if (stImage->pt && i + 1 < depth) {
+         /* unmap this slice */
 	 st_texture_image_unmap(ctx->st, stImage);
-	 texImage->Data = st_texture_image_map(ctx->st, stImage, i,
+         /* map next slice of 3D texture */
+	 texImage->Data = st_texture_image_map(ctx->st, stImage, i + 1,
                                                PIPE_TRANSFER_READ, 0, 0,
                                                stImage->base.Width,
                                                stImage->base.Height);
@@ -808,7 +812,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
    src = (const GLubyte *) pixels;
    dstRowStride = stImage->transfer->stride;
 
-   for (i = 0; i++ < depth;) {
+   for (i = 0; i < depth; i++) {
       if (!texImage->TexFormat->StoreImage(ctx, dims, texImage->_BaseFormat,
 					   texImage->TexFormat,
 					   texImage->Data,
@@ -820,10 +824,12 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
 	 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
       }
 
-      if (stImage->pt && i < depth) {
-         /* map next slice of 3D texture */
+      if (stImage->pt && i + 1 < depth) {
+         /* unmap this slice */
 	 st_texture_image_unmap(ctx->st, stImage);
-	 texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset + i,
+         /* map next slice of 3D texture */
+	 texImage->Data = st_texture_image_map(ctx->st, stImage,
+                                               zoffset + i + 1,
                                                PIPE_TRANSFER_WRITE,
                                                xoffset, yoffset,
                                                width, height);



More information about the mesa-commit mailing list