1Name 2 3 NV_texture_compression_vtc 4 5Name Strings 6 7 GL_NV_texture_compression_vtc 8 9Contact 10 11 Matt Craighead, NVIDIA Corporation (mcraighead 'at' nvidia.com) 12 13Notice 14 15 Copyright NVIDIA Corporation, 2000, 2001, 2004. 16 17IP Status 18 19 NVIDIA Proprietary. 20 21Version 22 23 NVIDIA Date: June 3, 2004 24 Version: 4 25 26Number 27 28 228 29 30Dependencies 31 32 Written based on the wording of the OpenGL 1.2.1 specification. 33 34 ARB_texture_compression is required. 35 36 EXT_texture_compression_s3tc is required. 37 38 ARB_texture_non_power_of_two interacts with this extension. 39 40Overview 41 42 This extension adds support for the VTC 3D texture compression 43 formats, which are analogous to the S3TC texture compression formats, 44 with the addition of some retiling in the Z direction. VTC has the 45 same compression ratio as S3TC and uses 4x4x1, 4x4x2, (4x4x3 when 46 non-power-of-two textures are supported), or 4x4x4 blocks. 47 48Issues 49 50 * Should the enumerants' (1) values and (2) names be reused from 51 the S3TC extension? 52 53 RESOLVED: Yes and yes. There is such a close correspondence 54 between the formats that introducing new values or names would 55 serve no purpose. 56 57 * Should the block alignment restrictions differ in any way from 58 the block alignment restrictions in the S3TC extension? 59 60 RESOLVED: No, except for the addition of the Z-direction block 61 alignment restriction for CompressedTexSubImage3D, which is 62 analogous to the X and Y restrictions. 63 64 * Should VTC compression work with the ARB_texture_non_power_of_two 65 functionality? 66 67 RESOLVED: Yes. The blockIndex computation works for 68 non-power-of-two width, height, and depth dimensions. 69 70 Consider a 31x25x11 3D texture to be stored using VTC. 71 The initial 31x25x8 portion of the volume is bricked up using 72 VTC with 4x4x4 blocks where the 31x25 dimensions are rounded 73 up to 32x28. Following the expanded 32x28x8 initial volume are 74 the final texels arranged as 32x28x3 with 4x4x3 blocks. 75 76New Procedures and Functions 77 78 None. 79 80New Tokens 81 82 Accepted by the <internalformat> parameter of TexImage3D and 83 CompressedTexImage3DARB and the <format> parameter of 84 CompressedTexSubImage2DARB: 85 86 COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 87 COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 88 COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 89 COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 90 91Additions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation) 92 93 None. 94 95Additions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization) 96 97 Modify the paragraph added to the end of the TexSubImage discussion 98 (page 123) by EXT_texture_compression_s3tc to say: 99 100 "If the internal format of the texture image being modified is 101 COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT, 102 COMPRESSED_RGBA_S3TC_DXT3_EXT, or COMPRESSED_RGBA_S3TC_DXT5_EXT, the 103 texture is stored using one of several S3TC or VTC compressed texture 104 image formats. Such images are easily edited along 4x4 texel 105 boundaries, so the limitations on TexSubImage2D, TexSubImage3D, 106 CopyTexSubImage2D, and CopyTexSubImage3D parameters are relaxed. 107 These commands will result in an INVALID_OPERATION error only if one 108 of the following conditions occurs: 109 110 * <width> is not a multiple of four or equal to TEXTURE_WIDTH. 111 * <height> is not a multiple of four or equal to TEXTURE_HEIGHT. 112 * <xoffset> or <yoffset> is not a multiple of four." 113 114 Modify the paragraph added to Section 3.8.2 "Alternate Image 115 Specification" at the end of the CompressedTexImage section by 116 EXT_texture_compression_s3tc to say: 117 118 "If <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT, 119 COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or 120 COMPRESSED_RGBA_S3TC_DXT5_EXT, the compressed texture is stored using 121 one of several S3TC or VTC compressed texture image formats. The 122 S3TC texture compression algorithm supports only 2D images without 123 borders, while the VTC texture compression algorithm supports only 124 3D images without borders. CompressedTexImage1DARB produces an 125 INVALID_ENUM error if <internalformat> is an S3TC/VTC format. 126 CompressedTexImage2DARB and CompressedTexImage3DARB will produce an 127 INVALID_OPERATION error if <border> is non-zero." 128 129 Modify the paragraph added to Section 3.8.2 "Alternate Image 130 Specification" at the end of the CompressedTexSubImage section by 131 EXT_texture_compression_s3tc to say: 132 133 "If the internal format of the texture image being modified is 134 COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT, 135 COMPRESSED_RGBA_S3TC_DXT3_EXT, or COMPRESSED_RGBA_S3TC_DXT5_EXT, the 136 texture is stored using one of several S3TC or VTC compressed texture 137 image formats. Since these algorithms support only 2D and 3D images, 138 CompressedTexSubImage1DARB produces an INVALID_ENUM error if <format> 139 is an S3TC/VTC format. Since S3TC/VTC images are easily edited along 140 4x4 and 4x4x4 texel boundaries, the limitations on 141 CompressedTexSubImage2D and CompressedTexSubImage3D are relaxed. 142 CompressedTexSubImage2D and CompressedTexSubImage3D will result in an 143 INVALID_OPERATION error only if one of the following conditions 144 occurs: 145 146 * <width> is not a multiple of four or equal to TEXTURE_WIDTH. 147 * <height> is not a multiple of four or equal to TEXTURE_HEIGHT. 148 * <depth> is not a multiple of four or equal to TEXTURE_DEPTH. 149 * <xoffset>, <yoffset>, or <zoffset> is not a multiple of four." 150 151Additions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment 152Operations and the Frame Buffer) 153 154 None. 155 156Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions) 157 158 None. 159 160Additions to Chapter 6 of the OpenGL 1.2.1 Specification (State and 161State Requests) 162 163 None. 164 165Additions to Appendix A of the OpenGL 1.2.1 Specification (Invariance) 166 167 None. 168 169Dependencies on ARB_texture_non_power_of_two 170 171 There are no explicit dependencies on ARB_texture_non_power_of_two 172 but the Appendix language is compatible with non-power-of-two 173 texture sizes. 4x4x3 blocks are not possible if texture sizes are 174 restricted to power-of-two values. 175 176GLX Protocol 177 178 None. 179 180Errors 181 182 The INVALID_ENUM error that was generated by CompressedTexImage3DARB 183 if <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT, 184 COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or 185 COMPRESSED_RGBA_S3TC_DXT5_EXT no longer occurs. 186 187 INVALID_OPERATION is generated by CompressedTexImage3DARB if 188 <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT, 189 COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or 190 COMPRESSED_RGBA_S3TC_DXT5_EXT and <border> is not equal to zero. 191 192 The INVALID_ENUM error that was generated by 193 CompressedTexSubImage3DARB if <format> is 194 COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT, 195 COMPRESSED_RGBA_S3TC_DXT3_EXT, or COMPRESSED_RGBA_S3TC_DXT5_EXT no 196 longer occurs. 197 198 INVALID_OPERATION is generated by TexSubImage3D or 199 CopyTexSubImage3D if INTERNAL_FORMAT is COMPRESSED_RGB_S3TC_DXT1_EXT, 200 COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or 201 COMPRESSED_RGBA_S3TC_DXT5_EXT and any of the following apply: <width> 202 is not a multiple of four or equal to TEXTURE_WIDTH; <height> is not 203 a multiple of four or equal to TEXTURE_HEIGHT; <xoffset> or <yoffset> 204 is not a multiple of four. 205 206 INVALID_OPERATION is generated by CompressedTexSubImage3D 207 if INTERNAL_FORMAT is COMPRESSED_RGB_S3TC_DXT1_EXT, 208 COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, 209 or COMPRESSED_RGBA_S3TC_DXT5_EXT and any of the following apply: 210 <width> is not a multiple of four or equal to TEXTURE_WIDTH; <height> 211 is not a multiple of four or equal to TEXTURE_HEIGHT; <depth> is not 212 a multiple of four or equal to TEXTURE_DEPTH; <xoffset> <yoffset>, 213 or <zoffset> is not a multiple of four. 214 215 See also errors in the GL_ARB_texture_compression and 216 GL_EXT_texture_compression_s3tc specifications. 217 218New State 219 220 None. 221 222Appendix 223 224 VTC Compressed Texture Image Formats 225 226 Each VTC compression format is similar to a corresponding S3TC 227 compression format, but where an S3TC block encodes a 4x4 block of 228 texels, a VTC block encodes a 4x4x1, 4x4x2, or 4x4x4 (or 4x4x3 if 229 non-power-of-two textures are supported) block of texels. If the 230 depth of the image is four or greater, 4x4x4 blocks are used, and 231 if the depth is 1 or 2, 4x4x1 or 4x4x2 blocks are used. 232 233 (If non-power-of-two textures are supported and the depth of the 234 texture is not a multiple 4, the excess texels in depth after 4x4x4 235 blocks are arranged are stored with 4x4x1, 4x4x2, or 4x4x3 blocks 236 as necessary to complete the texture.) 237 238 The size in bytes of a VTC image with dimensions w, h, and d is: 239 240 ceil(w/4) * ceil(h/4) * d * blocksize, 241 242 where blocksize is the size of an analogous 4x4 S3TC block and is 243 either 8 or 16 bytes. 244 245 The block containing a texel at location (x,y,z) starts at an offset 246 inside the image of blockIndex bytes where blockIndex is computed 247 as follows: 248 249 if (z >= 4*floor(d/4)) { 250 blockIndex = blocksize * (ceil(w/4) * ceil(h/4) * 4*floor(d/4) + 251 floor(x/4) + 252 ceil(w/4) * (floor(y/4) + 253 ceil(h/4) * (z-4*floor(d/4)) )); 254 } else { 255 blockIndex = blocksize * 4 * (floor(x/4) + 256 ceil(w/4) * (floor(y/4) + 257 ceil(h/4) * floor(z/4))); 258 } 259 260 These two observations about subexpressions in the above computation 261 are useful: 262 263 4*floor(d/4) == d & ~0x3 264 265 when z > 4*floor(d/4) and z < d, z-4*floor(d/4) == z & 0x3 266 267 A 4x4x1 block of each of the four formats is stored in exactly the 268 same way that a 4x4 block of the analogous S3TC format is stored. 269 270 A 4x4x2, 4x4x3, or 4x4x4 block is stored as two, three, or four 271 consecutive 4x4 blocks of the analogous S3TC format, one for each 272 layer inside the block. For example, a 4x4x2 DXT1 block consists of 273 16 bytes in total. The first 8 bytes encode the texels at locations 274 (0,0,0) through (3,3,0), and the second 8 bytes encode the texels 275 at locations (0,0,1) through (3,3,1). 276 277 For definitions of the S3TC formats, please refer to the 278 EXT_texture_compression_s3tc specification. 279 280Revision History 281 282 April 20, 2004 - Relax restrictions on depth and zoffset for 283 CopyTexSubImage3D and TexSubImage3D commands. Previous restrictions 284 required 1) the image level's depth to be 1 for CopyTexSubImage3D to 285 work (making the command useless in practice) and 2) the depth and 286 zoffset for TexSubImage3D to be a multiple 4. If these restrictions 287 were violated, an INVALID_OPERATION error was documented to be 288 generated. NVIDIA Release 60 drivers after April 20, 2004 relax 289 these restrictions. Note the restrictions on CompressedTexSubImage3D 290 that depth and zoffset must be multiples of 4 still exist because the 291 VTC block is a 3D 4x4x4 block (or 4x4x2 and 4x4x1 in the end cases). 292 293 Jun 3, 2004 - Update blockIndex to support non-power-of-two dimensions 294 for VTC storage. 295