~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/radeon/radeon_span.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
 * two main types:
112
112
 * - 1D (akin to macro-linear/micro-tiled on older asics)
113
113
 * - 2D (akin to macro-tiled/micro-tiled on older asics)
114
 
 * only 1D tiling is implemented below
115
114
 */
116
115
#if defined(RADEON_R600)
117
116
static inline GLint r600_1d_tile_helper(const struct radeon_renderbuffer * rrb,
208
207
    return offset;
209
208
}
210
209
 
 
210
static inline GLint r600_log2(GLint n)
 
211
{
 
212
        GLint log2 = 0;
 
213
 
 
214
        while (n >>= 1)
 
215
                ++log2;
 
216
        return log2;
 
217
}
 
218
 
 
219
static inline GLint r600_2d_tile_helper(const struct radeon_renderbuffer * rrb,
 
220
                                        GLint x, GLint y, GLint is_depth, GLint is_stencil)
 
221
{
 
222
        GLint group_bytes = rrb->group_bytes;
 
223
        GLint num_channels = rrb->num_channels;
 
224
        GLint num_banks = rrb->num_banks;
 
225
        GLint r7xx_bank_op = rrb->r7xx_bank_op;
 
226
        /* */
 
227
        GLint group_bits = r600_log2(group_bytes);
 
228
        GLint channel_bits = r600_log2(num_channels);
 
229
        GLint bank_bits = r600_log2(num_banks);
 
230
        GLint element_bytes = rrb->cpp;
 
231
        GLint num_samples = 1;
 
232
        GLint tile_width = 8;
 
233
        GLint tile_height = 8;
 
234
        GLint tile_thickness = 1;
 
235
        GLint macro_tile_width = num_banks;
 
236
        GLint macro_tile_height = num_channels;
 
237
        GLint pitch_elements = (rrb->pitch / element_bytes) / tile_width;
 
238
        GLint height = rrb->base.Height / tile_height;
 
239
        GLint z = 0;
 
240
        GLint sample_number = 0;
 
241
        /* */
 
242
        GLint tile_bytes;
 
243
        GLint macro_tile_bytes;
 
244
        GLint macro_tiles_per_row;
 
245
        GLint macro_tiles_per_slice;
 
246
        GLint slice_offset;
 
247
        GLint macro_tile_row_index;
 
248
        GLint macro_tile_column_index;
 
249
        GLint macro_tile_offset;
 
250
        GLint pixel_number = 0;
 
251
        GLint element_offset;
 
252
        GLint bank = 0;
 
253
        GLint channel = 0;
 
254
        GLint total_offset;
 
255
        GLint group_mask = (1 << group_bits) - 1;
 
256
        GLint offset_low;
 
257
        GLint offset_high;
 
258
        GLint offset = 0;
 
259
 
 
260
        switch (num_channels) {
 
261
        case 2:
 
262
        default:
 
263
                // channel[0] = x[3] ^ y[3]
 
264
                channel |= (((x >> 3) ^ (y >> 3)) & 1) << 0;
 
265
                break;
 
266
        case 4:
 
267
                // channel[0] = x[4] ^ y[3]
 
268
                channel |= (((x >> 4) ^ (y >> 3)) & 1) << 0;
 
269
                // channel[1] = x[3] ^ y[4]
 
270
                channel |= (((x >> 3) ^ (y >> 4)) & 1) << 1;
 
271
                break;
 
272
        case 8:
 
273
                // channel[0] = x[5] ^ y[3]
 
274
                channel |= (((x >> 5) ^ (y >> 3)) & 1) << 0;
 
275
                // channel[0] = x[4] ^ x[5] ^ y[4]
 
276
                channel |= (((x >> 4) ^ (x >> 5) ^ (y >> 4)) & 1) << 1;
 
277
                // channel[0] = x[3] ^ y[5]
 
278
                channel |= (((x >> 3) ^ (y >> 5)) & 1) << 2;
 
279
                break;
 
280
        }
 
281
 
 
282
        switch (num_banks) {
 
283
        case 4:
 
284
                // bank[0] = x[3] ^ y[4 + log2(num_channels)]
 
285
                bank |= (((x >> 3) ^ (y >> (4 + channel_bits))) & 1) << 0;
 
286
                if (r7xx_bank_op)
 
287
                        // bank[1] = x[3] ^ y[4 + log2(num_channels)] ^ x[5]
 
288
                        bank |= (((x >> 4) ^ (y >> (3 + channel_bits)) ^ (x >> 5)) & 1) << 1;
 
289
                else
 
290
                        // bank[1] = x[4] ^ y[3 + log2(num_channels)]
 
291
                        bank |= (((x >> 4) ^ (y >> (3 + channel_bits))) & 1) << 1;
 
292
                break;
 
293
        case 8:
 
294
                // bank[0] = x[3] ^ y[5 + log2(num_channels)]
 
295
                bank |= (((x >> 3) ^ (y >> (5 + channel_bits))) & 1) << 0;
 
296
                // bank[1] = x[4] ^ y[4 + log2(num_channels)] ^ y[5 + log2(num_channels)]
 
297
                bank |= (((x >> 4) ^ (y >> (4 + channel_bits)) ^ (y >> (5 + channel_bits))) & 1) << 1;
 
298
                if (r7xx_bank_op)
 
299
                        // bank[2] = x[5] ^ y[3 + log2(num_channels)] ^ x[6]
 
300
                        bank |= (((x >> 5) ^ (y >> (3 + channel_bits)) ^ (x >> 6)) & 1) << 2;
 
301
                else
 
302
                        // bank[2] = x[5] ^ y[3 + log2(num_channels)]
 
303
                        bank |= (((x >> 5) ^ (y >> (3 + channel_bits))) & 1) << 2;
 
304
                break;
 
305
        }
 
306
 
 
307
        tile_bytes = tile_width * tile_height * tile_thickness * element_bytes * num_samples;
 
308
        macro_tile_bytes = macro_tile_width * macro_tile_height * tile_bytes;
 
309
        macro_tiles_per_row = pitch_elements / macro_tile_width;
 
310
        macro_tiles_per_slice = macro_tiles_per_row * (height / macro_tile_height);
 
311
        slice_offset = (z / tile_thickness) * macro_tiles_per_slice * macro_tile_bytes;
 
312
        macro_tile_row_index = (y / tile_height) / macro_tile_height;
 
313
        macro_tile_column_index = (x / tile_width) / macro_tile_width;
 
314
        macro_tile_offset = ((macro_tile_row_index * macro_tiles_per_row) + macro_tile_column_index) * macro_tile_bytes;
 
315
 
 
316
        if (is_depth) {
 
317
                GLint pixel_offset = 0;
 
318
 
 
319
                pixel_number |= ((x >> 0) & 1) << 0; // pn[0] = x[0]
 
320
                pixel_number |= ((y >> 0) & 1) << 1; // pn[1] = y[0]
 
321
                pixel_number |= ((x >> 1) & 1) << 2; // pn[2] = x[1]
 
322
                pixel_number |= ((y >> 1) & 1) << 3; // pn[3] = y[1]
 
323
                pixel_number |= ((x >> 2) & 1) << 4; // pn[4] = x[2]
 
324
                pixel_number |= ((y >> 2) & 1) << 5; // pn[5] = y[2]
 
325
                switch (element_bytes) {
 
326
                case 2:
 
327
                        pixel_offset = pixel_number * element_bytes * num_samples;
 
328
                        break;
 
329
                case 4:
 
330
                        /* stencil and depth data are stored separately within a tile.
 
331
                         * stencil is stored in a contiguous tile before the depth tile.
 
332
                         * stencil element is 1 byte, depth element is 3 bytes.
 
333
                         * stencil tile is 64 bytes.
 
334
                         */
 
335
                        if (is_stencil)
 
336
                                pixel_offset = pixel_number * 1 * num_samples;
 
337
                        else
 
338
                                pixel_offset = (pixel_number * 3 * num_samples) + 64;
 
339
                        break;
 
340
                }
 
341
                element_offset = pixel_offset + (sample_number * element_bytes);
 
342
        } else {
 
343
                GLint sample_offset;
 
344
 
 
345
                switch (element_bytes) {
 
346
                case 1:
 
347
                        pixel_number |= ((x >> 0) & 1) << 0; // pn[0] = x[0]
 
348
                        pixel_number |= ((x >> 1) & 1) << 1; // pn[1] = x[1]
 
349
                        pixel_number |= ((x >> 2) & 1) << 2; // pn[2] = x[2]
 
350
                        pixel_number |= ((y >> 1) & 1) << 3; // pn[3] = y[1]
 
351
                        pixel_number |= ((y >> 0) & 1) << 4; // pn[4] = y[0]
 
352
                        pixel_number |= ((y >> 2) & 1) << 5; // pn[5] = y[2]
 
353
                        break;
 
354
                case 2:
 
355
                        pixel_number |= ((x >> 0) & 1) << 0; // pn[0] = x[0]
 
356
                        pixel_number |= ((x >> 1) & 1) << 1; // pn[1] = x[1]
 
357
                        pixel_number |= ((x >> 2) & 1) << 2; // pn[2] = x[2]
 
358
                        pixel_number |= ((y >> 0) & 1) << 3; // pn[3] = y[0]
 
359
                        pixel_number |= ((y >> 1) & 1) << 4; // pn[4] = y[1]
 
360
                        pixel_number |= ((y >> 2) & 1) << 5; // pn[5] = y[2]
 
361
                        break;
 
362
                case 4:
 
363
                        pixel_number |= ((x >> 0) & 1) << 0; // pn[0] = x[0]
 
364
                        pixel_number |= ((x >> 1) & 1) << 1; // pn[1] = x[1]
 
365
                        pixel_number |= ((y >> 0) & 1) << 2; // pn[2] = y[0]
 
366
                        pixel_number |= ((x >> 2) & 1) << 3; // pn[3] = x[2]
 
367
                        pixel_number |= ((y >> 1) & 1) << 4; // pn[4] = y[1]
 
368
                        pixel_number |= ((y >> 2) & 1) << 5; // pn[5] = y[2]
 
369
                        break;
 
370
                }
 
371
                sample_offset = sample_number * (tile_bytes / num_samples);
 
372
                element_offset = sample_offset + (pixel_number * element_bytes);
 
373
        }
 
374
        total_offset = (slice_offset + macro_tile_offset) >> (channel_bits + bank_bits);
 
375
        total_offset += element_offset;
 
376
 
 
377
        offset_low = total_offset & group_mask;
 
378
        offset_high = (total_offset & ~group_mask) << (channel_bits + bank_bits);
 
379
        offset = (bank << (group_bits + channel_bits)) + (channel << group_bits) + offset_low + offset_high;
 
380
 
 
381
        return offset;
 
382
}
 
