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

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/util/u_pack_color.h

  • 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:
37
37
 
38
38
#include "pipe/p_compiler.h"
39
39
#include "pipe/p_format.h"
 
40
#include "util/u_debug.h"
40
41
#include "util/u_format.h"
41
42
#include "util/u_math.h"
42
43
 
43
44
 
44
 
 
 
45
/**
 
46
 * Helper union for packing pixel values.
 
47
 * Will often contain values in formats which are too complex to be described
 
48
 * in simple terms, hence might just effectively contain a number of bytes.
 
49
 * Must be big enough to hold data for all formats (currently 256 bits).
 
50
 */
45
51
union util_color {
46
52
   ubyte ub;
47
53
   ushort us;
48
54
   uint ui;
49
55
   float f[4];
 
56
   double d[4];
50
57
};
51
58
 
52
59
/**
92
99
         uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
93
100
      }
94
101
      return;
 
102
   case PIPE_FORMAT_B5G5R5X1_UNORM:
 
103
      {
 
104
         uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
 
105
      }
 
106
      return;
95
107
   case PIPE_FORMAT_B5G5R5A1_UNORM:
96
108
      {
97
109
         uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
216
228
         *a = (ubyte) 0xff;
217
229
      }
218
230
      return;
 
231
   case PIPE_FORMAT_B5G5R5X1_UNORM:
 
232
      {
 
233
         ushort p = uc->us;
 
234
         *r = (ubyte) (((p >>  7) & 0xf8) | ((p >> 12) & 0x7));
 
235
         *g = (ubyte) (((p >>  2) & 0xf8) | ((p >>  7) & 0x7));
 
236
         *b = (ubyte) (((p <<  3) & 0xf8) | ((p >>  2) & 0x7));
 
237
         *a = (ubyte) 0xff;
 
238
      }
 
239
      return;
219
240
   case PIPE_FORMAT_B5G5R5A1_UNORM:
220
241
      {
221
242
         ushort p = uc->us;
361
382
         uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
362
383
      }
363
384
      return;
 
385
   case PIPE_FORMAT_B5G5R5X1_UNORM:
 
386
      {
 
387
         uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
 
388
      }
 
389
      return;
364
390
   case PIPE_FORMAT_B5G5R5A1_UNORM:
365
391
      {
366
392
         uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
405
431
   }
406
432
}
407
433
 
 
434
/* Integer versions of util_pack_z and util_pack_z_stencil - useful for
 
435
 * constructing clear masks.
 
436
 */
 
437
static INLINE uint
 
438
util_pack_uint_z(enum pipe_format format, unsigned z)
 
439
{
 
440
   switch (format) {
 
441
   case PIPE_FORMAT_Z16_UNORM:
 
442
      return z & 0xffff;
 
443
   case PIPE_FORMAT_Z32_UNORM:
 
444
   case PIPE_FORMAT_Z32_FLOAT:
 
445
      return z;
 
446
   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
 
447
   case PIPE_FORMAT_Z24X8_UNORM:
 
448
      return z & 0xffffff;
 
449
   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
 
450
   case PIPE_FORMAT_X8Z24_UNORM:
 
451
      return (z & 0xffffff) << 8;
 
452
   case PIPE_FORMAT_S8_USCALED:
 
453
      return 0;
 
454
   default:
 
455
      debug_print_format("gallium: unhandled format in util_pack_z()", format);
 
456
      assert(0);
 
457
      return 0;
 
458
   }
 
459
}
 
460
 
 
461
static INLINE uint
 
462
util_pack_uint_z_stencil(enum pipe_format format, double z, uint s)
 
463
{
 
464
   unsigned packed = util_pack_uint_z(format, z);
 
465
 
 
466
   s &= 0xff;
 
467
 
 
468
   switch (format) {
 
469
   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
 
470
      return packed | (s << 24);
 
471
   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
 
472
      return packed | s;
 
473
   case PIPE_FORMAT_S8_USCALED:
 
474
      return packed | s;
 
475
   default:
 
476
      return packed;
 
477
   }
 
478
}
 
479
 
 
480
 
408
481
 
409
482
/**
410
483
 * Note: it's assumed that z is in [0,1]
427
500
      return (uint) (z * 0xffffffff);
428
501
   case PIPE_FORMAT_Z32_FLOAT:
429
502
      return (uint)z;
430
 
   case PIPE_FORMAT_Z24S8_UNORM:
 
503
   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
431
504
   case PIPE_FORMAT_Z24X8_UNORM:
432
505
      if (z == 1.0)
433
506
         return 0xffffff;
434
507
      return (uint) (z * 0xffffff);
435
 
   case PIPE_FORMAT_S8Z24_UNORM:
 
508
   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
436
509
   case PIPE_FORMAT_X8Z24_UNORM:
437
510
      if (z == 1.0)
438
511
         return 0xffffff00;
439
512
      return ((uint) (z * 0xffffff)) << 8;
440
 
   case PIPE_FORMAT_S8_UNORM:
 
513
   case PIPE_FORMAT_S8_USCALED:
441
514
      /* this case can get it via util_pack_z_stencil() */
442
515
      return 0;
443
516
   default:
458
531
   unsigned packed = util_pack_z(format, z);
459
532
 
460
533
   switch (format) {
461
 
   case PIPE_FORMAT_Z24S8_UNORM:
 
534
   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
462
535
      packed |= s << 24;
463
536
      break;
464
 
   case PIPE_FORMAT_S8Z24_UNORM:
 
537
   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
465
538
      packed |= s;
466
539
      break;
467
 
   case PIPE_FORMAT_S8_UNORM:
 
540
   case PIPE_FORMAT_S8_USCALED:
468
541
      packed |= s;
469
542
      break;
470
543
   default: