[Mesa-dev] [PATCH 3/3] i965: Support direct upload into texture arrays

Chris Wilson chris at chris-wilson.co.uk
Wed Oct 18 11:11:14 UTC 2017


Iterate the tiled_memcpy for each face so that we can quickly do
synchronous uploads into cube maps etc.

Cc: Matt Turner <mattst88 at gmail.com>
Cc: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/intel_tex_image.c | 60 +++++++++++++++++------------
 1 file changed, 36 insertions(+), 24 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 57f2de1bc7..722f0f8f2b 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -198,8 +198,6 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
     * we need tests.
     */
    if (!devinfo->has_llc ||
-       !(texImage->TexObject->Target == GL_TEXTURE_2D ||
-         texImage->TexObject->Target == GL_TEXTURE_RECTANGLE) ||
        pixels == NULL ||
        _mesa_is_bufferobj(packing->BufferObj) ||
        packing->SwapBytes ||
@@ -219,10 +217,6 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
    if (mem_copy == NULL)
       return false;
 
-   /* If this is a nontrivial texture view, let another path handle it instead. */
-   if (texImage->TexObject->MinLayer)
-      return false;
-
    if (!image->mt ||
        (image->mt->surf.tiling != ISL_TILING_X &&
         image->mt->surf.tiling != ISL_TILING_Y0)) {
@@ -247,9 +241,6 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
    assert(image->mt->surf.logical_level0_px.depth == 1);
    assert(image->mt->surf.logical_level0_px.array_len == 1);
 
-   int level = texImage->Level + texImage->TexObject->MinLevel;
-   intel_miptree_access_raw(brw, image->mt, level, 0, true);
-
    struct brw_bo *bo = image->mt->bo;
 
    if (brw_batch_references(&brw->batch, bo)) {
@@ -276,26 +267,47 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
        packing->Alignment, packing->RowLength, packing->SkipPixels,
        packing->SkipRows);
 
-   /* Adjust x and y offset based on miplevel */
-   unsigned level_x, level_y;
-   intel_miptree_get_image_offset(image->mt, level, 0, &level_x, &level_y);
-   xoffset += level_x;
-   yoffset += level_y;
+   int image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight;
+   if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) {
+      assert(depth == 1);
+      assert(zoffset == 0);
+      depth = height;
+      height = 1;
+      image_height = 1;
+      zoffset = yoffset;
+      yoffset = 0;
+   }
 
    pixels = _mesa_image_address(dims, packing, pixels, width, height,
 				format, type, 0, 0, 0);
    uint32_t cpp = _mesa_get_format_bytes(texImage->TexFormat);
 
-   linear_to_tiled(
-      xoffset * cpp, (xoffset + width) * cpp,
-      yoffset, yoffset + height,
-      map,
-      pixels - (ptrdiff_t) yoffset * src_pitch - (ptrdiff_t) xoffset * cpp,
-      image->mt->surf.row_pitch, src_pitch,
-      brw->has_swizzling,
-      image->mt->surf.tiling,
-      mem_copy
-   );
+   int level = texImage->Level + texImage->TexObject->MinLevel;
+   int slice = texImage->Face + texImage->TexObject->MinLayer + zoffset;
+
+   for (zoffset = 0; depth--; zoffset++) {
+      intel_miptree_access_raw(brw, image->mt, level, slice + zoffset, true);
+
+      /* Adjust x and y offset based on miplevel */
+      unsigned level_x, level_y;
+      intel_miptree_get_image_offset(image->mt, level, slice + zoffset,
+				     &level_x, &level_y);
+      level_x += xoffset;
+      level_y += yoffset;
+
+      linear_to_tiled(
+         level_x * cpp, (level_x + width) * cpp,
+         level_y, level_y + height,
+         map,
+         pixels - (ptrdiff_t) level_y * src_pitch - (ptrdiff_t) level_x * cpp,
+         image->mt->surf.row_pitch, src_pitch,
+         brw->has_swizzling,
+         image->mt->surf.tiling,
+         mem_copy
+      );
+
+      pixels += image_height * src_pitch;
+   }
 
    brw_bo_unmap(bo);
    return true;
-- 
2.15.0.rc1



More information about the mesa-dev mailing list