~ubuntu-branches/ubuntu/raring/xserver-xorg-video-intel/raring

« back to all changes in this revision

Viewing changes to src/sna/blt.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-09-29 16:45:35 UTC
  • mfrom: (1.4.24)
  • Revision ID: package-import@ubuntu.com-20120929164535-g15mwstkty0de7ki
Tags: 2:2.20.9-0ubuntu1
* Merge from unrelease debian git.
  - fixes racy UXA pageflip code (LP: #966744)
* Drop dont-run-intel-mode-fini-before-preinit.diff, upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
214
214
}
215
215
 
216
216
void
 
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)
 
222
{
 
223
        const unsigned tile_width = 512;
 
224
        const unsigned tile_height = 8;
 
225
        const unsigned tile_size = 4096;
 
226
 
 
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;
 
232
 
 
233
        unsigned x, y;
 
234
 
 
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));
 
237
 
 
238
        src = (const uint8_t *)src + src_y * src_stride + src_x * cpp;
 
239
 
 
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;
 
247
 
 
248
                x = width * cpp;
 
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;
 
252
                        offset = tile_row +
 
253
                                (dx >> tile_pixels) * tile_size +
 
254
                                (dx & tile_mask) * cpp;
 
255
                        switch (swizzling) {
 
256
                        case I915_BIT_6_SWIZZLE_NONE:
 
257
                                break;
 
258
                        case I915_BIT_6_SWIZZLE_9:
 
259
                                offset ^= (offset >> 3) & 64;
 
260
                                break;
 
261
                        case I915_BIT_6_SWIZZLE_9_10:
 
262
                                offset ^= ((offset ^ (offset >> 1)) >> 3) & 64;
 
263
                                break;
 
264
                        case I915_BIT_6_SWIZZLE_9_11:
 
265
                                offset ^= ((offset ^ (offset >> 2)) >> 3) & 64;
 
266
                                break;
 
267
                        }
 
268
 
 
269
                        memcpy((char *)dst + offset, src_row, length * cpp);
 
270
 
 
271
                        src_row += length * cpp;
 
272
                        x -= length * cpp;
 
273
                        dx += length;
 
274
                }
 
275
                if (swizzling) {
 
276
                        while (x >= 64) {
 
277
                                offset = tile_row +
 
278
                                        (dx >> tile_pixels) * tile_size +
 
279
                                        (dx & tile_mask) * cpp;
 
280
                                switch (swizzling) {
 
281
                                case I915_BIT_6_SWIZZLE_9:
 
282
                                        offset ^= (offset >> 3) & 64;
 
283
                                        break;
 
284
                                case I915_BIT_6_SWIZZLE_9_10:
 
285
                                        offset ^= ((offset ^ (offset >> 1)) >> 3) & 64;
 
286
                                        break;
 
287
                                case I915_BIT_6_SWIZZLE_9_11:
 
288
                                        offset ^= ((offset ^ (offset >> 2)) >> 3) & 64;
 
289
                                        break;
 
290
                                }
 
291
 
 
292
                                memcpy((char *)dst + offset, src_row, 64);
 
293
 
 
294
                                src_row += 64;
 
295
                                x -= 64;
 
296
                                dx += swizzle_pixels;
 
297
                        }
 
298
                } else {
 
299
                        while (x >= 512) {
 
300
                                assert((dx & tile_mask) == 0);
 
301
                                offset = tile_row + (dx >> tile_pixels) * tile_size;
 
302
 
 
303
                                memcpy((char *)dst + offset, src_row, 512);
 
304
 
 
305
                                src_row += 512;
 
306
                                x -= 512;
 
307
                                dx += swizzle_pixels;
 
308
                        }
 
309
                }
 
310
                if (x) {
 
311
                        offset = tile_row +
 
312
                                (dx >> tile_pixels) * tile_size +
 
313
                                (dx & tile_mask) * cpp;
 
314
                        switch (swizzling) {
 
315
                        case I915_BIT_6_SWIZZLE_NONE:
 
316
                                break;
 
317
                        case I915_BIT_6_SWIZZLE_9:
 
318
                                offset ^= (offset >> 3) & 64;
 
319
                                break;
 
320
                        case I915_BIT_6_SWIZZLE_9_10:
 
321
                                offset ^= ((offset ^ (offset >> 1)) >> 3) & 64;
 
322
                                break;
 
323
                        case I915_BIT_6_SWIZZLE_9_11:
 
324
                                offset ^= ((offset ^ (offset >> 2)) >> 3) & 64;
 
325
                                break;
 
326
                        }
 
327
 
 
328
                        memcpy((char *)dst + offset, src_row, x);
 
329
                }
 
330
        }
 
331
}
 
332
 
 
333
void
217
334
memmove_box(const void *src, void *dst,
218
335
            int bpp, int32_t stride,
219
336
            const BoxRec *box,