Mesa (master): intel: Move more of the PBO blit upload logic into that function.

Eric Anholt anholt at kemper.freedesktop.org
Thu Sep 22 18:48:03 UTC 2011


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

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 21 09:32:57 2011 -0700

intel: Move more of the PBO blit upload logic into that function.

This also improves the debugging output in the failure paths so you
get more than just "failed", and don't get spammed with "failed" when
you didn't even have a PBO to try.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/drivers/dri/intel/intel_tex_image.c |   59 ++++++++++++++-----------
 1 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 6db27bc..9a12495 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -156,26 +156,43 @@ check_pbo_format(GLint internalFormat,
 
 /* XXX: Do this for TexSubImage also:
  */
-static GLboolean
+static bool
 try_pbo_upload(struct intel_context *intel,
                struct intel_texture_image *intelImage,
                const struct gl_pixelstore_attrib *unpack,
+	       GLenum format, GLenum type,
                GLint width, GLint height, const void *pixels)
 {
    struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
    GLuint src_offset, src_stride;
    GLuint dst_x, dst_y, dst_stride;
-   drm_intel_bo *dst_buffer = intel_region_buffer(intel,
-						  intelImage->mt->region,
-						  INTEL_WRITE_FULL);
+   drm_intel_bo *dst_buffer, *src_buffer;
+
+   if (!_mesa_is_bufferobj(unpack->BufferObj))
+      return false;
+
+   DBG("trying pbo upload\n");
 
-   if (!_mesa_is_bufferobj(unpack->BufferObj) ||
-       intel->ctx._ImageTransferState ||
+   if (!intelImage->mt) {
+      DBG("%s: no miptree\n", __FUNCTION__);
+      return false;
+   }
+
+   if (intel->ctx._ImageTransferState ||
        unpack->SkipPixels || unpack->SkipRows) {
-      DBG("%s: failure 1\n", __FUNCTION__);
-      return GL_FALSE;
+      DBG("%s: image transfer\n", __FUNCTION__);
+      return false;
    }
 
+   if (!check_pbo_format(intelImage->base.Base.InternalFormat, format,
+			 type, intelImage->base.Base.TexFormat)) {
+      DBG("%s: format mismatch (upload to %s with format 0x%x, type 0x%x)\n",
+	  __FUNCTION__, _mesa_get_format_name(intelImage->base.Base.TexFormat),
+	  format, type);
+      return false;
+   }
+
+   dst_buffer = intel_region_buffer(intel, intelImage->mt->region, INTEL_WRITE_FULL);
    /* note: potential 64-bit ptr to 32-bit int cast */
    src_offset = (GLuint) (unsigned long) pixels;
 
@@ -206,11 +223,13 @@ try_pbo_upload(struct intel_context *intel,
 			     intelImage->mt->region->tiling,
 			     0, 0, dst_x, dst_y, width, height,
 			     GL_COPY)) {
-	 return GL_FALSE;
+	 DBG("%s: blit failed\n", __FUNCTION__);
+	 return false;
       }
    }
 
-   return GL_TRUE;
+   DBG("%s: success\n", __FUNCTION__);
+   return true;
 }
 
 /**
@@ -398,24 +417,12 @@ intelTexImage(struct gl_context * ctx,
       }
    }
 
-   /* PBO fastpaths:
+   /* Attempt to use the blitter for PBO image uploads.
     */
    if (dims <= 2 &&
-       intelImage->mt &&
-       _mesa_is_bufferobj(unpack->BufferObj) &&
-       check_pbo_format(internalFormat, format,
-                        type, intelImage->base.Base.TexFormat)) {
-
-      DBG("trying pbo upload\n");
-
-      /* Otherwise, attempt to use the blitter for PBO image uploads.
-       */
-      if (try_pbo_upload(intel, intelImage, unpack, width, height, pixels)) {
-         DBG("pbo upload succeeded\n");
-         return;
-      }
-
-      DBG("pbo upload failed\n");
+       try_pbo_upload(intel, intelImage, unpack, format, type,
+		      width, height, pixels)) {
+      return;
    }
 
    /* intelCopyTexImage calls this function with pixels == NULL, with




More information about the mesa-commit mailing list