X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fpanfrost%2Fpan_swizzle.c;h=52a907ddd55d14c26f2b89d37b2c2718f2b873dc;hb=035759b61ba1778d5143cdf3a8795a62dd5d8a60;hp=0fe8b3cfa213858c68101375db0933af2ab783b4;hpb=b1213a394721cc9975d7d611e6ff95b96c0c376b;p=mesa.git diff --git a/src/gallium/drivers/panfrost/pan_swizzle.c b/src/gallium/drivers/panfrost/pan_swizzle.c index 0fe8b3cfa21..52a907ddd55 100644 --- a/src/gallium/drivers/panfrost/pan_swizzle.c +++ b/src/gallium/drivers/panfrost/pan_swizzle.c @@ -97,6 +97,9 @@ swizzle_bpp1_align16(int width, int height, int source_stride, int block_pitch, ++y; + if (y >= height) + break; + { int block_y = y & ~(0x0f); int rem_y = y & 0x0f; @@ -147,33 +150,40 @@ swizzle_bpp4_align16(int width, int height, int source_stride, int block_pitch, } void -panfrost_texture_swizzle(int width, int height, int bytes_per_pixel, int source_stride, +panfrost_texture_swizzle(unsigned off_x, + unsigned off_y, + int width, int height, int bytes_per_pixel, int dest_width, const uint8_t *pixels, uint8_t *ldest) { /* Calculate maximum size, overestimating a bit */ - int block_pitch = ALIGN(width, 16) >> 4; + int block_pitch = ALIGN(dest_width, 16) >> 4; + + /* Strides must be tight, since we're only ever called indirectly */ + int source_stride = width * bytes_per_pixel; /* Use fast path if available */ - if (bytes_per_pixel == 4 /* && (ALIGN(width, 16) == width) */) { - swizzle_bpp4_align16(width, height, source_stride >> 2, (block_pitch * 256 >> 4), (const uint32_t *) pixels, (uint32_t *) ldest); - return; - } else if (bytes_per_pixel == 1 /* && (ALIGN(width, 16) == width) */) { - swizzle_bpp1_align16(width, height, source_stride, (block_pitch * 256 >> 4), pixels, (uint8_t *) ldest); - return; + if (!(off_x || off_y) && (width == dest_width)) { + if (bytes_per_pixel == 4 /* && (ALIGN(width, 16) == width) */) { + swizzle_bpp4_align16(width, height, source_stride >> 2, (block_pitch * 256 >> 4), (const uint32_t *) pixels, (uint32_t *) ldest); + return; + } else if (bytes_per_pixel == 1 /* && (ALIGN(width, 16) == width) */) { + swizzle_bpp1_align16(width, height, source_stride, (block_pitch * 256 >> 4), pixels, (uint8_t *) ldest); + return; + } } /* Otherwise, default back on generic path */ for (int y = 0; y < height; ++y) { - int block_y = y >> 4; - int rem_y = y & 0x0F; + int block_y = (y + off_y) >> 4; + int rem_y = (y + off_y) & 0x0F; int block_start_s = block_y * block_pitch * 256; int source_start = y * source_stride; for (int x = 0; x < width; ++x) { - int block_x_s = (x >> 4) * 256; - int rem_x = x & 0x0F; + int block_x_s = ((x + off_x) >> 4) * 256; + int rem_x = (x + off_x) & 0x0F; int index = space_filler[rem_y][rem_x]; const uint8_t *source = &pixels[source_start + bytes_per_pixel * x]; @@ -184,14 +194,3 @@ panfrost_texture_swizzle(int width, int height, int bytes_per_pixel, int source_ } } } - - -unsigned -panfrost_swizzled_size(int width, int height, int bytes_per_pixel) -{ - /* Calculate maximum size, overestimating a bit */ - int block_pitch = ALIGN(width, 16) >> 4; - unsigned sz = bytes_per_pixel * 256 * ((height >> 4) + 1) * block_pitch; - - return sz; -}