From: Nathan H. <na...@ma...> - 2000-12-30 06:18:47
|
On Fri, Dec 29, 2000 at 03:59:46PM -0800, ra...@ra... wrote: > On 29 Dec, Gareth Hughes scribbled: > -> > -> #define READ_RGBA( rgba, _x, _y ) \ > -> do { \ > -> GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \ > -> rgba[0] = (p >> 8) & 0xf8; \ > -> rgba[1] = (p >> 3) & 0xfc; \ > -> rgba[2] = (p << 3) & 0xf8; \ > -> rgba[3] = 0xff; \ > -> if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \ > -> if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \ > -> if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; \ > -> } while (0) > > just thoguht i'd mention - you'll bypass the cmp's and jne/jeq' branches > and get some better performance with: > > #define READ_RGBA( rgba, _x, _y ) \ > do { \ > GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \ > rgba[0] = ((p >> 8) & 0xf8) | ((p >> 13) & 0x7); \ > rgba[1] = ((p >> 3) & 0xfc) | ((p >> 9) & 0x3); \ > rgba[2] = ((p << 3) & 0xf8) | ((p >> 2) & 0x7); \ > rgba[3] = 0xff; \ > } while (0) Performance is an exceptional non-issue with the software fallback paths. Incremental improvements like this are welcome for hardware accelerated paths but they are lost in the noise otherwise. |