217
memcpy_to_tiled_x(const void *src, void *dst, int bpp, int swizzling,
218
int32_t src_stride, int32_t dst_stride,
219
int16_t src_x, int16_t src_y,
220
int16_t dst_x, int16_t dst_y,
221
uint16_t width, uint16_t height)
223
const unsigned tile_width = 512;
224
const unsigned tile_height = 8;
225
const unsigned tile_size = 4096;
227
const unsigned cpp = bpp / 8;
228
const unsigned stride_tiles = dst_stride / tile_width;
229
const unsigned swizzle_pixels = (swizzling ? 64 : tile_width) / cpp;
230
const unsigned tile_pixels = ffs(tile_width / cpp) - 1;
231
const unsigned tile_mask = (1 << tile_pixels) - 1;
235
DBG(("%s(bpp=%d, swizzling=%d): src=(%d, %d), dst=(%d, %d), size=%dx%d, pitch=%d/%d\n",
236
__FUNCTION__, bpp, swizzling, src_x, src_y, dst_x, dst_y, width, height, src_stride, dst_stride));
238
src = (const uint8_t *)src + src_y * src_stride + src_x * cpp;
240
for (y = 0; y < height; ++y) {
241
const uint32_t dy = y + dst_y;
242
const uint32_t tile_row =
243
(dy / tile_height * stride_tiles * tile_size +
244
(dy & (tile_height-1)) * tile_width);
245
const uint8_t *src_row = (const uint8_t *)src + src_stride * y;
246
uint32_t dx = dst_x, offset;
249
if (dx & (swizzle_pixels - 1)) {
250
const uint32_t swizzle_bound_pixels = ALIGN(dx + 1, swizzle_pixels);
251
const uint32_t length = min(dst_x + width, swizzle_bound_pixels) - dx;
253
(dx >> tile_pixels) * tile_size +
254
(dx & tile_mask) * cpp;
256
case I915_BIT_6_SWIZZLE_NONE:
258
case I915_BIT_6_SWIZZLE_9:
259
offset ^= (offset >> 3) & 64;
261
case I915_BIT_6_SWIZZLE_9_10:
262
offset ^= ((offset ^ (offset >> 1)) >> 3) & 64;
264
case I915_BIT_6_SWIZZLE_9_11:
265
offset ^= ((offset ^ (offset >> 2)) >> 3) & 64;
269
memcpy((char *)dst + offset, src_row, length * cpp);
271
src_row += length * cpp;
278
(dx >> tile_pixels) * tile_size +
279
(dx & tile_mask) * cpp;
281
case I915_BIT_6_SWIZZLE_9:
282
offset ^= (offset >> 3) & 64;
284
case I915_BIT_6_SWIZZLE_9_10:
285
offset ^= ((offset ^ (offset >> 1)) >> 3) & 64;
287
case I915_BIT_6_SWIZZLE_9_11:
288
offset ^= ((offset ^ (offset >> 2)) >> 3) & 64;
292
memcpy((char *)dst + offset, src_row, 64);
296
dx += swizzle_pixels;
300
assert((dx & tile_mask) == 0);
301
offset = tile_row + (dx >> tile_pixels) * tile_size;
303
memcpy((char *)dst + offset, src_row, 512);
307
dx += swizzle_pixels;
312
(dx >> tile_pixels) * tile_size +
313
(dx & tile_mask) * cpp;
315
case I915_BIT_6_SWIZZLE_NONE:
317
case I915_BIT_6_SWIZZLE_9:
318
offset ^= (offset >> 3) & 64;
320
case I915_BIT_6_SWIZZLE_9_10:
321
offset ^= ((offset ^ (offset >> 1)) >> 3) & 64;
323
case I915_BIT_6_SWIZZLE_9_11:
324
offset ^= ((offset ^ (offset >> 2)) >> 3) & 64;
328
memcpy((char *)dst + offset, src_row, x);
217
334
memmove_box(const void *src, void *dst,
218
335
int bpp, int32_t stride,
219
336
const BoxRec *box,