This is the Format used for image data in the external framebuffer
(XFB). It exploits the fact that the resolution of color on a PAL/NTSC
screen is lower than the resolution of luminance (brightness), and
thus stores only separate luminance info for each pixel and combines
the color information of two pixels each, saving 2 bytes versus traditional
RGB-per-pixel framebuffers. This means that in XFB you cant modify
the color of a single pixel without affecting its neighbour. (you
can however, seperatly modify its luminance/brightness). It also means
that you can not accurately convert one single pixel into XFB framebuffer
format, you will always have to convert two pixels at once.
To convert two pixels to YCbYCr, first average their RGB values
WARNING: this section is screwed! any advice/corrections/help/etcblabla
welcomed! (thanx to Aaron Kaluszka for pointing this out)
S3TC is a compression method for textures, developed by S3 and licenced
by Nintendo for the Gamecube (and also by Microsoft for DirectX 6.0).
It basically gives you one more MIP level for free, with relatively
small quality loss and a simple implementation in hardware. You basically
store 2 colour values and then you have a few bits per pixel to interpolate
between them. It works in blocks of 4x4 pixel.
There are 5 variants:
DXT1 allows one bit of alpha
DXT2/3 allows 4 bits of alpha
DXT4/5 stores 2 alpha values and has 3 bits to interpolate between
them
The difference between DXT2/3 and 4/5 is, if colour values are pre-multiplied
with alpha. The blending equation is normally (c*(1-a))+(t*a)),
so with pre-multiplied alpha the texture contains (t*a) in each
colour channel and the blending becomes (c*(1-a) + t).
Each image is made up of tiles placed linearly from left to right
then top to bottom.
Each tile is made up of 4 blocks
0 1
2 3
Each block is made up of 8 words. These 8 words represent 16 pixels
using S3TC compression.
R = Color 0 Red
G = Color 0 Green
B = Color 0 Blue
r = Color 3 Red
g = Color 3 Green
b = Color 3 Blue
0 - 9, U - Z = Pixel color (2-bits each)
Colors 1 and 2 are interpolated from colors 0 and 3
The tiles are 32 bytes each. Depending on the image format the width
and height of the tiles will differ. A 16bit format (ie RGB5 or RGB4A3)
will have a 4x4 pixel tile since 4 * 4 * 2 bytes = 32. An 8bit
format (ie Color Indexed) will have a 8x4 pixel tile since 8 * 4
* 1 byte = 32.
So a 32x32 image (like a memory card icon) that is in RGB5 format
would be 8 tiles across and 8 tiles down.
Like a usual texture, a CMPR-texture is divided on tiles, each 32-bytes
to fit a texture cache line. Every tile is sub-tiled into four parts,
in zigzag order :
0
1
2
3
The format of the sub-tiles is pretty simple, and looks like DXT1.
First two base colors in RGB565, followed by 16 sub-tile texels. Every
texel is 2-bit wide, to lookup from four colors : 00, 01, 10 and 11.
First two are given already, and last two are interpolated from first
ones, by the following rule :