383
 
211
384
/* depth buffers */
212
385
static GLubyte *r600_ptr_depth(const struct radeon_renderbuffer * rrb,
213
386
                               GLint x, GLint y)
214
387
{
215
388
    GLubyte *ptr = rrb->bo->ptr;
216
 
    GLint offset = r600_1d_tile_helper(rrb, x, y, 1, 0);
 
389
    GLint offset;
 
390
    if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
 
391
            offset = r600_2d_tile_helper(rrb, x, y, 1, 0);
 
392
    else
 
393
            offset = r600_1d_tile_helper(rrb, x, y, 1, 0);
217
394
    return &ptr[offset];
218
395
}
219
396
 
221
398
                                 GLint x, GLint y)
222
399
{
223
400
    GLubyte *ptr = rrb->bo->ptr;
224
 
    GLint offset = r600_1d_tile_helper(rrb, x, y, 1, 1);
 
401
    GLint offset;
 
402
    if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
 
403
            offset = r600_2d_tile_helper(rrb, x, y, 1, 1);
 
404
    else
 
405
            offset = r600_1d_tile_helper(rrb, x, y, 1, 1);
225
406
    return &ptr[offset];
226
407
}
227
408
 
235
416
    if (rrb->has_surface || !(rrb->bo->flags & mask)) {
236
417
        offset = x * rrb->cpp + y * rrb->pitch;
237
418
    } else {
238
 
            offset = r600_1d_tile_helper(rrb, x, y, 0, 0);
 
419
            if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
 
420
                    offset = r600_2d_tile_helper(rrb, x, y, 0, 0);
 
421
            else
 
422
                    offset = r600_1d_tile_helper(rrb, x, y, 0, 0);
239
423
    }
240
424
    return &ptr[offset];
241
425
}