• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    NV_texture_compression_s3tc
4
5Name Strings
6
7    GL_NV_texture_compression_s3tc
8
9Contributors
10
11    Contributors to the OpenGL EXT_texture_compression_s3tc extension
12    Greg Roth, NVIDIA
13
14Contact
15
16    Ian Stewart, NVIDIA Corporation (istewart 'at' nvidia.com)
17
18Status
19
20    Complete.
21
22Version
23
24    Last Modifed Date: Sep 27, 2012
25    NVIDIA Revision: 1
26
27Number
28
29    OpenGL ES Extension #128
30
31Dependencies
32
33    This extension is written against the OpenGL ES 2.0.25
34    Specification.
35
36    This extension interacts with NV_texture_array
37
38Overview
39
40    This extension adds support for S3's S3TC texture compression
41    formats, including DXT1, DXT3, and DXT5.  For the DXT1 format,
42    this specification supports an RGB-only mode and a special RGBA
43    mode with single-bit alpha.
44
45IP Status
46
47    Contact S3 Incorporated (http://www.s3.com) regarding any
48    intellectual property issues associated with implementing this
49    extension.
50
51    WARNING: Vendors able to support S3TC texture compression in
52    Direct3D drivers do not necessarily have the right to use the same
53    functionality in OpenGL ES.
54
55New Tokens
56
57    Accepted by the <internalformat> parameter of CompressedTexImage2D
58    and CompressedTexSubImage2D:
59
60        COMPRESSED_RGB_S3TC_DXT1_NV                     0x83F0
61        COMPRESSED_RGBA_S3TC_DXT1_NV                    0x83F1
62        COMPRESSED_RGBA_S3TC_DXT3_NV                    0x83F2
63        COMPRESSED_RGBA_S3TC_DXT5_NV                    0x83F3
64
65Additions to Chapter 3 of the OpenGL ES 2.0.25 Specification
66
67    Modify Section 3.7.3, "Compressed Texture Images"
68
69    (Replace first two sentences with)
70
71    Texture images may also be specified or modified using image data
72    already stored in a known compressed image format.  The GL defines
73    some specific compressed formats, and others may be defined by GL
74    extensions.
75
76    (Insert after section describing CompressedTexImage2D)
77
78    The specific compressed texture formats supported by
79    CompressedTexImage2D, and the corresponding base internal format
80    for each specific format, are defined in table 3.X.
81
82        Table 3.X: "Specific compressed texture formats"
83
84        Compressed Internal Formats           Base Internal Format
85        ===========================           ====================
86        COMPRESSED_RGB_S3TC_DXT1_NV           RGB
87        COMPRESSED_RGBA_S3TC_DXT1_NV          RGBA
88        COMPRESSED_RGBA_S3TC_DXT3_NV          RGBA
89        COMPRESSED_RGBA_S3TC_DXT5_NV          RGBA
90
91    (Replace last paragraph with)
92
93    If the internal format is one of COMPRESSED_RGB_S3TC_DXT1_NV,
94    COMPRESSED_RGBA_S3TC_DXT1_NV, COMPRESSED_RGBA_S3TC_DXT3_NV, or
95    COMPRESSED_RGBA_S3TC_DXT5_NV, the compressed texture is stored
96    using one of several S3TC compressed texture image formats and is
97    easily edited along 4x4 texel boundaries. In this case,
98    CompressedTexImage2D will result in an INVALID_OPERATION error
99    if one of the following conditions occurs:
100
101        * <width> is not a multiple of four, and <width> plus
102          <xoffset> is not equal to TEXTURE_WIDTH;
103
104        * <height> is not a multiple of four, and <height> plus
105          <yoffset> is not equal to TEXTURE_HEIGHT; or
106
107        * <xoffset> or <yoffset> is not a multiple of four.
108
109    For any other formats, calling CompressedTexSubImage2D will result
110    in an INVALID_OPERATION error if <xoffset> or <yoffset> is not
111    equal to zero, or if <width> and <height> do not match the width
112    and height of the texture, respectively. The contents of any texel
113    outside the region modified by the call are undefined. These
114    restrictions may be relaxed for other specific compressed internal
115    formats whose images are easily modified.
116
117Interactions with NV_texture_array
118
119    If NV_texture_array is supported, the S3TC compressed formats may
120    also be used as the internal formats given to
121    CompressedTexImage3DNV and CompressedTexSubImage3DNV. The
122    restrictions for the <width>, <height>, <xoffset>, and <yoffset>
123    parameters of the CompressedTexSubImage2D function when used with
124    S3TC compressed texture formats, described in this extension, also
125    apply to the identically named parameters of
126    CompressedTexSubImage3DNV.
127
128Errors
129
130    INVALID_OPERATION is generated by CopyTexSubImage2D if the texture
131    image <level> bound to <target> has internal format
132    COMPRESSED_RGB_S3TC_DXT1_NV, COMPRESSED_RGBA_S3TC_DXT1_NV,
133    COMPRESSED_RGBA_S3TC_DXT3_NV, or COMPRESSED_RGBA_S3TC_DXT5_NV.
134
135    INVALID_OPERATION is generated by CompressedTexSubImage2D if
136    <internalformat> is COMPRESSED_RGB_S3TC_DXT1_NV,
137    COMPRESSED_RGBA_S3TC_DXT1_NV, COMPRESSED_RGBA_S3TC_DXT3_NV, or
138    COMPRESSED_RGBA_S3TC_DXT5_NV and any of the following apply:
139
140        * <width> is not a multiple of four, and <width> plus
141          <xoffset> is not equal to the texture width;
142
143        * <height> is not a multiple of four, and <height> plus
144          <yoffset> is not equal to the texture height; or
145
146        * <xoffset> or <yoffset> is not a multiple of four.
147
148New State
149
150    The queries for NUM_COMPRESSED_TEXTURE_FORMATS and
151    COMPRESSED_TEXTURE_FORMATS include COMPRESSED_RGB_S3TC_DXT1_NV,
152    COMPRESSED_RGBA_S3TC_DXT1_NV, COMPRESSED_RGBA_S3TC_DXT3_NV, and
153    COMPRESSED_RGBA_S3TC_DXT5_NV.
154
155Appendix
156
157    S3TC Compressed Texture Image Formats
158
159    Compressed texture images stored using the S3TC compressed image
160    formats are represented as a collection of 4x4 texel blocks, where
161    each block contains 64 or 128 bits of texel data.  The image is
162    encoded as a normal 2D raster image in which each 4x4 block is
163    treated as a single pixel.  If an S3TC image has a width or height
164    that is not a multiple of four, the data corresponding to texels
165    outside the image are irrelevant and undefined.
166
167    When an S3TC image with a width of <w>, height of <h>, and block
168    size of <blocksize> (8 or 16 bytes) is decoded, the corresponding
169    image size (in bytes) is:
170
171        ceil(<w>/4) * ceil(<h>/4) * blocksize.
172
173    When decoding an S3TC image, the block containing the texel at
174    offset (<x>, <y>) begins at an offset (in bytes) relative to the
175    base of the image of:
176
177        blocksize * (ceil(<w>/4) * floor(<y>/4) + floor(<x>/4)).
178
179    The data corresponding to a specific texel (<x>, <y>) are
180    extracted from a 4x4 texel block using a relative (x,y) value of
181
182        (<x> modulo 4, <y> modulo 4).
183
184    There are four distinct S3TC image formats:
185
186    COMPRESSED_RGB_S3TC_DXT1_NV:  Each 4x4 block of texels consists of
187    64 bits of RGB image data.
188
189        Each RGB image data block is encoded as a sequence of 8 bytes,
190        called (in order of increasing address):
191
192            c0_lo, c0_hi, c1_lo, c1_hi, bits_0, bits_1, bits_2, bits_3
193
194        The 8 bytes of the block are decoded into three quantities:
195
196            color0 = c0_lo + c0_hi * 256
197            color1 = c1_lo + c1_hi * 256
198            bits   = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * bits_3))
199
200        color0 and color1 are 16-bit unsigned integers that are
201        unpacked to RGB colors RGB0 and RGB1 as though they were
202        16-bit packed pixels with a <format> of RGB and a type of
203        UNSIGNED_SHORT_5_6_5.
204
205        bits is a 32-bit unsigned integer, from which a two-bit
206        control code is extracted for a texel at location (x,y) in the
207        block using:
208
209            code(x,y) = bits[2*(4*y+x)+1 .. 2*(4*y+x)+0]
210
211        where bit 31 is the most significant and bit 0 is the least
212        significant bit.
213
214        The RGB color for a texel at location (x,y) in the block is
215        given by:
216
217            RGB0,              if color0 > color1 and code(x,y) == 0
218            RGB1,              if color0 > color1 and code(x,y) == 1
219            (2*RGB0+RGB1)/3,   if color0 > color1 and code(x,y) == 2
220            (RGB0+2*RGB1)/3,   if color0 > color1 and code(x,y) == 3
221
222            RGB0,              if color0 <= color1 and code(x,y) == 0
223            RGB1,              if color0 <= color1 and code(x,y) == 1
224            (RGB0+RGB1)/2,     if color0 <= color1 and code(x,y) == 2
225            BLACK,             if color0 <= color1 and code(x,y) == 3
226
227        Arithmetic operations are done per component, and BLACK refers
228        to an RGB color where red, green, and blue are all zero.
229
230        Since this image has an RGB format, there is no alpha
231        component and the image is considered fully opaque.
232
233
234    COMPRESSED_RGBA_S3TC_DXT1_NV:  Each 4x4 block of texels consists
235    of 64 bits of RGB image data and minimal alpha information.  The
236    RGB components of a texel are extracted in the same way as
237    COMPRESSED_RGB_S3TC_DXT1_NV.
238
239        The alpha component for a texel at location (x,y) in the block
240        is given by:
241
242            0.0,               if color0 <= color1 and code(x,y) == 3
243            1.0,               otherwise
244
245
246    COMPRESSED_RGBA_S3TC_DXT3_NV:  Each 4x4 block of texels consists
247    of 64 bits of uncompressed alpha image data followed by 64 bits of
248    RGB image data.
249
250        Each RGB image data block is encoded according to the
251        COMPRESSED_RGB_S3TC_DXT1_NV format, with the exception that
252        the two code bits always use the non-transparent encodings.
253        In other words, they are treated as though color0 > color1,
254        regardless of the actual values of color0 and color1.
255
256        Each alpha image data block is encoded as a sequence of 8
257        bytes, called (in order of increasing address):
258
259            a0, a1, a2, a3, a4, a5, a6, a7
260
261        The 8 bytes of the block are decoded into one 64-bit integer:
262
263            alpha = a0 + 256 * (a1 + 256 * (a2 + 256 * (a3 + 256 * (a4 +
264                         256 * (a5 + 256 * (a6 + 256 * a7))))))
265
266        alpha is a 64-bit unsigned integer, from which a four-bit
267        alpha value is extracted for a texel at location (x,y) in the
268        block using:
269
270            alpha(x,y) = bits[4*(4*y+x)+3 .. 4*(4*y+x)+0]
271
272        where bit 63 is the most significant and bit 0 is the least
273        significant bit.
274
275        The alpha component for a texel at location (x,y) in the block
276        is given by alpha(x,y) / 15.
277
278
279    COMPRESSED_RGBA_S3TC_DXT5_NV:  Each 4x4 block of texels consists
280    of 64 bits of compressed alpha image data followed by 64 bits of
281    RGB image data.
282
283        Each RGB image data block is encoded according to the
284        COMPRESSED_RGB_S3TC_DXT1_NV format, with the exception that
285        the two code bits always use the non-transparent encodings.
286        In other words, they are treated as though color0 > color1,
287        regardless of the actual values of color0 and color1.
288
289        Each alpha image data block is encoded as a sequence of 8
290        bytes, called (in order of increasing address):
291
292        alpha0, alpha1, bits_0, bits_1, bits_2, bits_3, bits_4, bits_5
293
294        The alpha0 and alpha1 are 8-bit unsigned bytes converted to
295        alpha components by multiplying by 1/255.
296
297        The 6 "bits" bytes of the block are decoded into one 48-bit
298        integer:
299
300          bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 +
301                          256 * (bits_4 + 256 * bits_5))))
302
303        bits is a 48-bit unsigned integer, from which a three-bit
304        control code is extracted for a texel at location (x,y) in the
305        block using:
306
307            code(x,y) = bits[3*(4*y+x)+2 .. 3*(4*y+x)+0]
308
309        where bit 47 is the most significant and bit 0 is the least
310        significant bit.
311
312        The alpha component for a texel at location (x,y) in the block
313        is given by:
314
315              alpha0,                   code(x,y) == 0
316              alpha1,                   code(x,y) == 1
317
318              (6*alpha0 + 1*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 2
319              (5*alpha0 + 2*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 3
320              (4*alpha0 + 3*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 4
321              (3*alpha0 + 4*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 5
322              (2*alpha0 + 5*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 6
323              (1*alpha0 + 6*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 7
324
325              (4*alpha0 + 1*alpha1)/5,  alpha0 <= alpha1 and code(x,y) == 2
326              (3*alpha0 + 2*alpha1)/5,  alpha0 <= alpha1 and code(x,y) == 3
327              (2*alpha0 + 3*alpha1)/5,  alpha0 <= alpha1 and code(x,y) == 4
328              (1*alpha0 + 4*alpha1)/5,  alpha0 <= alpha1 and code(x,y) == 5
329              0.0,                      alpha0 <= alpha1 and code(x,y) == 6
330              1.0,                      alpha0 <= alpha1 and code(x,y) == 7
331
332
333Issues
334
335    None
336
337Revision History
338
339    Rev.    Date        Author       Changes
340    ----   --------     ---------    -------------------------------------
341     1     09/27/2012   istewart     First revision, based of the
342                                     EXT_texture_compression_s3tc
343                                     specification.
344
345# vim:ai:ts=4:sts=4:expandtab:textwidth=70
346