15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci EXT_texture_compression_dxt1 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_EXT_texture_compression_dxt1 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Pat Brown, NVIDIA Corporation 125bd8deadSopenharmony_ci Mathias Agopian, PalmSource, Inc 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciContact 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Norbert Juffa, NVIDIA Corporation (njuffa 'at' nvidia.com) 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciNotice 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Copyright NVIDIA Corporation, 2004. 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciStatus 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci Shipping in an NVIDIA OpenGL ES 1.x implementation 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciVersion 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci 1.0, August 12, 2008 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ciNumber 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ci OpenGL Extension #309 335bd8deadSopenharmony_ci OpenGL ES Extension #49 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ciDependencies 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci OpenGL-ES 1.0 is required. Since OpenGL-ES 1.0 is specified using 385bd8deadSopenharmony_ci the OpenGL 1.3 Specification as a base, this extension references 395bd8deadSopenharmony_ci the OpenGL 1.3 Specification. 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ciOverview 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci Support of EXT_texture_compression_s3tc is attractive for OpenGL-ES 445bd8deadSopenharmony_ci implementations because it provides compressed textures that allow 455bd8deadSopenharmony_ci for significantly reduced texture storage. Reducing texture storage is 465bd8deadSopenharmony_ci advantageous because of the smaller memory capacity of many embedded 475bd8deadSopenharmony_ci systems compared to desktop systems. Smaller textures also provide a 485bd8deadSopenharmony_ci welcome performance advantage since embedded platforms typically provide 495bd8deadSopenharmony_ci less performance than desktop systems. S3TC compressed textures 505bd8deadSopenharmony_ci are widely supported and used by applications. The DXT1 format is 515bd8deadSopenharmony_ci used in the vast majority of cases in which S3TC compressed textures 525bd8deadSopenharmony_ci are used. 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci However, EXT_texture_compression_s3tc specifies functionality that is 555bd8deadSopenharmony_ci burdensome for an OpenGL-ES implementation. In particular it requires 565bd8deadSopenharmony_ci that the driver provide the capability to compress textures into 575bd8deadSopenharmony_ci S3TC texture formats, as an S3TC texture format is accepted as the 585bd8deadSopenharmony_ci <internalformat> parameter of TexImage2D and CopyTexImage2D. Further, 595bd8deadSopenharmony_ci EXT_texture_compression_s3tc may require conversion from one S3TC 605bd8deadSopenharmony_ci format to another during CompressedTexSubImage2D if the <format> 615bd8deadSopenharmony_ci parameter does not match the <internalformat> of the texture image 625bd8deadSopenharmony_ci previously created by TexImage2D. 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ci In an OpenGL-ES implementation it is therefore advantageous to support 655bd8deadSopenharmony_ci a limited subset of EXT_texture_compression_s3tc: Restrict supported 665bd8deadSopenharmony_ci texture formats to DXT1 and restrict supported operations to those 675bd8deadSopenharmony_ci that do not require texture compression into an S3TC texture format or 685bd8deadSopenharmony_ci decompression from an S3TC texture format. 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ciIP Status 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci A license to the S3TC Intellectual Property may be necessary for 735bd8deadSopenharmony_ci implementation of this extension. You should consult with your 745bd8deadSopenharmony_ci Attorney to determine the need for a license. 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ciNew Procedures and Functions 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci None 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ciNew Tokens 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci Accepted by the <internalformat> parameter of CompressedTexImage2D 835bd8deadSopenharmony_ci and the <format> parameter of CompressedTexSubImage2D: 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ci COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 865bd8deadSopenharmony_ci COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci CompressedTexImage2D and CompressedTexSubImage2D are the only 895bd8deadSopenharmony_ci functions that support the S3TC DXT1 texture formats. No other S3TC 905bd8deadSopenharmony_ci texture formats are supported. 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 1.3 Specification (OpenGL Operation) 935bd8deadSopenharmony_ci 945bd8deadSopenharmony_ci None. 955bd8deadSopenharmony_ci 965bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 1.3 Specification (Rasterization) 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci Table 3.17: Specific Compressed Internal Formats 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci Compressed Internal Format Base Internal Format 1015bd8deadSopenharmony_ci ========================== ==================== 1025bd8deadSopenharmony_ci COMPRESSED_RGB_S3TC_DXT1_EXT RGB 1035bd8deadSopenharmony_ci COMPRESSED_RGBA_S3TC_DXT1_EXT RGBA 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci Add to Section 3.8.3, Compressed Texture Images 1075bd8deadSopenharmony_ci (add to the end of the CompressedTexImage section) 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ci If <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT or 1105bd8deadSopenharmony_ci COMPRESSED_RGBA_S3TC_DXT1_EXT, the compressed texture is stored 1115bd8deadSopenharmony_ci in one of these two S3TC texture formats. OpenGL-ES 1.0 and the S3TC 1125bd8deadSopenharmony_ci texture compression algorithm support only 2D images without borders. 1135bd8deadSopenharmony_ci CompressedTexImage2D will produce an INVALID_OPERATION error if 1145bd8deadSopenharmony_ci <border> is non-zero, according to the OpenGL-ES 1.0 Specification. 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci Add to Section 3.8.3, Compressed Texture Images 1175bd8deadSopenharmony_ci (add to the end of the CompressedTexSubImage section) 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ci If the internal format of the texture image being modified is 1205bd8deadSopenharmony_ci COMPRESSED_RGB_S3TC_DXT1_EXT or COMPRESSED_RGBA_S3TC_DXT1_EXT, the 1215bd8deadSopenharmony_ci texture is stored using one of these two S3TC compressed texture image 1225bd8deadSopenharmony_ci formats. OpenGL-ES 1.0 only supports CompressedTexSubImage2D. 1235bd8deadSopenharmony_ci Since DXT1 images are easily edited along 4x4 texel boundaries, 1245bd8deadSopenharmony_ci the limitations on CompressedTexSubImage2D are relaxed. 1255bd8deadSopenharmony_ci CompressedTexSubImage2D will result in an INVALID_OPERATION error only 1265bd8deadSopenharmony_ci if one of the following conditions occurs: 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci * <width> is not a multiple of four or equal to TEXTURE_WIDTH. 1295bd8deadSopenharmony_ci * <height> is not a multiple of four or equal to TEXTURE_HEIGHT. 1305bd8deadSopenharmony_ci * <xoffset> or <yoffset> is not a multiple of four. 1315bd8deadSopenharmony_ci * <format> does not match the internal format of the texture image 1325bd8deadSopenharmony_ci being modified. 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci The following restrictions at the end of section 3.8.3 of the 1355bd8deadSopenharmony_ci OpenGL 1.3 Specification do not apply to S3TC DXT1 texture formats, 1365bd8deadSopenharmony_ci since subimage modification is straightforward as long as the subimage 1375bd8deadSopenharmony_ci is properly aligned. 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ci DELETE: Calling CompressedTexSubImage3D, CompressedTexSubImage2D, 1405bd8deadSopenharmony_ci DELETE: or CompressedTexSubImage1D will result in an INVALID 1415bd8deadSopenharmony_ci DELETE: OPERATION error if xoffset, yoffset, or zoffset is not 1425bd8deadSopenharmony_ci DELETE: equal to -b (border width), or if <width>, <height>, and 1435bd8deadSopenharmony_ci DELETE: <depth> do not mathc the values of TEXTURE_WIDTH, 1445bd8deadSopenharmony_ci DELETE: TEXTURE_HEIGHT, or TEXTURE_DEPTH, respectively. The contents 1455bd8deadSopenharmony_ci DELETE: of any texel outside the region modified by the call are 1465bd8deadSopenharmony_ci DELETE: undefined. 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 1.3 Specification (Per-Fragment 1495bd8deadSopenharmony_ciOperations and the Frame Buffer) 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci None. 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.3 Specification (Special Functions) 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci None. 1565bd8deadSopenharmony_ci 1575bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.3 Specification (State and State 1585bd8deadSopenharmony_ciRequests) 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ci None. 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ciAdditions to Appendices A through G of the OpenGL 1.3 Specification 1635bd8deadSopenharmony_ci 1645bd8deadSopenharmony_ci None. 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ciAdditions to the EGL Specifications 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci None. 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ciErrors 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci INVALID_OPERATION is generated by CompressedTexImage2D if 1735bd8deadSopenharmony_ci <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT or 1745bd8deadSopenharmony_ci COMPRESSED_RGBA_S3TC_DXT1_EXT and <border> is not equal to zero. 1755bd8deadSopenharmony_ci OpenGL-ES 1.0 does not support non-zero borders. 1765bd8deadSopenharmony_ci 1775bd8deadSopenharmony_ci INVALID_OPERATION is generated by TexImage2D and CopyTexImage2D 1785bd8deadSopenharmony_ci if <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT or 1795bd8deadSopenharmony_ci COMPRESSED_RGBA_S3TC_DXT1_EXT. 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci INVALID_OPERATION is generated by TexSubImage2D and CopyTexSubImage2D 1825bd8deadSopenharmony_ci if the internal format of the texture currently bound to <target> is 1835bd8deadSopenharmony_ci COMPRESSED_RGB_S3TC_DXT1_EXT or COMPRESSED_RGBA_S3TC_DXT1_EXT. 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ci INVALID_OPERATION is generated by CompressedTexSubImage2D if <format> 1865bd8deadSopenharmony_ci is COMPRESSED_RGB_S3TC_DXT1_EXT or COMPRESSED_RGBA_S3TC_DXT1_EXT and 1875bd8deadSopenharmony_ci any of the following apply: 1885bd8deadSopenharmony_ci <width> is not a multiple of four or equal to TEXTURE_WIDTH; 1895bd8deadSopenharmony_ci <height> is not a multiple of four or equal to TEXTURE_HEIGHT; 1905bd8deadSopenharmony_ci <xoffset> or <yoffset> is not a multiple of four; 1915bd8deadSopenharmony_ci <format> does not match the internal format of the texture image 1925bd8deadSopenharmony_ci being modified. 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ciAppendix: 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci S3TC DXT1 Compressed Texture Image Formats 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci Compressed texture images stored using the S3TC compressed image formats 1995bd8deadSopenharmony_ci are represented as a collection of 4x4 texel blocks, where each block 2005bd8deadSopenharmony_ci contains 64 or 128 bits of texel data. The image is encoded as a normal 2015bd8deadSopenharmony_ci 2D raster image in which each 4x4 block is treated as a single pixel. If 2025bd8deadSopenharmony_ci an S3TC image has a width or height less than four, the data corresponding 2035bd8deadSopenharmony_ci to texels outside the image are irrelevant and undefined. 2045bd8deadSopenharmony_ci 2055bd8deadSopenharmony_ci When an S3TC image with a width of <w>, height of <h>, and block size of 2065bd8deadSopenharmony_ci <blocksize> (8 or 16 bytes) is decoded, the corresponding image size (in 2075bd8deadSopenharmony_ci bytes) is: 2085bd8deadSopenharmony_ci 2095bd8deadSopenharmony_ci ceil(<w>/4) * ceil(<h>/4) * blocksize. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci When decoding an S3TC image, the block containing the texel at offset 2125bd8deadSopenharmony_ci (<x>, <y>) begins at an offset (in bytes) relative to the base of the 2135bd8deadSopenharmony_ci image of: 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci blocksize * (ceil(<w>/4) * floor(<y>/4) + floor(<x>/4)). 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci The data corresponding to a specific texel (<x>, <y>) are extracted from a 2185bd8deadSopenharmony_ci 4x4 texel block using a relative (x,y) value of 2195bd8deadSopenharmony_ci 2205bd8deadSopenharmony_ci (<x> modulo 4, <y> modulo 4). 2215bd8deadSopenharmony_ci 2225bd8deadSopenharmony_ci There are four distinct S3TC image formats: 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci COMPRESSED_RGB_S3TC_DXT1_EXT: Each 4x4 block of texels consists of 64 2255bd8deadSopenharmony_ci bits of RGB image data. 2265bd8deadSopenharmony_ci 2275bd8deadSopenharmony_ci Each RGB image data block is encoded as a sequence of 8 bytes, called (in 2285bd8deadSopenharmony_ci order of increasing address): 2295bd8deadSopenharmony_ci 2305bd8deadSopenharmony_ci c0_lo, c0_hi, c1_lo, c1_hi, bits_0, bits_1, bits_2, bits_3 2315bd8deadSopenharmony_ci 2325bd8deadSopenharmony_ci The 8 bytes of the block are decoded into three quantities: 2335bd8deadSopenharmony_ci 2345bd8deadSopenharmony_ci color0 = c0_lo + c0_hi * 256 2355bd8deadSopenharmony_ci color1 = c1_lo + c1_hi * 256 2365bd8deadSopenharmony_ci bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * bits_3)) 2375bd8deadSopenharmony_ci 2385bd8deadSopenharmony_ci color0 and color1 are 16-bit unsigned integers that are unpacked to 2395bd8deadSopenharmony_ci RGB colors RGB0 and RGB1 as though they were 16-bit packed pixels with 2405bd8deadSopenharmony_ci a <format> of RGB and a type of UNSIGNED_SHORT_5_6_5. 2415bd8deadSopenharmony_ci 2425bd8deadSopenharmony_ci bits is a 32-bit unsigned integer, from which a two-bit control code 2435bd8deadSopenharmony_ci is extracted for a texel at location (x,y) in the block using: 2445bd8deadSopenharmony_ci 2455bd8deadSopenharmony_ci code(x,y) = bits[2*(4*y+x)+1..2*(4*y+x)+0] 2465bd8deadSopenharmony_ci 2475bd8deadSopenharmony_ci where bit 31 is the most significant and bit 0 is the least 2485bd8deadSopenharmony_ci significant bit. 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ci The RGB color for a texel at location (x,y) in the block is given by: 2515bd8deadSopenharmony_ci 2525bd8deadSopenharmony_ci RGB0, if color0 > color1 and code(x,y) == 0 2535bd8deadSopenharmony_ci RGB1, if color0 > color1 and code(x,y) == 1 2545bd8deadSopenharmony_ci (2*RGB0+RGB1)/3, if color0 > color1 and code(x,y) == 2 2555bd8deadSopenharmony_ci (RGB0+2*RGB1)/3, if color0 > color1 and code(x,y) == 3 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci RGB0, if color0 <= color1 and code(x,y) == 0 2585bd8deadSopenharmony_ci RGB1, if color0 <= color1 and code(x,y) == 1 2595bd8deadSopenharmony_ci (RGB0+RGB1)/2, if color0 <= color1 and code(x,y) == 2 2605bd8deadSopenharmony_ci BLACK, if color0 <= color1 and code(x,y) == 3 2615bd8deadSopenharmony_ci 2625bd8deadSopenharmony_ci Arithmetic operations are done per component, and BLACK refers to an 2635bd8deadSopenharmony_ci RGB color where red, green, and blue are all zero. 2645bd8deadSopenharmony_ci 2655bd8deadSopenharmony_ci Since this image has an RGB format, there is no alpha component and the 2665bd8deadSopenharmony_ci image is considered fully opaque. 2675bd8deadSopenharmony_ci 2685bd8deadSopenharmony_ci 2695bd8deadSopenharmony_ci COMPRESSED_RGBA_S3TC_DXT1_EXT: Each 4x4 block of texels consists of 64 2705bd8deadSopenharmony_ci bits of RGB image data and minimal alpha information. The RGB components 2715bd8deadSopenharmony_ci of a texel are extracted in the same way as COMPRESSED_RGB_S3TC_DXT1_EXT. 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci The alpha component for a texel at location (x,y) in the block is 2745bd8deadSopenharmony_ci given by: 2755bd8deadSopenharmony_ci 2765bd8deadSopenharmony_ci 0.0, if color0 <= color1 and code(x,y) == 3 2775bd8deadSopenharmony_ci 1.0, otherwise 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci IMPORTANT: When encoding an RGBA image into a format using 1-bit 2805bd8deadSopenharmony_ci alpha, any texels with an alpha component less than 0.5 end up with an 2815bd8deadSopenharmony_ci alpha of 0.0 and any texels with an alpha component greater than or 2825bd8deadSopenharmony_ci equal to 0.5 end up with an alpha of 1.0. When encoding an RGBA image 2835bd8deadSopenharmony_ci into the COMPRESSED_RGBA_S3TC_DXT1_EXT format, the resulting red, 2845bd8deadSopenharmony_ci green, and blue components of any texels with a final alpha of 0.0 2855bd8deadSopenharmony_ci will automatically be zero (black). If this behavior is not desired 2865bd8deadSopenharmony_ci by an application, it should not use COMPRESSED_RGBA_S3TC_DXT1_EXT. 2875bd8deadSopenharmony_ci This format will never be used when a generic compressed internal 2885bd8deadSopenharmony_ci format (Table 3.16.2) is specified, although the nearly identical 2895bd8deadSopenharmony_ci format COMPRESSED_RGB_S3TC_DXT1_EXT (above) may be. 2905bd8deadSopenharmony_ci 2915bd8deadSopenharmony_ci 2925bd8deadSopenharmony_ciRevision History 2935bd8deadSopenharmony_ci 2945bd8deadSopenharmony_ci 1.0, 08/12/08 jleech: Move out of draft status as NVIDIA has 2955bd8deadSopenharmony_ci verified a shipping implementation. 2965bd8deadSopenharmony_ci 0.6, 08/07/08 jleech: Assigned OpenGL ES extension number so the 2975bd8deadSopenharmony_ci extension can live in both API registries. 2985bd8deadSopenharmony_ci 0.5, 09/24/04 njuffa: Added contributors section. Changed name to 2995bd8deadSopenharmony_ci EXT_texture_compression_dxt1 3005bd8deadSopenharmony_ci 0.4, 09/23/04 njuffa: Extension no longer specified as a delta to 3015bd8deadSopenharmony_ci EXT_texture_compression_s3tc 3025bd8deadSopenharmony_ci 0.3, 03/12/04 njuffa: Added section IP Status 3035bd8deadSopenharmony_ci 0.2, 03/04/04 njuffa: Extension name modification; clarification of 3045bd8deadSopenharmony_ci error generation conditions 3055bd8deadSopenharmony_ci 0.1, 02/13/04 njuffa: Initial revision 306