[Mesa-dev,1/3] i965: Use try_pbo_upload for glTexSubImage* as well

Submitted by Neil Roberts on Dec. 22, 2014, 11:08 p.m.

Details

Message ID 1419289730-20554-2-git-send-email-neil@linux.intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Neil Roberts Dec. 22, 2014, 11:08 p.m.
There is an existing function to attempt to upload texture data from a PBO via
the blit pipeline called try_pbo_upload. However it was only used for the
glTexImage* functions. This patches renames it to intel_try_pbo_upload and
adds parameters to specify the x/y offsets and size and makes intelTexSubImage
use it as well.
---
 src/mesa/drivers/dri/i965/intel_tex.h          |  9 +++++++
 src/mesa/drivers/dri/i965/intel_tex_image.c    | 35 +++++++++++++++-----------
 src/mesa/drivers/dri/i965/intel_tex_subimage.c | 11 ++++++++
 3 files changed, 41 insertions(+), 14 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/dri/i965/intel_tex.h b/src/mesa/drivers/dri/i965/intel_tex.h
index 27f7f11..dfe1b03 100644
--- a/src/mesa/drivers/dri/i965/intel_tex.h
+++ b/src/mesa/drivers/dri/i965/intel_tex.h
@@ -68,4 +68,13 @@  intel_texsubimage_tiled_memcpy(struct gl_context *ctx,
                                const struct gl_pixelstore_attrib *packing,
                                bool for_glTexImage);
 
+bool
+intel_try_pbo_upload(struct gl_context *ctx,
+                     struct gl_texture_image *image,
+                     GLint xoffset, GLint yoffset,
+                     GLsizei width, GLsizei height,
+                     const struct gl_pixelstore_attrib *unpack,
+                     GLenum format, GLenum type, const void *pixels,
+                     bool for_glTexImage);
+
 #endif
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 3317779..52ee97e 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -85,13 +85,14 @@  intel_miptree_create_for_teximage(struct brw_context *brw,
                                false);
 }
 
-/* XXX: Do this for TexSubImage also:
- */
-static bool
-try_pbo_upload(struct gl_context *ctx,
-               struct gl_texture_image *image,
-               const struct gl_pixelstore_attrib *unpack,
-	       GLenum format, GLenum type, const void *pixels)
+bool
+intel_try_pbo_upload(struct gl_context *ctx,
+                     struct gl_texture_image *image,
+                     GLint xoffset, GLint yoffset,
+                     GLsizei width, GLsizei height,
+                     const struct gl_pixelstore_attrib *unpack,
+                     GLenum format, GLenum type, const void *pixels,
+                     bool for_glTexImage)
 {
    struct intel_texture_image *intelImage = intel_texture_image(image);
    struct brw_context *brw = brw_context(ctx);
@@ -109,7 +110,8 @@  try_pbo_upload(struct gl_context *ctx,
       return false;
    }
 
-   ctx->Driver.AllocTextureImageBuffer(ctx, image);
+   if (for_glTexImage)
+      ctx->Driver.AllocTextureImageBuffer(ctx, image);
 
    if (!intelImage->mt) {
       DBG("%s: no miptree\n", __FUNCTION__);
@@ -131,19 +133,19 @@  try_pbo_upload(struct gl_context *ctx,
    }
 
    int src_stride =
-      _mesa_image_row_stride(unpack, image->Width, format, type);
+      _mesa_image_row_stride(unpack, width, format, type);
 
    /* note: potential 64-bit ptr to 32-bit int cast */
    src_offset = (GLuint) (unsigned long) pixels;
    src_buffer = intel_bufferobj_buffer(brw, pbo,
-                                       src_offset, src_stride * image->Height);
+                                       src_offset, src_stride * height);
 
    struct intel_mipmap_tree *pbo_mt =
       intel_miptree_create_for_bo(brw,
                                   src_buffer,
                                   intelImage->mt->format,
                                   src_offset,
-                                  image->Width, image->Height,
+                                  width, height,
                                   src_stride);
    if (!pbo_mt)
       return false;
@@ -152,8 +154,8 @@  try_pbo_upload(struct gl_context *ctx,
                            pbo_mt, 0, 0,
                            0, 0, false,
                            intelImage->mt, image->Level, image->Face,
-                           0, 0, false,
-                           image->Width, image->Height, GL_COPY)) {
+                           xoffset, yoffset, false,
+                           width, height, GL_COPY)) {
       DBG("%s: blit failed\n", __FUNCTION__);
       intel_miptree_release(&pbo_mt);
       return false;
@@ -193,7 +195,12 @@  intelTexImage(struct gl_context * ctx,
    /* Attempt to use the blitter for PBO image uploads.
     */
    if (dims <= 2 &&
-       try_pbo_upload(ctx, texImage, unpack, format, type, pixels)) {
+       intel_try_pbo_upload(ctx, texImage,
+                            0, 0, /* x,y offsets */
+                            texImage->Width,
+                            texImage->Height,
+                            unpack, format, type, pixels,
+                            true /*for_glTexImage*/)) {
       return;
    }
 
diff --git a/src/mesa/drivers/dri/i965/intel_tex_subimage.c b/src/mesa/drivers/dri/i965/intel_tex_subimage.c
index cb5738a..dde1591 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_subimage.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_subimage.c
@@ -691,6 +691,17 @@  intelTexSubImage(struct gl_context * ctx,
    if (ok)
      return;
 
+   /* Attempt to use the blitter for PBO image uploads.
+    */
+   if (dims <= 2 &&
+       intel_try_pbo_upload(ctx, texImage,
+                            xoffset, yoffset,
+                            width, height,
+                            packing, format, type, pixels,
+                            false /*for_glTexImage*/)) {
+      return;
+   }
+
    /* The intel_blit_texsubimage() function only handles 2D images */
    if (dims != 2 || !intel_blit_texsubimage(ctx, texImage,
 			       xoffset, yoffset,