15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    3DFX_texture_compression_FXT1
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_3DFX_texture_compression_FXT1
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Don Mullis, 3dfx Interactive (dwm 'at' 3dfx.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciStatus
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    CANDIDATE FOR FINAL DRAFT -- NOT YET COMPLETE
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ciVersion
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ci    Draft 0.4, 12 Apr 2000
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ciNumber
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    206
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ciDependencies
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ci    OpenGL 1.1 is required.
285bd8deadSopenharmony_ci    GL_ARB_texture_compression is required.
295bd8deadSopenharmony_ci    This extension is written against the OpenGL 1.2.1 Specification.
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ciOverview
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ci    This extension additional texture compression functionality 's FXT1
345bd8deadSopenharmony_ci    format, specific to 3dfxsubject to all the requirements and
355bd8deadSopenharmony_ci    limitations described by the extension GL_ARB_texture_compression.
365bd8deadSopenharmony_ci    The FXT1 texture format supports only 2D and 3D images without
375bd8deadSopenharmony_ci    borders.
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ci    Because 3dfx expects to make continual improvement to its FXT1
405bd8deadSopenharmony_ci    compressor implementation, 3dfx recommends that to achieve best
415bd8deadSopenharmony_ci    visual quality applications adopt the following procedure with
425bd8deadSopenharmony_ci    respect to reuse of textures compressed by the GL:
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ci	1) Save the RENDERER and VERSION strings along with images
455bd8deadSopenharmony_ci	   compressed by the GL;
465bd8deadSopenharmony_ci	2) Before reuse of the textures, compare the stored strings with
475bd8deadSopenharmony_ci	   strings newly returned from the current GL;
485bd8deadSopenharmony_ci	3) If out-of-date, repeat the compression and storage steps.
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ciIP Status
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    A royalty-free license is available from 3dfx Interactive
535bd8deadSopenharmony_ci    (http://www.3dfx.com/).
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ciIssues
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ci    (1) Two or only one internalformat tokens:
585bd8deadSopenharmony_ci	GL_COMPRESSED_RGBA_FXT1_3DFX and GL_COMPRESSED_RGB_FXT1_3DFX, or
595bd8deadSopenharmony_ci	GL_COMPRESSED_RGBA_FXT1_3DFX only. These names are placeholders,
605bd8deadSopenharmony_ci	the point in question is whether there should be separate tokens
615bd8deadSopenharmony_ci	reflecting extrinsic knowledge of whether the image contains any
625bd8deadSopenharmony_ci	non-unity alpha values. This arises because the FXT1 image
635bd8deadSopenharmony_ci	format distinguishes non-unity alpha only at the level of an
645bd8deadSopenharmony_ci	individual 8x4 compression block. If there are two distinct
655bd8deadSopenharmony_ci	tokens, passing GL_COMPRESSED_RGB_FXT1_3DFX to
665bd8deadSopenharmony_ci	CompressedTexImage with an image that contained non-unity-alpha
675bd8deadSopenharmony_ci	blocks would be an error.
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ci	RESOLVED. Two distinct tokens specified. This is largely to
705bd8deadSopenharmony_ci	follow the usual usage by apps of non-compressed tokens.
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci    (2) Support for borders.
735bd8deadSopenharmony_ci
745bd8deadSopenharmony_ci	RESOLVED.  Not supported.
755bd8deadSopenharmony_ci
765bd8deadSopenharmony_ci    (3) Support for TexSubImage at a level more general than that
775bd8deadSopenharmony_ci	guaranteed by ARB_texture_compression.
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ci	RESOLVED. Not supported; See issue (5) of the
805bd8deadSopenharmony_ci	GL_ARB_texture_compression spec.
815bd8deadSopenharmony_ci
825bd8deadSopenharmony_ciNew Procedures and Functions
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ci    None
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ciNew Tokens
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci    Accepted by the <internalformat> parameter of TexImage2D,
895bd8deadSopenharmony_ci    CopyTexImage2D, TexImage3D, CopyTexImage3D, and by the
905bd8deadSopenharmony_ci    <internalformat> and <format> parameters of
915bd8deadSopenharmony_ci    CompressedTexImage2D_ARB, CompressedTexSubImage2D_ARB,
925bd8deadSopenharmony_ci    CompressedTexImage3D_ARB, CompressedTexSubImage3D_ARB:
935bd8deadSopenharmony_ci
945bd8deadSopenharmony_ci	COMPRESSED_RGB_FXT1_3DFX			  0x86B0
955bd8deadSopenharmony_ci	COMPRESSED_RGBA_FXT1_3DFX			  0x86B1
965bd8deadSopenharmony_ci
975bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation)
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci    None.
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization)
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci    Add Table 3.16.1:  Specific Compressed Internal Formats
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ci	Compressed Internal Format	   Base Internal Format
1065bd8deadSopenharmony_ci	==========================	   ====================
1075bd8deadSopenharmony_ci	COMPRESSED_RGB_FXT1_3DFX	   RGB
1085bd8deadSopenharmony_ci	COMPRESSED_RGBA_FXT1_3DFX	   RGBA
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci    Add to Section 3.8.2, Alternate Image Specification (adding to the
1115bd8deadSopenharmony_ci    end of the CompressedTexImage section introduced by the
1125bd8deadSopenharmony_ci    ARB_texture_compression spec)
1135bd8deadSopenharmony_ci
1145bd8deadSopenharmony_ci    If <internalformat> is COMPRESSED_RGB_FXT1_3DFX,
1155bd8deadSopenharmony_ci    COMPRESSED_RGBA_FXT1_3DFX, the compressed texture is stored using
1165bd8deadSopenharmony_ci    one of several FXT1 compressed texture image formats. FXT1 texture
1175bd8deadSopenharmony_ci    compression supports only 2D images without borders.
1185bd8deadSopenharmony_ci    CompressedTexImage1DARB and CompressedTexImage3DARB produce an
1195bd8deadSopenharmony_ci    INVALID_ENUM error if <internalformat> is an FXT1 format.
1205bd8deadSopenharmony_ci    CompressedTexImage2DARB will produce an INVALID_OPERATION error if
1215bd8deadSopenharmony_ci    <border> is non-zero.
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ci    Add to Section 3.8.2, Alternate Image Specification (adding to the
1255bd8deadSopenharmony_ci    end of the CompressedTexSubImage section introduced by the
1265bd8deadSopenharmony_ci    ARB_texture_compression spec)
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci    If the internal format of the texture image being modified is
1295bd8deadSopenharmony_ci    COMPRESSED_RGB_FXT1_3DFX, COMPRESSED_RGBA_FXT1_3DFX, the texture is
1305bd8deadSopenharmony_ci    stored using one of the several FXT1 compressed texture image
1315bd8deadSopenharmony_ci    formats. Since the FXT1 texture compression algorithm supports only
1325bd8deadSopenharmony_ci    2D images, CompressedTexSubImage1DARB and CompressedTexSubImage3DARB
1335bd8deadSopenharmony_ci    produce an INVALID_ENUM error if <format> is an FXT1 format.
1345bd8deadSopenharmony_ci
1355bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment
1365bd8deadSopenharmony_ciOperations and the Frame Buffer)
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    None.
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions)
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci    None.
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.2.1 Specification (State and
1455bd8deadSopenharmony_ciState Requests)
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci    None.
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 1.2.1 Specification (Invariance)
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci    None.
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci    None.
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ciGLX Protocol
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ci    None.
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ciErrors
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci    INVALID_ENUM is generated by CompressedTexImage1DARB if
1645bd8deadSopenharmony_ci    <internalformat> is GL_COMPRESSED_RGB_FXT1_3DFX or
1655bd8deadSopenharmony_ci    GL_COMPRESSED_RGBA_FXT1_3DFX.
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ci    INVALID_OPERATION is generated by CompressedTexImage2DARB or
1685bd8deadSopenharmony_ci    CompressedTexImage3DARB if <internalformat> is
1695bd8deadSopenharmony_ci    GL_COMPRESSED_RGB_FXT1_3DFX or GL_COMPRESSED_RGBA_FXT1_3DFX and
1705bd8deadSopenharmony_ci    <border> is not equal to zero.
1715bd8deadSopenharmony_ci
1725bd8deadSopenharmony_ci    INVALID_ENUM is generated by CompressedTexSubImage1DARB if <format>
1735bd8deadSopenharmony_ci    is GL_COMPRESSED_RGB_FXT1_3DFX or GL_COMPRESSED_RGBA_FXT1_3DFX.
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ciAppendix
1765bd8deadSopenharmony_ci
1775bd8deadSopenharmony_ci    FXT1 comprises four different compressed texture formats. Each of
1785bd8deadSopenharmony_ci    the formats compress an 8x4 texel blocks into 128 bits. During the
1795bd8deadSopenharmony_ci    compression phase, the encoder selects one of the four formats for
1805bd8deadSopenharmony_ci    each block based on which encoding scheme results in best overall
1815bd8deadSopenharmony_ci    visual quality. Unused pixel locations along the right or bottom
1825bd8deadSopenharmony_ci    edges within a block should contain a repetition of the values in
1835bd8deadSopenharmony_ci    used locations. The total size of an image is ceil(width/8) *
1845bd8deadSopenharmony_ci    ceil(height/4) * 16 bytes.
1855bd8deadSopenharmony_ci
1865bd8deadSopenharmony_ci    In each compression format, the 32 texels of the 8x4 block are
1875bd8deadSopenharmony_ci    partitioned into two 4x4 sub-blocks according to the following
1885bd8deadSopenharmony_ci    diagram:
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci	 t0  t1  t2  t3   t16 t17 t18 t19
1915bd8deadSopenharmony_ci	 t4  t5  t6  t7   t20 t21 t22 t23
1925bd8deadSopenharmony_ci	 t8  t9 t10 t11   t24 t25 t26 t27
1935bd8deadSopenharmony_ci	t12 t13 t14 t15   t28 t29 t30 t31
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ci    In the following bit-level descriptions, bits of increasing index
1965bd8deadSopenharmony_ci    are stored in bytes at likewise increasing offsets, i.e. the order
1975bd8deadSopenharmony_ci    is "little-endian".
1985bd8deadSopenharmony_ci
1995bd8deadSopenharmony_ci
2005bd8deadSopenharmony_ci    1. FXT1 Compressed Texture Format CC_HI:
2015bd8deadSopenharmony_ci
2025bd8deadSopenharmony_ci    (rgb555) (3-bit/texel)
2035bd8deadSopenharmony_ci    mode[1:0]  color1  color0  texel 31 to 16  texel 15 to 0
2045bd8deadSopenharmony_ci	    2	   15	   15		   48		  48
2055bd8deadSopenharmony_ci
2065bd8deadSopenharmony_ci
2075bd8deadSopenharmony_ci	    [127:126]  mode[1:0]
2085bd8deadSopenharmony_ci	    [125:121]  red of color1
2095bd8deadSopenharmony_ci	    [120:116]  green of color1
2105bd8deadSopenharmony_ci	    [115:111]  blue of color1
2115bd8deadSopenharmony_ci	    [110:106]  red of color0
2125bd8deadSopenharmony_ci	    [105:101]  green of color0
2135bd8deadSopenharmony_ci	     [100:96]  blue of color0
2145bd8deadSopenharmony_ci	      [95:93]  texel 31
2155bd8deadSopenharmony_ci		...
2165bd8deadSopenharmony_ci	      [50:48]  texel 16
2175bd8deadSopenharmony_ci	      [47:45]  texel 15
2185bd8deadSopenharmony_ci		 ...
2195bd8deadSopenharmony_ci		[2:0]  texel 0
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci    In CC_HI format, mode = 00b, the 15-bit color1 (RGB555 format) and
2225bd8deadSopenharmony_ci    color0 (RGB555 format) colors are converted into 24-bit RGB888
2235bd8deadSopenharmony_ci    colors by duplicating the upper 3 bits for the 3 LSBs. The 24-bit
2245bd8deadSopenharmony_ci    converted color1 and color0 are then used to linearly interpolate 5
2255bd8deadSopenharmony_ci    more levels of color to create seven total levels of colors and 1
2265bd8deadSopenharmony_ci    alpha (transparent) color. The first seven colors always have
2275bd8deadSopenharmony_ci    alpha=ffh (opaque), while the eighth color is defined to be
2285bd8deadSopenharmony_ci    transparent black (r,g,b=00h, alpha=00h).
2295bd8deadSopenharmony_ci
2305bd8deadSopenharmony_ci    These eight 32-bit colors are used as the contents of an 8-entry (3
2315bd8deadSopenharmony_ci    bit index) lookup table. For all 32 texels in the block, each
2325bd8deadSopenharmony_ci    texel's 3-bit index value is used to index the lookup table, the
2335bd8deadSopenharmony_ci    output from the lookup table representing the 32-bit color
2345bd8deadSopenharmony_ci    (ARGB8888) for that texel.
2355bd8deadSopenharmony_ci
2365bd8deadSopenharmony_ci    Generating RGB888 from RGB555:
2375bd8deadSopenharmony_ci
2385bd8deadSopenharmony_ci	    Color1 (red) =   {[125:121], [125:123]}
2395bd8deadSopenharmony_ci	    Color1 (green) = {[120:116], [120:118]}
2405bd8deadSopenharmony_ci	    Color1 (blue) =  {[115:111], [115:113]}
2415bd8deadSopenharmony_ci
2425bd8deadSopenharmony_ci	    Color0 (red) =   {[110:106], [110:108]}
2435bd8deadSopenharmony_ci	    Color0 (green) = {[105:101], [105:103]}
2445bd8deadSopenharmony_ci	    Color0 (blue) =  {[100:96],  [100:98]}
2455bd8deadSopenharmony_ci
2465bd8deadSopenharmony_ci    Creating seven ARGB8888 colors from two RGB888 colors (operations
2475bd8deadSopenharmony_ci    performed individually for each color channel):
2485bd8deadSopenharmony_ci
2495bd8deadSopenharmony_ci	    Color[0] = color0[r,g,b], alpha[0] = ffh
2505bd8deadSopenharmony_ci	    Color[1] = (5*color0[r,g,b] + color1[r,g,b] +3 )/6 alpha[1] = ffh
2515bd8deadSopenharmony_ci	    Color[2] = (4*color0[r,g,b] + 2*color1[r,g,b] +3 )/6 alpha[2] = ffh
2525bd8deadSopenharmony_ci	    Color[3] = (3*color0[r,g,b] + 3*color1[r,g,b] +3 )/6 alpha[3] = ffh
2535bd8deadSopenharmony_ci	    Color[4] = (2*color0[r,g,b] + 4*color1[r,g,b] +3 )/6 alpha[4] = ffh
2545bd8deadSopenharmony_ci	    Color[5] = (color0[r,g,b] + 5*color1[r,g,b] +3 )/6 alpha[5] = ffh
2555bd8deadSopenharmony_ci	    Color[6] = color1[r,g,b], alpha[6] = ffh
2565bd8deadSopenharmony_ci	    Color[7] = where r,g,b = 00h, alpha[7]=00h
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ci    Table Lookup:
2595bd8deadSopenharmony_ci	   3-bit index of   Color for texel 31 to texel 0
2605bd8deadSopenharmony_ci	texel31 to texel0   (ARGB8888)
2615bd8deadSopenharmony_ci
2625bd8deadSopenharmony_ci			0   color[0] => {a[7:0], r[7:0], g[7:0], b[7:0]}
2635bd8deadSopenharmony_ci			1   color[1]
2645bd8deadSopenharmony_ci			2   color[2]
2655bd8deadSopenharmony_ci			3   color[3]
2665bd8deadSopenharmony_ci			4   color[4]
2675bd8deadSopenharmony_ci			5   color[5]
2685bd8deadSopenharmony_ci			6   color[6]
2695bd8deadSopenharmony_ci			7   color[7]
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci
2725bd8deadSopenharmony_ci    2. FXT1 Compressed Texture Format CC_CHROMA:
2735bd8deadSopenharmony_ci
2745bd8deadSopenharmony_ci    (rgb555) (2-bit/texel)
2755bd8deadSopenharmony_ci    Mode[2:0] unused color3 color2 color1 color0  texel 31 to 16  texel 15 to 0
2765bd8deadSopenharmony_ci	    3	   1	 15	15     15     15	      32	     32
2775bd8deadSopenharmony_ci
2785bd8deadSopenharmony_ci	    [127:125]  mode[2:0]
2795bd8deadSopenharmony_ci		[124]  unused
2805bd8deadSopenharmony_ci	    [123:119]  color3(r5)
2815bd8deadSopenharmony_ci	    [118:114]  color3(g5)
2825bd8deadSopenharmony_ci	    [113:109]  color3(b5)
2835bd8deadSopenharmony_ci	    [108:104]  color2(r5)
2845bd8deadSopenharmony_ci	     [103:99]  color2(g5)
2855bd8deadSopenharmony_ci	      [98:94]  color2(b5)
2865bd8deadSopenharmony_ci	      [93:89]  color1(r5)
2875bd8deadSopenharmony_ci	      [88:84]  color1(g5)
2885bd8deadSopenharmony_ci	      [83:79]  color1(b5)
2895bd8deadSopenharmony_ci	      [78:74]  color0(r5)
2905bd8deadSopenharmony_ci	      [73:69]  color0(g5)
2915bd8deadSopenharmony_ci	      [68:64]  color0(b5)
2925bd8deadSopenharmony_ci	      [63:62]  texel 31
2935bd8deadSopenharmony_ci		 ...
2945bd8deadSopenharmony_ci	      [33:32]  texel 16
2955bd8deadSopenharmony_ci	      [31:30]  texel 15
2965bd8deadSopenharmony_ci		 ...
2975bd8deadSopenharmony_ci		[1:0]  texel 0
2985bd8deadSopenharmony_ci
2995bd8deadSopenharmony_ci    In CC_CHROMA format, mode=010b, the 15-bit colors color[3:0]
3005bd8deadSopenharmony_ci    (RGB555) are converted into 24-bit RGB888 colors exactly the same as
3015bd8deadSopenharmony_ci    in the CC_HI format via bit replication. Color3 to Color0 are used
3025bd8deadSopenharmony_ci    as they are (after conversion to RGB888 format), but without
3035bd8deadSopenharmony_ci    interpolation. The 24-bit converted colors color3, color2, color1,
3045bd8deadSopenharmony_ci    and color0 are used as the contents of a 4-entry (2-bit index)
3055bd8deadSopenharmony_ci    lookup table. The Alpha channel of the output of the lookup table is
3065bd8deadSopenharmony_ci    always opaque(ffh), regardless of the 2-bit index value. The 32-bit
3075bd8deadSopenharmony_ci    (ARGB8888) color value for each texel is obtained by performing
3085bd8deadSopenharmony_ci    table lookup using that texel's 2-bit index.
3095bd8deadSopenharmony_ci
3105bd8deadSopenharmony_ci    Table Lookup:
3115bd8deadSopenharmony_ci
3125bd8deadSopenharmony_ci	    2-bit index of   Color for texel 31 to texel 0
3135bd8deadSopenharmony_ci       texel 31 to texel 0   (ARGB8888)
3145bd8deadSopenharmony_ci
3155bd8deadSopenharmony_ci			 0   color0, alpha = ffh
3165bd8deadSopenharmony_ci			 1   color1, alpha = ffh
3175bd8deadSopenharmony_ci			 2   color2, alpha = ffh
3185bd8deadSopenharmony_ci			 3   color3, alpha = ffh
3195bd8deadSopenharmony_ci
3205bd8deadSopenharmony_ci
3215bd8deadSopenharmony_ci    3. FXT1 Compressed Texture Format CC_MIXED:
3225bd8deadSopenharmony_ci
3235bd8deadSopenharmony_ci    (rgb555) (2-bit/texel)
3245bd8deadSopenharmony_ci    mode[0] glsb[1:0] alpha[0] color3 color2 color1 color0  texel 31to16  texel 15to0
3255bd8deadSopenharmony_ci	  1	    2	     1	   15	  15	 15	15	      32	   32
3265bd8deadSopenharmony_ci
3275bd8deadSopenharmony_ci
3285bd8deadSopenharmony_ci		[127]  mode[0]
3295bd8deadSopenharmony_ci	    [126:125]  glsb[1:0] (lsbs of green for color 1 & color 3)
3305bd8deadSopenharmony_ci		[124]  alpha[0]
3315bd8deadSopenharmony_ci	    [123:119]  color3(r5)
3325bd8deadSopenharmony_ci	    [118:114]  color3(g5)
3335bd8deadSopenharmony_ci	    [113:109]  color3(b5)
3345bd8deadSopenharmony_ci	    [108:104]  color2(r5)
3355bd8deadSopenharmony_ci	     [103:99]  color2(g5)
3365bd8deadSopenharmony_ci	      [98:94]  color2(b5)
3375bd8deadSopenharmony_ci	      [93:89]  color1(r5)
3385bd8deadSopenharmony_ci	      [88:84]  color1(g5)
3395bd8deadSopenharmony_ci	      [83:79]  color1(b5)
3405bd8deadSopenharmony_ci	      [78:74]  color0(r5)
3415bd8deadSopenharmony_ci	      [73:69]  color0(g5)
3425bd8deadSopenharmony_ci	      [68:64]  color0(b5)
3435bd8deadSopenharmony_ci	      [63:62]  texel 31
3445bd8deadSopenharmony_ci		 ...
3455bd8deadSopenharmony_ci	      [33:32]  texel 16
3465bd8deadSopenharmony_ci	      [31:30]  texel 15
3475bd8deadSopenharmony_ci		 ...
3485bd8deadSopenharmony_ci		[1:0]  texel 0
3495bd8deadSopenharmony_ci
3505bd8deadSopenharmony_ci    In CC_MIXED format, mode[0]=1 (only one bit), color2 and color3 are
3515bd8deadSopenharmony_ci    used for texels 31 to 16, and color0 and color1 are used for texels
3525bd8deadSopenharmony_ci    15 to 0. When alpha[0] = 0, the two pairs of colors (colors 0 and 1
3535bd8deadSopenharmony_ci    for texels 15 to 0 and colors 2 and 3 for texels 31 to 16) are
3545bd8deadSopenharmony_ci    interpreted as 16-bit RGB565 colors. For color1 and color3, the LSB
3555bd8deadSopenharmony_ci    (bit 0) of the green channel comes from the glsb bits
3565bd8deadSopenharmony_ci    (color1.green[0] = bit 125, color3.green[0] = bit 126). For color0
3575bd8deadSopenharmony_ci    and color2, the LSB (bit 0) of the green channel comes from the
3585bd8deadSopenharmony_ci    upper select bit for texel 0 and texel 16, respectively
3595bd8deadSopenharmony_ci    (color0.green[0] = bit 1 xor bit 125, color2.green[0] = bit 33 xor
3605bd8deadSopenharmony_ci    bit 126). The two 16-bit colors are then expanded to a 24-bit RGB888
3615bd8deadSopenharmony_ci    format by bit replication (most significant bits replicated in the
3625bd8deadSopenharmony_ci    least significant bits), and are then used to create 2 more levels
3635bd8deadSopenharmony_ci    of color in between the color0/2 and color1/3 values through linear
3645bd8deadSopenharmony_ci    interpolation. A total of 4 colors are therefore available for 2-bit
3655bd8deadSopenharmony_ci    index per texel selection.
3665bd8deadSopenharmony_ci
3675bd8deadSopenharmony_ci    When alpha[0]=1, color0 and color2 are interpreted as 15-bit RGB555
3685bd8deadSopenharmony_ci    colors, and color 1 and color3 are interpreted as RGB565 colors. For
3695bd8deadSopenharmony_ci    color0 and color2, the 15-bit RGB555 colors are expanded to 24-bit
3705bd8deadSopenharmony_ci    RGB888 colors by bit replication. For color1 and color3, the LSB
3715bd8deadSopenharmony_ci    (bit 0) of the green channel comes from the glsb bits
3725bd8deadSopenharmony_ci    (color1.green[0] = bit 125, color3.green[0] = bit 126), and then bit
3735bd8deadSopenharmony_ci    replication is used to convert from the 16-bit RGB565 format to a
3745bd8deadSopenharmony_ci    24-bit RGB888 format. A third color is created by linear
3755bd8deadSopenharmony_ci    interpolation (interpolating between the converted 24-bit RGB888
3765bd8deadSopenharmony_ci    color0 and color1 for texels 15 to 0, and interpolating between the
3775bd8deadSopenharmony_ci    converted 24-bit RGB888 color2 and color3 for texels 31 to 16).
3785bd8deadSopenharmony_ci    Finally, a fourth color (texel index 0x3) is defined to be
3795bd8deadSopenharmony_ci    transparent black (r,g,b=00h, alpha=00h). A total of 4 colors are
3805bd8deadSopenharmony_ci    therefore available for 2-bit index per texel selection. The 32-bit
3815bd8deadSopenharmony_ci    (ARGB8888) color value for all texels is obtained by performing
3825bd8deadSopenharmony_ci    table lookup using each texel's 2-bit index.
3835bd8deadSopenharmony_ci
3845bd8deadSopenharmony_ci    Creating the 24-bit (RGB888) base colors color3 and color2:
3855bd8deadSopenharmony_ci
3865bd8deadSopenharmony_ci	    Color3(red) = {[123:119], [123:121]}
3875bd8deadSopenharmony_ci	    Color3(green) = {[118:114], [126], [118:117]}
3885bd8deadSopenharmony_ci	    Color3(blue) = {[113:109], [113:111]}
3895bd8deadSopenharmony_ci	    Color2(red) = {[108:104], [108:106]}
3905bd8deadSopenharmony_ci	    Color2(green) = (alpha[0]=1) ? {[103:99],[103:101]}
3915bd8deadSopenharmony_ci					 : {[103:99],[33]^[126],[103:102]}
3925bd8deadSopenharmony_ci	    Color2(blue) = {[98:94], [98:96]}
3935bd8deadSopenharmony_ci
3945bd8deadSopenharmony_ci    Creating the 24-bit (RGB888) base colors color1 and color0:
3955bd8deadSopenharmony_ci
3965bd8deadSopenharmony_ci	    Color1(red) = {[93:89], [93:91]}
3975bd8deadSopenharmony_ci	    Color1(green) = {[88:84], [125], [88:87]}
3985bd8deadSopenharmony_ci	    Color1(blue) = {[83:79], [83:81]}
3995bd8deadSopenharmony_ci	    Color0(red) = {[78:74], [78:76]}
4005bd8deadSopenharmony_ci	    Color0(green) = (alpha[0]=1) ? {[73:69, [73:71]}
4015bd8deadSopenharmony_ci					 : {[73:69], [1]^[125], [73:72]}
4025bd8deadSopenharmony_ci	    Color0(blue) = {[68:64], [68:66]}
4035bd8deadSopenharmony_ci
4045bd8deadSopenharmony_ci    When alpha[0]=0, because one of the texel select bits is used to
4055bd8deadSopenharmony_ci    determine a bit of color0 and color2, the software encoder must
4065bd8deadSopenharmony_ci    perform some very tricky operations. The method below describes how
4075bd8deadSopenharmony_ci    to generate color0 and color1 and the associated select bits (the
4085bd8deadSopenharmony_ci    same method applies to determining the lsb of green for color2 and
4095bd8deadSopenharmony_ci    color3):
4105bd8deadSopenharmony_ci
4115bd8deadSopenharmony_ci	    1. Determine the 16-bit RGB565 color values for color0 & color1.
4125bd8deadSopenharmony_ci
4135bd8deadSopenharmony_ci	    2. Determine the select bits for each pixel in the 4x4 sub-block.
4145bd8deadSopenharmony_ci
4155bd8deadSopenharmony_ci	    3. If (pixel[0].select[1] != color0.green[0]^color1.green[0]) then
4165bd8deadSopenharmony_ci	       swap color0 &color1, and invert all the select bits.
4175bd8deadSopenharmony_ci
4185bd8deadSopenharmony_ci    Below is a snippet of psuedo-C code to generate bits 0-31, bits
4195bd8deadSopenharmony_ci    64-93 & bit 125 based on the initial color0, color1 and pixel
4205bd8deadSopenharmony_ci    indices:
4215bd8deadSopenharmony_ci
4225bd8deadSopenharmony_ci    struct RGB565 {Byte red; Byte green; Byte blue};
4235bd8deadSopenharmony_ci
4245bd8deadSopenharmony_ci    struct CSels {Byte index[16]};
4255bd8deadSopenharmony_ci
4265bd8deadSopenharmony_ci    // cc_mixed_right_half derives bits[93:64] of the 128 bit data word of a
4275bd8deadSopenharmony_ci    // CC_MIXED non-alpha compression block and returns them in 'bits_64_to_31'.
4285bd8deadSopenharmony_ci    // Plus, as a bonus, you will receive bit 125, containing the lsb of
4295bd8deadSopenharmony_ci    // the green channel of color1, and bits_0_to_31, containing all of the pixel indices.
4305bd8deadSopenharmony_ci    void
4315bd8deadSopenharmony_ci    cc_mixed_right_half( RGB565 color0, RGB565 color1,
4325bd8deadSopenharmony_ci			 CSels pix,
4335bd8deadSopenharmony_ci			 Dword &bits_0_to_31,
4345bd8deadSopenharmony_ci			 Dword &bits_64_to_93,
4355bd8deadSopenharmony_ci			 Bit &bit125)
4365bd8deadSopenharmony_ci    {
4375bd8deadSopenharmony_ci	RGB565 o_color0;
4385bd8deadSopenharmony_ci	RGB565 o_color1;
4395bd8deadSopenharmony_ci
4405bd8deadSopenharmony_ci	// Determine if we need to switch color0 & color1
4415bd8deadSopenharmony_ci	if (((pix.index[0] >> 1) & 1) != ((color0.green ^ color1.green) & 1)) {
4425bd8deadSopenharmony_ci	    o_color1 = color0;
4435bd8deadSopenharmony_ci	    o_color0 = color1;
4445bd8deadSopenharmony_ci
4455bd8deadSopenharmony_ci	    for (int i=0; i<16; i++)
4465bd8deadSopenharmony_ci		pix.index[i] = ~pix.index[i] & 3;
4475bd8deadSopenharmony_ci	} else {
4485bd8deadSopenharmony_ci	    o_color0 = color0;
4495bd8deadSopenharmony_ci	    o_color1 = color1;
4505bd8deadSopenharmony_ci	}
4515bd8deadSopenharmony_ci
4525bd8deadSopenharmony_ci	// Save lsb of color1.green in bit125
4535bd8deadSopenharmony_ci	bit125 = o_color1.green & 1;
4545bd8deadSopenharmony_ci
4555bd8deadSopenharmony_ci	// Convert color0 & color1 to RGB555, and then munge into bits 64 to 93
4565bd8deadSopenharmony_ci	o_color0.green >>= 1;
4575bd8deadSopenharmony_ci	o_color1.green >>= 1;
4585bd8deadSopenharmony_ci
4595bd8deadSopenharmony_ci	bits_64_to_93 = ( (o_color1.red<<25) | (o_color1.green<<20) | (o_color1.blue<<15)
4605bd8deadSopenharmony_ci			| (o_color0.red<<10) | (o_color0.green<<5) | (o_color0.blue) );
4615bd8deadSopenharmony_ci
4625bd8deadSopenharmony_ci	// Munge the pixel indices into bits 0 to 31
4635bd8deadSopenharmony_ci	bits_0_to_31 = 0;
4645bd8deadSopenharmony_ci
4655bd8deadSopenharmony_ci	for (int i=0; i<16; i++)
4665bd8deadSopenharmony_ci	    bits_0_to_31 |= pix.index[i]<<(i*2);
4675bd8deadSopenharmony_ci    }
4685bd8deadSopenharmony_ci
4695bd8deadSopenharmony_ci
4705bd8deadSopenharmony_ci    Generating the 4-entry lookup table for texels 31 to 16:
4715bd8deadSopenharmony_ci
4725bd8deadSopenharmony_ci	If alpha[0]=0,
4735bd8deadSopenharmony_ci	    Color[0] = color2[r,g,b] , alpha=ffh
4745bd8deadSopenharmony_ci	    Color[1] = (2 * color2[r,g,b] + color3[r,g,b] + 1) / 3, alpha=ffh
4755bd8deadSopenharmony_ci	    Color[2] = (color2[r,g,b] + 2 * color3[r,g,b] +1) / 3, alpha=ffh
4765bd8deadSopenharmony_ci	    Color[3] = color3[r,g,b], alpha=ffh
4775bd8deadSopenharmony_ci
4785bd8deadSopenharmony_ci	If alpha[0]=1,
4795bd8deadSopenharmony_ci	    Color[0] = color2[r,g,b], alpha=ffh
4805bd8deadSopenharmony_ci	    Color[1] = (color2[r,g,b] + color3[r,g,b]) / 2, alpha=ffh
4815bd8deadSopenharmony_ci	    Color[2] = color3[r,g,b], alpha=ffh
4825bd8deadSopenharmony_ci	    Color[3] = [a,r,g,b] = 00h
4835bd8deadSopenharmony_ci
4845bd8deadSopenharmony_ci    Generating the 4-entry lookup table for texels 15 to 0:
4855bd8deadSopenharmony_ci
4865bd8deadSopenharmony_ci	If alpha[0]=0,
4875bd8deadSopenharmony_ci	    Color[0] = color0[r,g,b] , alpha=ffh
4885bd8deadSopenharmony_ci	    Color[1] = (2 * color0[r,g,b] + color1[r,g,b] + 1) / 3, alpha=ffh
4895bd8deadSopenharmony_ci	    Color[2] = (color0[r,g,b] + 2 * color1[r,g,b] + 1) / 3, alpha=ffh
4905bd8deadSopenharmony_ci	    Color[3] = color1[r,g,b], alpha=ffh
4915bd8deadSopenharmony_ci
4925bd8deadSopenharmony_ci	If alpha[0]=1,
4935bd8deadSopenharmony_ci	    Color[0] = color0[r,g,b], alpha=ffh
4945bd8deadSopenharmony_ci	    Color[1] = (color0[r,g,b] + color1[r,g,b]) / 2, alpha=ffh
4955bd8deadSopenharmony_ci	    Color[2] = color1[r,g,b], alpha=ffh
4965bd8deadSopenharmony_ci	    Color[3] = [a,r,g,b] = 00h
4975bd8deadSopenharmony_ci
4985bd8deadSopenharmony_ci    Table Lookup:
4995bd8deadSopenharmony_ci	      2-bit index of   Color for texel 31 to texel 0
5005bd8deadSopenharmony_ci	 texel 31 to texel 0   ARGB8888
5015bd8deadSopenharmony_ci
5025bd8deadSopenharmony_ci			   0   color[0], {a[7:0], r[7:0], g[7:0], b[7:0]}
5035bd8deadSopenharmony_ci			   1   color[1]
5045bd8deadSopenharmony_ci			   2   color[2]
5055bd8deadSopenharmony_ci			   3   color[3]
5065bd8deadSopenharmony_ci
5075bd8deadSopenharmony_ci
5085bd8deadSopenharmony_ci    4. FXT1 Compressed Texture format CC_ALPHA:
5095bd8deadSopenharmony_ci
5105bd8deadSopenharmony_ci    (argb5555) (2-bit/texel)
5115bd8deadSopenharmony_ci    mode[2:0] lerp alpha2 alpha1 alpha0 color2 color1 color0  texel 31 to 16  texel 15 to 0
5125bd8deadSopenharmony_ci	    3	 1	5      5      5     15	   15	  15		  32		 32
5135bd8deadSopenharmony_ci
5145bd8deadSopenharmony_ci	    [127:125]  mode[2:0]
5155bd8deadSopenharmony_ci		[124]  lerp
5165bd8deadSopenharmony_ci	    [123:119]  color2(a5)
5175bd8deadSopenharmony_ci	    [118:114]  color1(a5)
5185bd8deadSopenharmony_ci	    [113:109]  color0(a5)
5195bd8deadSopenharmony_ci	    [108:104]  color2(r5)
5205bd8deadSopenharmony_ci	     [103:99]  color2(g5)
5215bd8deadSopenharmony_ci	      [98:94]  color2(b5)
5225bd8deadSopenharmony_ci	      [93:89]  color1(r5)
5235bd8deadSopenharmony_ci	      [88:84]  color1(g5)
5245bd8deadSopenharmony_ci	      [83:79]  color1(b5)
5255bd8deadSopenharmony_ci	      [78:74]  color0(r5)
5265bd8deadSopenharmony_ci	      [73:69]  color0(g5)
5275bd8deadSopenharmony_ci	      [68:64]  color0(b5)
5285bd8deadSopenharmony_ci	      [63:62]  texel 31
5295bd8deadSopenharmony_ci		 ...
5305bd8deadSopenharmony_ci	      [33:32]  texel 16
5315bd8deadSopenharmony_ci	      [31:30]  texel 15
5325bd8deadSopenharmony_ci		 ...
5335bd8deadSopenharmony_ci		[1:0]  texel 0
5345bd8deadSopenharmony_ci
5355bd8deadSopenharmony_ci    In CC_ALPHA format, mode[2:0]=011b, three 20-bit colors color2,
5365bd8deadSopenharmony_ci    color1 and color0 (ARGB5555) are converted to a 32-bit (ARGB8888)
5375bd8deadSopenharmony_ci    format by duplicating the upper 3-bits for the 3 LSBs (all the color
5385bd8deadSopenharmony_ci    channels and the alpha channel are converted from 5-bit formats to
5395bd8deadSopenharmony_ci    8-bit formats using this bit duplication).
5405bd8deadSopenharmony_ci
5415bd8deadSopenharmony_ci    Creating the 32-bit (RGB8888) base colors color2, color1, and color0:
5425bd8deadSopenharmony_ci
5435bd8deadSopenharmony_ci	    Color2(alpha) = {[123:119], [123:121]}
5445bd8deadSopenharmony_ci	    Color2(red) = {[108:104], [108:106]}
5455bd8deadSopenharmony_ci	    Color2(green) = {[103:99], [103:101]}
5465bd8deadSopenharmony_ci	    Color2(blue) = {[98:94], [98:96]}
5475bd8deadSopenharmony_ci	    Color1(alpha) = {[118:114], [118:116]}
5485bd8deadSopenharmony_ci	    Color1(red) = {[93:89], [93:91]}
5495bd8deadSopenharmony_ci	    Color1(green) = {[88:84], [88:86]}
5505bd8deadSopenharmony_ci	    Color1(blue) = {[83:79], [83:81]}
5515bd8deadSopenharmony_ci	    Color0(alpha) = {[113:109], [113:111]}
5525bd8deadSopenharmony_ci	    Color0(red) = {[78:74], [78:76]}
5535bd8deadSopenharmony_ci	    Color0(green) = {[73:69], [73:71]}
5545bd8deadSopenharmony_ci	    Color0(blue) = {[68:64], [68:66]}
5555bd8deadSopenharmony_ci
5565bd8deadSopenharmony_ci    When lerp = 0 (bit 124 = 0), the converted 32-bit colors color2,
5575bd8deadSopenharmony_ci    color1, and color0 are used directly as the first 3 entries in the
5585bd8deadSopenharmony_ci    4-entry lookup table. The last entry in the 4-entry lookup table,
5595bd8deadSopenharmony_ci    accessed with index=3, is defined to be transparent black (rgb=00h,
5605bd8deadSopenharmony_ci    alpha=00h). A total of 4 colors are therefore available for 2-bit
5615bd8deadSopenharmony_ci    index per texel selection, and the 32-bit (ARGB8888) color value for
5625bd8deadSopenharmony_ci    all texels is obtained by performing table lookup using each texel's
5635bd8deadSopenharmony_ci    2-bit index.
5645bd8deadSopenharmony_ci
5655bd8deadSopenharmony_ci    Table Lookup (when lerp = 0):
5665bd8deadSopenharmony_ci
5675bd8deadSopenharmony_ci	Index of texel 31 to 0	 Color for texel 31 to texel 0
5685bd8deadSopenharmony_ci				 (ARGB8888)
5695bd8deadSopenharmony_ci
5705bd8deadSopenharmony_ci			     0	  Color[0] = color0 alpha = alpha0
5715bd8deadSopenharmony_ci			     1	  Color[1] = color1 alpha = alpha1
5725bd8deadSopenharmony_ci			     2	  Color[2] = color2 alpha = alpha2
5735bd8deadSopenharmony_ci			     3	  Color[3] = 000000h alpha = 00h
5745bd8deadSopenharmony_ci
5755bd8deadSopenharmony_ci    When lerp = 1 (bit 124 = 1), the converted 32-bit colors color2 and
5765bd8deadSopenharmony_ci    color1 are used as the 32-bit base colors for texels 31 to 16, and
5775bd8deadSopenharmony_ci    the converted 32-bit colors color1 and color0 are used as the base
5785bd8deadSopenharmony_ci    colors for texels 15 to 0. The 32-bit base colors are then used to
5795bd8deadSopenharmony_ci    create 2 more levels of color through linear interpolation. A total
5805bd8deadSopenharmony_ci    of 4 colors are therefore available for 2-bit index per texel
5815bd8deadSopenharmony_ci    selection, and the 32-bit (ARGB8888) color value for all texels is
5825bd8deadSopenharmony_ci    obtained by performing table lookup using each texel's 2-bit index.
5835bd8deadSopenharmony_ci
5845bd8deadSopenharmony_ci    Creating the 4 colors used in the 4-entry lookup table from the
5855bd8deadSopenharmony_ci    32-bit base colors (when lerp = 1):
5865bd8deadSopenharmony_ci
5875bd8deadSopenharmony_ci	For texel 31 to texel 16
5885bd8deadSopenharmony_ci	    Color[0] = color2[a,r,g,b]
5895bd8deadSopenharmony_ci	    Color[1] = (2 * color2[a,r,g,b] + color1[a,r,g,b] + 1) / 3
5905bd8deadSopenharmony_ci	    Color[2] = (color2[a,r,g,b] + 2 * color1[a,r,g,b] +1) / 3
5915bd8deadSopenharmony_ci	    Color[3] = color1[a,r,g,b]
5925bd8deadSopenharmony_ci
5935bd8deadSopenharmony_ci	For texel 15 to texel 0
5945bd8deadSopenharmony_ci	    Color[0] = color0[a,r,g,b]
5955bd8deadSopenharmony_ci	    Color[1] = (2 * color0[a,r,g,b] + color1[a,r,g,b] +1) / 3
5965bd8deadSopenharmony_ci	    Color[2] = (color0[a,r,g,b] + 2 * color1[a,r,g,b] +1) / 3
5975bd8deadSopenharmony_ci	    Color[3] = color1[a,r,g,b]
5985bd8deadSopenharmony_ci
5995bd8deadSopenharmony_ci    Table Lookup (when lerp = 1):
6005bd8deadSopenharmony_ci
6015bd8deadSopenharmony_ci	Index of texel 31 to 0	 Color for texel 31 to texel 0
6025bd8deadSopenharmony_ci				 (ARGB8888)
6035bd8deadSopenharmony_ci
6045bd8deadSopenharmony_ci			     0	 color[0]
6055bd8deadSopenharmony_ci			     1	 color[1]
6065bd8deadSopenharmony_ci			     2	 color[2]
6075bd8deadSopenharmony_ci			     3	 color[3]
6085bd8deadSopenharmony_ci
6095bd8deadSopenharmony_ciRevision History
6105bd8deadSopenharmony_ci
6115bd8deadSopenharmony_ci    0.1,  01/12/00 dwm: Initial revision.
6125bd8deadSopenharmony_ci    0.2,  02/09/00 dwm: Respond to feedback from Intel.
6135bd8deadSopenharmony_ci    0.3,  02/23/00 dwm: Respond to feedback from Intel.
6145bd8deadSopenharmony_ci    0.4,  04/12/00 dwm: Updated to reflect final version of the
6155bd8deadSopenharmony_ci			ARB_texture_compression extension.
6165bd8deadSopenharmony_ci
6175bd8deadSopenharmony_ci
6185bd8deadSopenharmony_ciCopyright 1999-2000, 3dfx Interactive, Inc.
6195bd8deadSopenharmony_ciAll rights reserved.
620