}
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 source_stride,
const uint8_t *pixels,
uint8_t *ldest)
{
int block_pitch = ALIGN(width, 16) >> 4;
/* 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)) {
+ 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];
}
}
}
-
-
-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;
-}
-
-#if 0
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-#define TW 1920
-#define TH 1080
-void
-main()
-{
- panfrost_generate_space_filler_indices();
-
- uint8_t in[TW * TH * 4];
-
- for (int i = 0; i < TW * TH * 4; ++i) in[i] = i;
-
- uint8_t *out = malloc(TW * TH * 4 * 2);
-
- for (int i = 0; i < 60; ++i) {
- //swizzle_bpp4_align16(TW, TH, TW*4, TW>>4, (uint32_t *) in, (uint32_t *) out);
- //panfrost_texture_swizzle_bpp4(TW, TH, TW*4, (uint32_t *) in, (uint32_t *) out);
- //panfrost_texture_swizzle(TW, TH, 4, TW*4, (uint32_t *) in, (uint32_t *) out);
-
- int block_pitch = ALIGN(TW, 16) >> 4;
- swizzle_bpp1_align16(TW, TH, TW, (block_pitch * 256 >> 4), in, (uint8_t *) out);
- }
-
-#if 0
- uint8_t *reference = malloc(TW * TH * 4 * 2);
- panfrost_texture_swizzle(TW, TH, 1, TW, (uint8_t *) in, (uint8_t *) reference);
-
- if (memcmp(reference, out, TW * TH * 4)) printf("XXX\n");
-
-#endif
- printf("ref %X\n", out[0]);
-}
-#endif