[Mesa-dev] [PATCH 4/4] i965: Support packing for intel_tiled_memcpy paths

Chris Wilson chris at chris-wilson.co.uk
Fri May 25 23:33:59 UTC 2018


intel_tiled_memcpy is not restricted to using the same pitch on both the
src/dst buffers, nor requires row alignment on the user buffer. To
support arbitrary using packing modes, all we need to do is use the core
functions to compute the pixel locations.
---
 src/mesa/drivers/dri/i965/intel_pixel_read.c |  6 ++----
 src/mesa/drivers/dri/i965/intel_tex_image.c  | 17 +++++++----------
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_pixel_read.c b/src/mesa/drivers/dri/i965/intel_pixel_read.c
index 57df1178417..e697f63d973 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel_read.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel_read.c
@@ -93,10 +93,6 @@ intel_readpixels_tiled_memcpy(struct gl_context * ctx,
     */
    if (pixels == NULL ||
        _mesa_is_bufferobj(pack->BufferObj) ||
-       pack->Alignment > 4 ||
-       pack->SkipPixels > 0 ||
-       pack->SkipRows > 0 ||
-       (pack->RowLength != 0 && pack->RowLength != width) ||
        pack->SwapBytes ||
        pack->LsbFirst ||
        pack->Invert)
@@ -160,6 +156,8 @@ intel_readpixels_tiled_memcpy(struct gl_context * ctx,
    xoffset += slice_offset_x;
    yoffset += slice_offset_y;
 
+   pixels = _mesa_image_address(2, pack, pixels, width, height,
+                                format, type, 0, 0, 0);
    dst_pitch = _mesa_image_row_stride(pack, width, format, type);
 
    /* For a window-system renderbuffer, the buffer is actually flipped
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 5afc8d99462..ebfd6fdd7d4 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -200,10 +200,6 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
          texImage->TexObject->Target == GL_TEXTURE_RECTANGLE) ||
        pixels == NULL ||
        _mesa_is_bufferobj(packing->BufferObj) ||
-       packing->Alignment > 4 ||
-       packing->SkipPixels > 0 ||
-       packing->SkipRows > 0 ||
-       (packing->RowLength != 0 && packing->RowLength != width) ||
        packing->SwapBytes ||
        packing->LsbFirst ||
        packing->Invert)
@@ -244,14 +240,13 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
    if (devinfo->gen < 5 && brw->has_swizzling)
       return false;
 
-   int level = texImage->Level + texImage->TexObject->MinLevel;
-
    /* Since we are going to write raw data to the miptree, we need to resolve
     * any pending fast color clears before we start.
     */
    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;
@@ -286,6 +281,8 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
    xoffset += level_x;
    yoffset += level_y;
 
+   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(
@@ -704,10 +701,6 @@ intel_gettexsubimage_tiled_memcpy(struct gl_context *ctx,
          texImage->TexObject->Target == GL_TEXTURE_RECTANGLE) ||
        pixels == NULL ||
        _mesa_is_bufferobj(packing->BufferObj) ||
-       packing->Alignment > 4 ||
-       packing->SkipPixels > 0 ||
-       packing->SkipRows > 0 ||
-       (packing->RowLength != 0 && packing->RowLength != width) ||
        packing->SwapBytes ||
        packing->LsbFirst ||
        packing->Invert)
@@ -780,6 +773,10 @@ intel_gettexsubimage_tiled_memcpy(struct gl_context *ctx,
    xoffset += level_x;
    yoffset += level_y;
 
+   int dims = _mesa_get_texture_dimensions(texImage->TexObject->Target);
+   pixels = _mesa_image_address(dims, packing, pixels, width, height,
+                                format, type, 0, 0, 0);
+
    uint32_t cpp = _mesa_get_format_bytes(texImage->TexFormat);
    tiled_to_linear(
       xoffset * cpp, (xoffset + width) * cpp,
-- 
2.17.0



More information about the mesa-dev mailing list