1Name 2 3 EXT_texture_compression_dxt1 4 5Name Strings 6 7 GL_EXT_texture_compression_dxt1 8 9Contributors 10 11 Pat Brown, NVIDIA Corporation 12 Mathias Agopian, PalmSource, Inc 13 14Contact 15 16 Norbert Juffa, NVIDIA Corporation (njuffa 'at' nvidia.com) 17 18Notice 19 20 Copyright NVIDIA Corporation, 2004. 21 22Status 23 24 Shipping in an NVIDIA OpenGL ES 1.x implementation 25 26Version 27 28 1.0, August 12, 2008 29 30Number 31 32 OpenGL Extension #309 33 OpenGL ES Extension #49 34 35Dependencies 36 37 OpenGL-ES 1.0 is required. Since OpenGL-ES 1.0 is specified using 38 the OpenGL 1.3 Specification as a base, this extension references 39 the OpenGL 1.3 Specification. 40 41Overview 42 43 Support of EXT_texture_compression_s3tc is attractive for OpenGL-ES 44 implementations because it provides compressed textures that allow 45 for significantly reduced texture storage. Reducing texture storage is 46 advantageous because of the smaller memory capacity of many embedded 47 systems compared to desktop systems. Smaller textures also provide a 48 welcome performance advantage since embedded platforms typically provide 49 less performance than desktop systems. S3TC compressed textures 50 are widely supported and used by applications. The DXT1 format is 51 used in the vast majority of cases in which S3TC compressed textures 52 are used. 53 54 However, EXT_texture_compression_s3tc specifies functionality that is 55 burdensome for an OpenGL-ES implementation. In particular it requires 56 that the driver provide the capability to compress textures into 57 S3TC texture formats, as an S3TC texture format is accepted as the 58 <internalformat> parameter of TexImage2D and CopyTexImage2D. Further, 59 EXT_texture_compression_s3tc may require conversion from one S3TC 60 format to another during CompressedTexSubImage2D if the <format> 61 parameter does not match the <internalformat> of the texture image 62 previously created by TexImage2D. 63 64 In an OpenGL-ES implementation it is therefore advantageous to support 65 a limited subset of EXT_texture_compression_s3tc: Restrict supported 66 texture formats to DXT1 and restrict supported operations to those 67 that do not require texture compression into an S3TC texture format or 68 decompression from an S3TC texture format. 69 70IP Status 71 72 A license to the S3TC Intellectual Property may be necessary for 73 implementation of this extension. You should consult with your 74 Attorney to determine the need for a license. 75 76New Procedures and Functions 77 78 None 79 80New Tokens 81 82 Accepted by the <internalformat> parameter of CompressedTexImage2D 83 and the <format> parameter of CompressedTexSubImage2D: 84 85 COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 86 COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 87 88 CompressedTexImage2D and CompressedTexSubImage2D are the only 89 functions that support the S3TC DXT1 texture formats. No other S3TC 90 texture formats are supported. 91 92Additions to Chapter 2 of the OpenGL 1.3 Specification (OpenGL Operation) 93 94 None. 95 96Additions to Chapter 3 of the OpenGL 1.3 Specification (Rasterization) 97 98 Table 3.17: Specific Compressed Internal Formats 99 100 Compressed Internal Format Base Internal Format 101 ========================== ==================== 102 COMPRESSED_RGB_S3TC_DXT1_EXT RGB 103 COMPRESSED_RGBA_S3TC_DXT1_EXT RGBA 104 105 106 Add to Section 3.8.3, Compressed Texture Images 107 (add to the end of the CompressedTexImage section) 108 109 If <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT or 110 COMPRESSED_RGBA_S3TC_DXT1_EXT, the compressed texture is stored 111 in one of these two S3TC texture formats. OpenGL-ES 1.0 and the S3TC 112 texture compression algorithm support only 2D images without borders. 113 CompressedTexImage2D will produce an INVALID_OPERATION error if 114 <border> is non-zero, according to the OpenGL-ES 1.0 Specification. 115 116 Add to Section 3.8.3, Compressed Texture Images 117 (add to the end of the CompressedTexSubImage section) 118 119 If the internal format of the texture image being modified is 120 COMPRESSED_RGB_S3TC_DXT1_EXT or COMPRESSED_RGBA_S3TC_DXT1_EXT, the 121 texture is stored using one of these two S3TC compressed texture image 122 formats. OpenGL-ES 1.0 only supports CompressedTexSubImage2D. 123 Since DXT1 images are easily edited along 4x4 texel boundaries, 124 the limitations on CompressedTexSubImage2D are relaxed. 125 CompressedTexSubImage2D will result in an INVALID_OPERATION error only 126 if one of the following conditions occurs: 127 128 * <width> is not a multiple of four or equal to TEXTURE_WIDTH. 129 * <height> is not a multiple of four or equal to TEXTURE_HEIGHT. 130 * <xoffset> or <yoffset> is not a multiple of four. 131 * <format> does not match the internal format of the texture image 132 being modified. 133 134 The following restrictions at the end of section 3.8.3 of the 135 OpenGL 1.3 Specification do not apply to S3TC DXT1 texture formats, 136 since subimage modification is straightforward as long as the subimage 137 is properly aligned. 138 139 DELETE: Calling CompressedTexSubImage3D, CompressedTexSubImage2D, 140 DELETE: or CompressedTexSubImage1D will result in an INVALID 141 DELETE: OPERATION error if xoffset, yoffset, or zoffset is not 142 DELETE: equal to -b (border width), or if <width>, <height>, and 143 DELETE: <depth> do not mathc the values of TEXTURE_WIDTH, 144 DELETE: TEXTURE_HEIGHT, or TEXTURE_DEPTH, respectively. The contents 145 DELETE: of any texel outside the region modified by the call are 146 DELETE: undefined. 147 148Additions to Chapter 4 of the OpenGL 1.3 Specification (Per-Fragment 149Operations and the Frame Buffer) 150 151 None. 152 153Additions to Chapter 5 of the OpenGL 1.3 Specification (Special Functions) 154 155 None. 156 157Additions to Chapter 6 of the OpenGL 1.3 Specification (State and State 158Requests) 159 160 None. 161 162Additions to Appendices A through G of the OpenGL 1.3 Specification 163 164 None. 165 166Additions to the EGL Specifications 167 168 None. 169 170Errors 171 172 INVALID_OPERATION is generated by CompressedTexImage2D if 173 <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT or 174 COMPRESSED_RGBA_S3TC_DXT1_EXT and <border> is not equal to zero. 175 OpenGL-ES 1.0 does not support non-zero borders. 176 177 INVALID_OPERATION is generated by TexImage2D and CopyTexImage2D 178 if <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT or 179 COMPRESSED_RGBA_S3TC_DXT1_EXT. 180 181 INVALID_OPERATION is generated by TexSubImage2D and CopyTexSubImage2D 182 if the internal format of the texture currently bound to <target> is 183 COMPRESSED_RGB_S3TC_DXT1_EXT or COMPRESSED_RGBA_S3TC_DXT1_EXT. 184 185 INVALID_OPERATION is generated by CompressedTexSubImage2D if <format> 186 is COMPRESSED_RGB_S3TC_DXT1_EXT or COMPRESSED_RGBA_S3TC_DXT1_EXT and 187 any of the following apply: 188 <width> is not a multiple of four or equal to TEXTURE_WIDTH; 189 <height> is not a multiple of four or equal to TEXTURE_HEIGHT; 190 <xoffset> or <yoffset> is not a multiple of four; 191 <format> does not match the internal format of the texture image 192 being modified. 193 194Appendix: 195 196 S3TC DXT1 Compressed Texture Image Formats 197 198 Compressed texture images stored using the S3TC compressed image formats 199 are represented as a collection of 4x4 texel blocks, where each block 200 contains 64 or 128 bits of texel data. The image is encoded as a normal 201 2D raster image in which each 4x4 block is treated as a single pixel. If 202 an S3TC image has a width or height less than four, the data corresponding 203 to texels outside the image are irrelevant and undefined. 204 205 When an S3TC image with a width of <w>, height of <h>, and block size of 206 <blocksize> (8 or 16 bytes) is decoded, the corresponding image size (in 207 bytes) is: 208 209 ceil(<w>/4) * ceil(<h>/4) * blocksize. 210 211 When decoding an S3TC image, the block containing the texel at offset 212 (<x>, <y>) begins at an offset (in bytes) relative to the base of the 213 image of: 214 215 blocksize * (ceil(<w>/4) * floor(<y>/4) + floor(<x>/4)). 216 217 The data corresponding to a specific texel (<x>, <y>) are extracted from a 218 4x4 texel block using a relative (x,y) value of 219 220 (<x> modulo 4, <y> modulo 4). 221 222 There are four distinct S3TC image formats: 223 224 COMPRESSED_RGB_S3TC_DXT1_EXT: Each 4x4 block of texels consists of 64 225 bits of RGB image data. 226 227 Each RGB image data block is encoded as a sequence of 8 bytes, called (in 228 order of increasing address): 229 230 c0_lo, c0_hi, c1_lo, c1_hi, bits_0, bits_1, bits_2, bits_3 231 232 The 8 bytes of the block are decoded into three quantities: 233 234 color0 = c0_lo + c0_hi * 256 235 color1 = c1_lo + c1_hi * 256 236 bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * bits_3)) 237 238 color0 and color1 are 16-bit unsigned integers that are unpacked to 239 RGB colors RGB0 and RGB1 as though they were 16-bit packed pixels with 240 a <format> of RGB and a type of UNSIGNED_SHORT_5_6_5. 241 242 bits is a 32-bit unsigned integer, from which a two-bit control code 243 is extracted for a texel at location (x,y) in the block using: 244 245 code(x,y) = bits[2*(4*y+x)+1..2*(4*y+x)+0] 246 247 where bit 31 is the most significant and bit 0 is the least 248 significant bit. 249 250 The RGB color for a texel at location (x,y) in the block is given by: 251 252 RGB0, if color0 > color1 and code(x,y) == 0 253 RGB1, if color0 > color1 and code(x,y) == 1 254 (2*RGB0+RGB1)/3, if color0 > color1 and code(x,y) == 2 255 (RGB0+2*RGB1)/3, if color0 > color1 and code(x,y) == 3 256 257 RGB0, if color0 <= color1 and code(x,y) == 0 258 RGB1, if color0 <= color1 and code(x,y) == 1 259 (RGB0+RGB1)/2, if color0 <= color1 and code(x,y) == 2 260 BLACK, if color0 <= color1 and code(x,y) == 3 261 262 Arithmetic operations are done per component, and BLACK refers to an 263 RGB color where red, green, and blue are all zero. 264 265 Since this image has an RGB format, there is no alpha component and the 266 image is considered fully opaque. 267 268 269 COMPRESSED_RGBA_S3TC_DXT1_EXT: Each 4x4 block of texels consists of 64 270 bits of RGB image data and minimal alpha information. The RGB components 271 of a texel are extracted in the same way as COMPRESSED_RGB_S3TC_DXT1_EXT. 272 273 The alpha component for a texel at location (x,y) in the block is 274 given by: 275 276 0.0, if color0 <= color1 and code(x,y) == 3 277 1.0, otherwise 278 279 IMPORTANT: When encoding an RGBA image into a format using 1-bit 280 alpha, any texels with an alpha component less than 0.5 end up with an 281 alpha of 0.0 and any texels with an alpha component greater than or 282 equal to 0.5 end up with an alpha of 1.0. When encoding an RGBA image 283 into the COMPRESSED_RGBA_S3TC_DXT1_EXT format, the resulting red, 284 green, and blue components of any texels with a final alpha of 0.0 285 will automatically be zero (black). If this behavior is not desired 286 by an application, it should not use COMPRESSED_RGBA_S3TC_DXT1_EXT. 287 This format will never be used when a generic compressed internal 288 format (Table 3.16.2) is specified, although the nearly identical 289 format COMPRESSED_RGB_S3TC_DXT1_EXT (above) may be. 290 291 292Revision History 293 294 1.0, 08/12/08 jleech: Move out of draft status as NVIDIA has 295 verified a shipping implementation. 296 0.6, 08/07/08 jleech: Assigned OpenGL ES extension number so the 297 extension can live in both API registries. 298 0.5, 09/24/04 njuffa: Added contributors section. Changed name to 299 EXT_texture_compression_dxt1 300 0.4, 09/23/04 njuffa: Extension no longer specified as a delta to 301 EXT_texture_compression_s3tc 302 0.3, 03/12/04 njuffa: Added section IP Status 303 0.2, 03/04/04 njuffa: Extension name modification; clarification of 304 error generation conditions 305 0.1, 02/13/04 njuffa: Initial revision 306