• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    EXT_texture_compression_s3tc
4
5Name Strings
6
7    GL_EXT_texture_compression_s3tc
8
9Contributors
10
11    Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com)
12    Ian Stewart, NVIDIA Corporation (istewart 'at' nvidia.com)
13    Nicholas Haemel, NVIDIA Corporation
14    Acorn Pooley, NVIDIA Corporation
15    Antti Rasmus, NVIDIA Corporation
16    Musawir Shah, NVIDIA Corporation
17
18Contact
19
20    Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com)
21    Slawomir Grajewski, INTEL (slawomir.grajewski 'at' intel.com)
22
23Status
24
25    FINAL
26
27Version
28
29    1.6, 15 July 2013
30
31Number
32
33    OpenGL Extension #198
34    OpenGL ES Extension #154
35
36Dependencies
37
38    OpenGL dependencies:
39
40        OpenGL 1.1 is required.
41
42        GL_ARB_texture_compression is required.
43
44        This extension is written against the OpenGL 1.2.1 Specification.
45
46        This extension interacts with OpenGL 2.0 and
47        ARB_texture_non_power_of_two.
48
49    OpenGL ES dependencies:
50
51        This extension is written against the OpenGL ES 2.0.25 Specification
52        and OpenGL ES 3.0.2 Specification.
53
54        This extension applied to OpenGL ES 2.0.25 Specification interacts with
55        NV_texture_array.
56
57Overview
58
59    This extension provides additional texture compression functionality
60    specific to S3's S3TC format (called DXTC in Microsoft's DirectX API),
61    subject to all the requirements and limitations described by the extension
62    GL_ARB_texture_compression.
63
64    This extension supports DXT1, DXT3, and DXT5 texture compression formats.
65    For the DXT1 image format, this specification supports an RGB-only mode
66    and a special RGBA mode with single-bit "transparent" alpha.
67
68IP Status
69
70    Contact S3 Incorporated (http://www.s3.com) regarding any intellectual
71    property issues associated with implementing this extension.
72
73    WARNING:  Vendors able to support S3TC texture compression in Direct3D
74    drivers do not necessarily have the right to use the same functionality in
75    OpenGL.
76
77Issues
78
79    (1) Should DXT2 and DXT4 (premultiplied alpha) formats be supported?
80
81        RESOLVED:  No -- insufficient interest.  Supporting DXT2 and DXT4
82        would require some rework to the TexEnv definition (maybe add a new
83        base internal format RGBA_PREMULTIPLIED_ALPHA) for these formats.
84        Note that the EXT_texture_env_combine extension (which extends normal
85        TexEnv modes) can be used to support textures with premultipled alpha.
86
87    (2) Should generic "RGB_S3TC_EXT" and "RGBA_S3TC_EXT" enums be supported
88        or should we use only the DXT<n> enums?
89
90        RESOLVED:  No.  A generic RGBA_S3TC_EXT is problematic because DXT3
91        and DXT5 are both nominally RGBA (and DXT1 with the 1-bit alpha is
92        also) yet one format must be chosen up front.
93
94    (3) Should TexSubImage support all block-aligned edits or just the minimal
95        functionality required by the ARB_texture_compression extension?
96
97        RESOLVED:  Allow all valid block-aligned edits.
98
99    (4) A pre-compressed image with a DXT1 format can be used as either an
100        RGB_S3TC_DXT1 or an RGBA_S3TC_DXT1 image.  If the image has
101        transparent texels, how are they treated in each format?
102
103        RESOLVED:  The renderer has to make sure that an RGB_S3TC_DXT1 format
104        is decoded as RGB (where alpha is effectively one for all texels),
105        while RGBA_S3TC_DXT1 is decoded as RGBA (where alpha is zero for all
106        texels with "transparent" encodings).  Otherwise, the formats are
107        identical.
108
109    (5) Is the encoding of the RGB components for DXT1 formats correct in this
110        spec?  MSDN documentation does not specify an RGB color for the
111        "transparent" encoding.  Is it really black?
112
113        RESOLVED:  Yes.  The specification for the DXT1 format initially
114        required black, but later changed that requirement to a
115        recommendation.  All vendors involved in the definition of this
116        specification support black.  In addition, specifying black has a
117        useful behavior.
118
119        When blending multiple texels (GL_LINEAR filtering), mixing opaque and
120        transparent samples is problematic.  Defining a black color on
121        transparent texels achieves a sensible result that works like a
122        texture with premultiplied alpha.  For example, if three opaque white
123        and one transparent sample is being averaged, the result would be a
124        75% intensity gray (with an alpha of 75%).  This is the same result on
125        the color channels as would be obtained using a white color, 75%
126        alpha, and a SRC_ALPHA blend factor.
127
128    (6) Is the encoding of the RGB components for DXT3 and DXT5 formats
129        correct in this spec?  MSDN documentation suggests that the RGB blocks
130        for DXT3 and DXT5 are decoded as described by the DXT1 format.
131
132        RESOLVED:  Yes -- this appears to be a bug in the MSDN documentation.
133        The specification for the DXT2-DXT5 formats require decoding using the
134        opaque block encoding, regardless of the relative values of "color0"
135        and "color1".
136
137New Procedures and Functions
138
139    None.
140
141New Tokens
142
143    This extension introduces new tokens:
144
145        COMPRESSED_RGB_S3TC_DXT1_EXT                   0x83F0
146        COMPRESSED_RGBA_S3TC_DXT1_EXT                  0x83F1
147        COMPRESSED_RGBA_S3TC_DXT3_EXT                  0x83F2
148        COMPRESSED_RGBA_S3TC_DXT5_EXT                  0x83F3
149
150    In OpenGL 1.2.1 these tokens are accepted by the <internalformat> parameter
151    of TexImage2D, CopyTexImage2D, and CompressedTexImage2D and the <format>
152    parameter of CompressedTexSubImage2D.
153
154    In extended OpenGL ES 2.0.25 these new tokens are accepted by the
155    <internalformat> parameter of TexImage2D, CompressedTexImage2D and the <format>
156    parameter of CompressedTexSubImage2D.
157
158    In extended OpenGL ES 3.0.2 these new tokens are also accepted by the
159    <internalformat> parameter of TexImage3D, CompressedTexImage3D,
160    TexStorage2D, TexStorage3D and the <format> parameter of
161    CompressedTexSubImage3D.
162
163Additions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation)
164
165    None.
166
167Additions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization)
168
169    Add to Table 3.16.1:  Specific Compressed Internal Formats
170
171        Compressed Internal Format         Base Internal Format
172        ==========================         ====================
173        COMPRESSED_RGB_S3TC_DXT1_EXT       RGB
174        COMPRESSED_RGBA_S3TC_DXT1_EXT      RGBA
175        COMPRESSED_RGBA_S3TC_DXT3_EXT      RGBA
176        COMPRESSED_RGBA_S3TC_DXT5_EXT      RGBA
177
178
179    Modify Section 3.8.2, Alternate Image Specification
180
181    (add to end of TexSubImage discussion, p.123 -- after edit from the
182    ARB_texture_compression spec)
183
184    If the internal format of the texture image being modified is
185    COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT,
186    COMPRESSED_RGBA_S3TC_DXT3_EXT, or COMPRESSED_RGBA_S3TC_DXT5_EXT, the
187    texture is stored using one of the several S3TC compressed texture image
188    formats.  Such images are easily edited along 4x4 texel boundaries, so the
189    limitations on TexSubImage2D or CopyTexSubImage2D parameters are relaxed.
190    TexSubImage2D and CopyTexSubImage2D will result in an INVALID_OPERATION
191    error only if one of the following conditions occurs:
192
193        * <width> is not a multiple of four, <width> plus <xoffset> is not
194          equal to TEXTURE_WIDTH, and either <xoffset> or <yoffset> is
195          non-zero;
196
197        * <height> is not a multiple of four, <height> plus <yoffset> is not
198          equal to TEXTURE_HEIGHT, and either <xoffset> or <yoffset> is
199          non-zero; or
200
201        * <xoffset> or <yoffset> is not a multiple of four.
202
203    The contents of any 4x4 block of texels of an S3TC compressed texture
204    image that does not intersect the area being modified are preserved during
205    valid TexSubImage2D and CopyTexSubImage2D calls.
206
207
208    Add to Section 3.8.2, Alternate Image Specification (adding to the end of
209    the CompressedTexImage section introduced by the ARB_texture_compression
210    spec)
211
212    If <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT,
213    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
214    COMPRESSED_RGBA_S3TC_DXT5_EXT, the compressed texture is stored using one
215    of several S3TC compressed texture image formats.  The S3TC texture
216    compression algorithm supports only 2D images without borders.
217    CompressedTexImage1DARB and CompressedTexImage3DARB produce an
218    INVALID_ENUM error if <internalformat> is an S3TC format.
219    CompressedTexImage2DARB will produce an INVALID_OPERATION error if
220    <border> is non-zero.
221
222
223    Add to Section 3.8.2, Alternate Image Specification (adding to the end of
224    the CompressedTexSubImage section introduced by the
225    ARB_texture_compression spec)
226
227    If the internal format of the texture image being modified is
228    COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT,
229    COMPRESSED_RGBA_S3TC_DXT3_EXT, or COMPRESSED_RGBA_S3TC_DXT5_EXT, the
230    texture is stored using one of the several S3TC compressed texture image
231    formats.  Since the S3TC texture compression algorithm supports only 2D
232    images, CompressedTexSubImage1DARB and CompressedTexSubImage3DARB produce
233    an INVALID_ENUM error if <format> is an S3TC format.  Since S3TC images
234    are easily edited along 4x4 texel boundaries, the limitations on
235    CompressedTexSubImage2D are relaxed.  CompressedTexSubImage2D will result
236    in an INVALID_OPERATION error only if one of the following conditions
237    occurs:
238
239        * <width> is not a multiple of four, and <width> plus <xoffset> is not
240          equal to TEXTURE_WIDTH;
241
242        * <height> is not a multiple of four, and <height> plus <yoffset> is
243          not equal to TEXTURE_HEIGHT; or
244
245        * <xoffset> or <yoffset> is not a multiple of four.
246
247    The contents of any 4x4 block of texels of an S3TC compressed texture
248    image that does not intersect the area being modified are preserved during
249    valid TexSubImage2D and CopyTexSubImage2D calls.
250
251Additions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment
252Operations and the Frame Buffer)
253
254    None.
255
256Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions)
257
258    None.
259
260Additions to Chapter 6 of the OpenGL 1.2.1 Specification (State and
261State Requests)
262
263    None.
264
265Additions to Appendix A of the OpenGL 1.2.1 Specification (Invariance)
266
267    None.
268
269Additions to Chapter 3 of the OpenGL ES 2.0.25 Specification
270
271    Modify Section 3.7.1, Texture Image Specification
272
273    (change last paragraph on Page 67 as follows)
274
275    Components are then selected from the resulting R, G, B, or A values
276    to obtain a texture with the base internal format specified by
277    <internalformat>, which must match <format> except when <target> is
278    TEXTURE_2D and <internalformat> is one of the following compressed
279    formats: COMPRESSED_RGB_S3TC_DXT1_EXT,
280    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
281    COMPRESSED_RGBA_S3TC_DXT5_EXT. In this case, conversion from only
282    RGB and RGBA formats are supported during texture image processing.
283    <format> values other than RBA or RGBA will result in the
284    INVALID_OPERATION error. In all other cases where <internalformat>
285    does not match <format>, the error INVALID_OPERATION is generated.
286    Table 3.8 summarizes the mapping of R, G, B, and A values to texture
287    components, as a function of the base internal format of the texture
288    image. <internalformat> may be one of the five internal format
289    symbolic constants listed in table 3.8 or the four compressed
290    formats: COMPRESSED_RGB_S3TC_DXT1_EXT,
291    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
292    COMPRESSED_RGBA_S3TC_DXT5_EXT. Specifying a value for
293    <internalformat> that is not one of the above values generates the
294    error INVALID_VALUE. When a compressed <internalformat> is specified,
295    a compressed texture is created and all the associated restrictions
296    mentioned in Section 3.7.3 are imposed.
297
298    Note that when encoding an RGBA image into a format using 1-bit
299    alpha, any texels with an alpha component less than 0.5 end up
300    with an alpha of 0.0 and any texels with an alpha component
301    greater than or equal to 0.5 end up with an alpha of 1.0. When
302    encoding an RGBA image into the COMPRESSED_RGBA_S3TC_DXT1_EXT
303    format, the resulting red, green, and blue components of any
304    texels with a final alpha of 0.0 will automatically be zero
305    (black).  If this behavior is not desired by an application, it
306    should not use COMPRESSED_RGBA_S3TC_DXT1_EXT.
307
308    Modify Section 3.7.2, Alternate Texture Image Specification Commands
309
310    (add to the end of section)
311
312    When the internal format of the texture object is
313    COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT,
314    COMPRESSED_RGBA_S3TC_DXT3_EXT, or COMPRESSED_RGBA_S3TC_DXT5_EXT, the
315    update region specified in TexSubImage2D must be aligned to 4x4
316    pixel blocks. If <xoffset> or <yoffset> are not multiples of 4 an
317    INVALID_OPERATION error is generated. If <width> is not a multiple
318    of 4 and <xoffset> + <width> is not equal to the width of the LOD
319    then an INVALID_OPERATION error is generated.  If <height> is not
320    a multiple of 4 and <yoffset> + <height> is not equal to the
321    height of the LOD then an INVALID_OPERATION error is generated.
322
323    Modify Section 3.7.3, "Compressed Texture Images"
324
325    (Replace first two sentences with)
326
327    Texture images may also be specified or modified using image data
328    already stored in a known compressed image format.  The GL defines
329    some specific compressed formats, and others may be defined by GL
330    extensions.
331
332    (Insert after section describing CompressedTexImage2D)
333
334    The specific compressed texture formats supported by
335    CompressedTexImage2D, and the corresponding base internal format
336    for each specific format, are defined in table 3.X.
337
338        Table 3.X: "Specific compressed texture formats"
339
340        Compressed Internal Formats           Base Internal Format
341        ===========================           ====================
342        COMPRESSED_RGB_S3TC_DXT1_EXT           RGB
343        COMPRESSED_RGBA_S3TC_DXT1_EXT          RGBA
344        COMPRESSED_RGBA_S3TC_DXT3_EXT          RGBA
345        COMPRESSED_RGBA_S3TC_DXT5_EXT          RGBA
346
347    (Replace last paragraph with)
348
349    If the internal format is one of COMPRESSED_RGB_S3TC_DXT1_EXT,
350    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
351    COMPRESSED_RGBA_S3TC_DXT5_EXT, the compressed texture is stored
352    using one of several S3TC compressed texture image formats and is
353    easily edited along 4x4 texel boundaries. In this case,
354    CompressedTexSubImage2D will result in an INVALID_OPERATION error
355    if one of the following conditions occurs:
356
357        * <width> is not a multiple of four, and <width> plus
358          <xoffset> is not equal to texture width;
359
360        * <height> is not a multiple of four, and <height> plus
361          <yoffset> is not equal to texture height; or
362
363        * <xoffset> or <yoffset> is not a multiple of four.
364
365    For any other formats, calling CompressedTexSubImage2D will result
366    in an INVALID_OPERATION error if <xoffset> or <yoffset> is not
367    equal to zero, or if <width> and <height> do not match the width
368    and height of the texture, respectively. The contents of any texel
369    outside the region modified by the call are undefined. These
370    restrictions may be relaxed for other specific compressed internal
371    formats whose images are easily modified.
372
373Additions to Chapter 4 of the OpenGL ES 2.0.25 Specification (Per-Fragment
374Operations and the Framebuffer)
375
376    Modify Section 4.4.3, Attaching Texture Images to a Framebuffer
377
378    (add after last paragraph on Page 113)
379
380    If <texture> is not zero and the internal format of the
381    corresponding texture object is a compressed format, an
382    INVALID_OPERATION error is generated.
383
384Interactions of extended OpenGL ES 2.0.25 with NV_texture_array
385
386    If NV_texture_array is supported, the S3TC compressed formats may
387    also be used as the internal formats given to
388    CompressedTexImage3DNV and CompressedTexSubImage3DNV. The
389    restrictions for the <width>, <height>, <xoffset>, and <yoffset>
390    parameters of the CompressedTexSubImage2D function when used with
391    S3TC compressed texture formats, described in this extension, also
392    apply to the identically named parameters of
393    CompressedTexSubImage3DNV.
394
395Additions to Chapter 3 of the OpenGL ES 3.0.2 Specification
396
397    Modify Section 3.8.3, "Texture Image Specification"
398
399    (Modify paragraph starting with "Components are then selected")
400
401    Components are then selected from the resulting R, G, B, A, depth, or
402    stencil values to obtain a texture with the base internal format specified
403    by (or derived from) internalformat. Table 3.11 summarizes the mapping of
404    R, G, B, A, depth, or stencil values to texture components, as a function
405    of the base internal format of the texture image.
406
407    For internalformat different than COMPRESSED_RGB_S3TC_DXT1_EXT,
408    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
409    COMPRESSED_RGBA_S3TC_DXT5_EX specifying a combination of values for format,
410    type, and internalformat that is not listed as a valid combination in
411    tables 3.2 or 3.3 generates the error INVALID_OPERATION.
412
413    For internalformat equal COMPRESSED_RGB_S3TC_DXT1_EXT,
414    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
415    COMPRESSED_RGBA_S3TC_DXT5_EXT only RGB and RGBA formats are supported
416    during texture image processing and for these internalformat values
417    <format> values other than RBA or RGBA will result in the INVALID_OPERATION
418    error.
419
420    Modify Section 3.8.6, "Compressed Texture Images"
421
422    (extend Table 3.16 with the following rows)
423
424        Compressed Internal Formats           Base Internal Format
425        ===========================           ====================
426        COMPRESSED_RGB_S3TC_DXT1_EXT          RGB
427        COMPRESSED_RGBA_S3TC_DXT1_EXT         RGBA
428        COMPRESSED_RGBA_S3TC_DXT3_EXT         RGBA
429        COMPRESSED_RGBA_S3TC_DXT5_EXT         RGBA
430
431    (Replace the first paragraph)
432
433    Texture images may also be specified or modified using image data already
434    stored in a known compressed image format, such as the
435    ETC2/EAC/DXT1/DXT3/DXT5 formats defined in appendix C, or additional
436    formats defined by GL extensions.
437
438    (Replace paragraph starting with: If internalformat is one of the ETC2/EAC
439    formats described)
440
441    If internalformat is one of the ETC2/EAC/DXT1/DXT3/DXT5 formats described
442    in table 3.16, the compressed image data is stored using one of the
443    ETC2/EAC/DXT1/DXT3/DXT5 compressed texture image encodings (see appendix
444    C). The ETC2/EAC/DXT1/DXT3/DXT5 texture compression algorithm supports only
445    two-dimensional images. If internalformat is an ETC2/EAC/DXT1/DXT3/DXT5
446    format, CompressedTexImage3D will generate an INVALID_OPERATION error if
447    target is not TEXTURE_2D_ARRAY.
448
449    (Add at the end of the chapter)
450
451    If the internal format is one of COMPRESSED_RGB_S3TC_DXT1_EXT,
452    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
453    COMPRESSED_RGBA_S3TC_DXT5_EXT, the compressed texture is stored using one
454    of several S3TC compressed texture image formats and is easily edited along
455    4x4 texel boundaries. In this case,
456    CompressedTexSubImage2D/CompressedTexSubImage3D will result in an
457    INVALID_OPERATION error if one of the following conditions occurs:
458
459        * <width> is not a multiple of four, and <width> plus
460          <xoffset> is not equal to texture width;
461
462        * <height> is not a multiple of four, and <height> plus
463          <yoffset> is not equal to texture height; or
464
465        * <xoffset> or <yoffset> is not a multiple of four.
466
467    For any other formats, calling CompressedTexSubImage2D/CompressedTexSubImage3D
468    will result in an INVALID_OPERATION error if <xoffset> or <yoffset> is not
469    equal to zero, or if <width> and <height> do not match the width and height
470    of the texture, respectively. The contents of any texel outside the region
471    modified by the call are undefined. These restrictions may be relaxed for
472    other specific compressed internal formats whose images are easily
473    modified.
474
475Additions to the AGL/GLX/WGL Specifications
476
477    None.
478
479GLX Protocol
480
481    None.
482
483Dependencies on OpenGL 2.0 or ARB_texture_non_power_of_two
484
485    If OpenGL 2.0 or ARB_texture_non_power_of_two is supported, compressed
486    texture images can have sizes that are neither multiples of four nor small
487    values like one or two.  The original version of this specification didn't
488    allow TexSubImage2D and CompressedTexSubImage2D to update only a portion
489    of such images.  The spec has been updated to allow such edits in the
490    spirit of the resolution of issue (3).  See the "Implementation Note"
491    section for more details.
492
493Errors for OpenGL 1.2.1 Specification
494
495    INVALID_ENUM is generated by CompressedTexImage1D or CompressedTexImage3D
496    if <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT,
497    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
498    COMPRESSED_RGBA_S3TC_DXT5_EXT.
499
500    INVALID_OPERATION is generated by CompressedTexImage2D if
501    <internalformat> is COMPRESSED_RGB_S3TC_DXT1_EXT,
502    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
503    COMPRESSED_RGBA_S3TC_DXT5_EXT and <border> is not equal to zero.
504
505    INVALID_ENUM is generated by CompressedTexSubImage1D or
506    CompressedTexSubImage3D if <format> is COMPRESSED_RGB_S3TC_DXT1_EXT,
507    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
508    COMPRESSED_RGBA_S3TC_DXT5_EXT.
509
510    INVALID_OPERATION is generated by TexSubImage2D or CopyTexSubImage2D if
511    TEXTURE_INTERNAL_FORMAT is COMPRESSED_RGB_S3TC_DXT1_EXT,
512    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
513    COMPRESSED_RGBA_S3TC_DXT5_EXT and any of the following apply:
514
515        * <width> is not a multiple of four, <width> plus <xoffset> is not
516           equal to TEXTURE_WIDTH, and either <xoffset> or <yoffset> is
517           non-zero;
518
519        * <height> is not a multiple of four, <height> plus <yoffset> is not
520          equal to TEXTURE_HEIGHT, and either <xoffset> or <yoffset> is
521          non-zero; or
522
523        * <xoffset> or <yoffset> is not a multiple of four.
524
525    INVALID_OPERATION is generated by CompressedTexSubImage2D if
526    TEXTURE_INTERNAL_FORMAT is COMPRESSED_RGB_S3TC_DXT1_EXT,
527    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
528    COMPRESSED_RGBA_S3TC_DXT5_EXT and any of the following apply:
529
530        * <width> is not a multiple of four, and <width> plus <xoffset> is not
531          equal to TEXTURE_WIDTH;
532
533        * <height> is not a multiple of four, and <height> plus <yoffset> is
534          not equal to TEXTURE_HEIGHT; or
535
536        * <xoffset> or <yoffset> is not a multiple of four.
537
538
539    The following restrictions from the ARB_texture_compression specification
540    do not apply to S3TC texture formats, since subimage modification is
541    straightforward as long as the subimage is properly aligned.
542
543    DELETE: INVALID_OPERATION is generated by TexSubImage1D, TexSubImage2D,
544    DELETE: TexSubImage3D, CopyTexSubImage1D, CopyTexSubImage2D, or
545    DELETE: CopyTexSubImage3D if the internal format of the texture image is
546    DELETE: compressed and <xoffset>, <yoffset>, or <zoffset> does not equal
547    DELETE: -b, where b is value of TEXTURE_BORDER.
548
549    DELETE: INVALID_VALUE is generated by CompressedTexSubImage1DARB,
550    DELETE: CompressedTexSubImage2DARB, or CompressedTexSubImage3DARB if the
551    DELETE: entire texture image is not being edited:  if <xoffset>,
552    DELETE: <yoffset>, or <zoffset> is greater than -b, <xoffset> + <width> is
553    DELETE: less than w+b, <yoffset> + <height> is less than h+b, or <zoffset>
554    DELETE: + <depth> is less than d+b, where b is the value of
555    DELETE: TEXTURE_BORDER, w is the value of TEXTURE_WIDTH, h is the value of
556    DELETE: TEXTURE_HEIGHT, and d is the value of TEXTURE_DEPTH.
557
558    See also errors in the GL_ARB_texture_compression specification.
559
560Errors for OpenGL ES 2.0.25 Specification
561
562    INVALID_OPERATION is generated by CopyTexSubImage2D if the texture
563    image <level> bound to <target> has internal format
564    COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT,
565    COMPRESSED_RGBA_S3TC_DXT3_EXT, or COMPRESSED_RGBA_S3TC_DXT5_EXT.
566
567    INVALID_OPERATION is generated by CompressedTexSubImage2D if
568    <format> is COMPRESSED_RGB_S3TC_DXT1_EXT,
569    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
570    COMPRESSED_RGBA_S3TC_DXT5_EXT and any of the following apply:
571
572        * <width> is not a multiple of four, and <width> plus
573          <xoffset> is not equal to the texture width;
574
575        * <height> is not a multiple of four, and <height> plus
576          <yoffset> is not equal to the texture height; or
577
578        * <xoffset> or <yoffset> is not a multiple of four.
579
580    INVALID_OPERATION is generated by TexImage2D and TexSubImage2D if
581    texture has internal format COMPRESSED_RGB_S3TC_DXT1_EXT,
582    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
583    COMPRESSED_RGBA_S3TC_DXT5_EXT and any of the following apply:
584
585        * <xoffset> or <yoffset> are not multiples of 4
586
587        * <width> is not a multiple of 4 and <xoffset> + <width> is not equal
588          to the width of the LOD
589
590        * if <height> is not a multiple of 4 and <yoffset> + <height> is not
591          equal to the height of the LOD
592
593Errors for OpenGL ES 3.0.2 Specification
594
595    INVALID_OPERATION is generated by CopyTexSubImage2D / CopyTexSubImage3D if
596    the texture image <level> bound to <target> has internal format
597    COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT,
598    COMPRESSED_RGBA_S3TC_DXT3_EXT, or COMPRESSED_RGBA_S3TC_DXT5_EXT.
599
600    INVALID_OPERATION is generated by CompressedTexSubImage2D /
601    CopressedTexSubImage3D if <format> is COMPRESSED_RGB_S3TC_DXT1_EXT,
602    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
603    COMPRESSED_RGBA_S3TC_DXT5_EXT and any of the following apply:
604
605        * <width> is not a multiple of four, and <width> plus
606          <xoffset> is not equal to the texture width;
607
608        * <height> is not a multiple of four, and <height> plus
609          <yoffset> is not equal to the texture height; or
610
611        * <xoffset> or <yoffset> is not a multiple of four.
612
613    INVALID_OPERATION is generated by TexImage2D/TexImage3D and
614    TexSubImage2D/TexSubimage3D if texture has internal format
615    COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT,
616    COMPRESSED_RGBA_S3TC_DXT3_ETX, or COMPRESSED_RGBA_S3TC_DXT5_EXT and
617    <format> is not RGB or RGBA, or any of the following apply:
618
619        * <xoffset> or <yoffset> are not multiples of 4
620
621        * <width> is not a multiple of 4 and <xoffset> + <width> is not equal
622          to the width of the LOD
623
624        * if <height> is not a multiple of 4 and <yoffset> + <height> is not
625          equal to the height of the LOD
626
627New State for OpenGL 1.2.1 Specification
628
629    In the "Textures" state table, increment the TEXTURE_INTERNAL_FORMAT
630    subscript for Z by 4 in the "Type" row.
631
632New State for OpenGL ES 2.0.25 and 3.0.2 Specifications
633
634    The queries for NUM_COMPRESSED_TEXTURE_FORMATS and
635    COMPRESSED_TEXTURE_FORMATS include COMPRESSED_RGB_S3TC_DXT1_EXT,
636    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, and
637    COMPRESSED_RGBA_S3TC_DXT5_EXT.
638
639New Implementation Dependent State
640
641    None
642
643Appendix in OpenGL 1.2.1
644Appendix C.2 in OpenGL ES 3.0.2
645
646    S3TC Compressed Texture Image Formats
647
648    Compressed texture images stored using the S3TC compressed image formats
649    are represented as a collection of 4x4 texel blocks, where each block
650    contains 64 or 128 bits of texel data.  The image is encoded as a normal
651    2D raster image in which each 4x4 block is treated as a single pixel.  If
652    an S3TC image has a width or height that is not a multiple of four, the
653    data corresponding to texels outside the image are irrelevant and
654    undefined.
655
656    When an S3TC image with a width of <w>, height of <h>, and block size of
657    <blocksize> (8 or 16 bytes) is decoded, the corresponding image size (in
658    bytes) is:
659
660        ceil(<w>/4) * ceil(<h>/4) * blocksize.
661
662    When decoding an S3TC image, the block containing the texel at offset
663    (<x>, <y>) begins at an offset (in bytes) relative to the base of the
664    image of:
665
666        blocksize * (ceil(<w>/4) * floor(<y>/4) + floor(<x>/4)).
667
668    The data corresponding to a specific texel (<x>, <y>) are extracted from a
669    4x4 texel block using a relative (x,y) value of
670
671        (<x> modulo 4, <y> modulo 4).
672
673    There are four distinct S3TC image formats:
674
675    COMPRESSED_RGB_S3TC_DXT1_EXT:  Each 4x4 block of texels consists of 64
676    bits of RGB image data.
677
678    Each RGB image data block is encoded as a sequence of 8 bytes, called (in
679    order of increasing address):
680
681            c0_lo, c0_hi, c1_lo, c1_hi, bits_0, bits_1, bits_2, bits_3
682
683        The 8 bytes of the block are decoded into three quantities:
684
685            color0 = c0_lo + c0_hi * 256
686            color1 = c1_lo + c1_hi * 256
687            bits   = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * bits_3))
688
689        color0 and color1 are 16-bit unsigned integers that are unpacked to
690        RGB colors RGB0 and RGB1 as though they were 16-bit packed pixels with
691        a <format> of RGB and a type of UNSIGNED_SHORT_5_6_5.
692
693        bits is a 32-bit unsigned integer, from which a two-bit control code
694        is extracted for a texel at location (x,y) in the block using:
695
696            code(x,y) = bits[2*(4*y+x)+1 .. 2*(4*y+x)+0]
697
698        where bit 31 is the most significant and bit 0 is the least
699        significant bit.
700
701        The RGB color for a texel at location (x,y) in the block is given by:
702
703            RGB0,              if color0 > color1 and code(x,y) == 0
704            RGB1,              if color0 > color1 and code(x,y) == 1
705            (2*RGB0+RGB1)/3,   if color0 > color1 and code(x,y) == 2
706            (RGB0+2*RGB1)/3,   if color0 > color1 and code(x,y) == 3
707
708            RGB0,              if color0 <= color1 and code(x,y) == 0
709            RGB1,              if color0 <= color1 and code(x,y) == 1
710            (RGB0+RGB1)/2,     if color0 <= color1 and code(x,y) == 2
711            BLACK,             if color0 <= color1 and code(x,y) == 3
712
713        Arithmetic operations are done per component, and BLACK refers to an
714        RGB color where red, green, and blue are all zero.
715
716    Since this image has an RGB format, there is no alpha component and the
717    image is considered fully opaque.
718
719
720    COMPRESSED_RGBA_S3TC_DXT1_EXT:  Each 4x4 block of texels consists of 64
721    bits of RGB image data and minimal alpha information.  The RGB components
722    of a texel are extracted in the same way as COMPRESSED_RGB_S3TC_DXT1_EXT.
723
724        The alpha component for a texel at location (x,y) in the block is
725        given by:
726
727            0.0,               if color0 <= color1 and code(x,y) == 3
728            1.0,               otherwise
729
730        IMPORTANT:  When encoding an RGBA image into a format using 1-bit
731        alpha, any texels with an alpha component less than 0.5 end up with an
732        alpha of 0.0 and any texels with an alpha component greater than or
733        equal to 0.5 end up with an alpha of 1.0.  When encoding an RGBA image
734        into the COMPRESSED_RGBA_S3TC_DXT1_EXT format, the resulting red,
735        green, and blue components of any texels with a final alpha of 0.0
736        will automatically be zero (black).  If this behavior is not desired
737        by an application, it should not use COMPRESSED_RGBA_S3TC_DXT1_EXT.
738        This format will never be used when a generic compressed internal
739        format (Table 3.16.2) is specified, although the nearly identical
740        format COMPRESSED_RGB_S3TC_DXT1_EXT (above) may be.
741
742
743    COMPRESSED_RGBA_S3TC_DXT3_EXT:  Each 4x4 block of texels consists of 64
744    bits of uncompressed alpha image data followed by 64 bits of RGB image
745    data.
746
747    Each RGB image data block is encoded according to the
748    COMPRESSED_RGB_S3TC_DXT1_EXT format, with the exception that the two code
749    bits always use the non-transparent encodings.  In other words, they are
750    treated as though color0 > color1, regardless of the actual values of
751    color0 and color1.
752
753    Each alpha image data block is encoded as a sequence of 8 bytes, called
754    (in order of increasing address):
755
756            a0, a1, a2, a3, a4, a5, a6, a7
757
758        The 8 bytes of the block are decoded into one 64-bit integer:
759
760            alpha = a0 + 256 * (a1 + 256 * (a2 + 256 * (a3 + 256 * (a4 +
761                         256 * (a5 + 256 * (a6 + 256 * a7))))))
762
763        alpha is a 64-bit unsigned integer, from which a four-bit alpha value
764        is extracted for a texel at location (x,y) in the block using:
765
766            alpha(x,y) = bits[4*(4*y+x)+3 .. 4*(4*y+x)+0]
767
768        where bit 63 is the most significant and bit 0 is the least
769        significant bit.
770
771        The alpha component for a texel at location (x,y) in the block is
772        given by alpha(x,y) / 15.
773
774
775    COMPRESSED_RGBA_S3TC_DXT5_EXT:  Each 4x4 block of texels consists of 64
776    bits of compressed alpha image data followed by 64 bits of RGB image data.
777
778    Each RGB image data block is encoded according to the
779    COMPRESSED_RGB_S3TC_DXT1_EXT format, with the exception that the two code
780    bits always use the non-transparent encodings.  In other words, they are
781    treated as though color0 > color1, regardless of the actual values of
782    color0 and color1.
783
784    Each alpha image data block is encoded as a sequence of 8 bytes, called
785    (in order of increasing address):
786
787        alpha0, alpha1, bits_0, bits_1, bits_2, bits_3, bits_4, bits_5
788
789        The alpha0 and alpha1 are 8-bit unsigned bytes converted to alpha
790        components by multiplying by 1/255.
791
792        The 6 "bits" bytes of the block are decoded into one 48-bit integer:
793
794          bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 +
795                          256 * (bits_4 + 256 * bits_5))))
796
797        bits is a 48-bit unsigned integer, from which a three-bit control code
798        is extracted for a texel at location (x,y) in the block using:
799
800            code(x,y) = bits[3*(4*y+x)+2 .. 3*(4*y+x)+0]
801
802        where bit 47 is the most significant and bit 0 is the least
803        significant bit.
804
805        The alpha component for a texel at location (x,y) in the block is
806        given by:
807
808              alpha0,                   code(x,y) == 0
809              alpha1,                   code(x,y) == 1
810
811              (6*alpha0 + 1*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 2
812              (5*alpha0 + 2*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 3
813              (4*alpha0 + 3*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 4
814              (3*alpha0 + 4*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 5
815              (2*alpha0 + 5*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 6
816              (1*alpha0 + 6*alpha1)/7,  alpha0 > alpha1 and code(x,y) == 7
817
818              (4*alpha0 + 1*alpha1)/5,  alpha0 <= alpha1 and code(x,y) == 2
819              (3*alpha0 + 2*alpha1)/5,  alpha0 <= alpha1 and code(x,y) == 3
820              (2*alpha0 + 3*alpha1)/5,  alpha0 <= alpha1 and code(x,y) == 4
821              (1*alpha0 + 4*alpha1)/5,  alpha0 <= alpha1 and code(x,y) == 5
822              0.0,                      alpha0 <= alpha1 and code(x,y) == 6
823              1.0,                      alpha0 <= alpha1 and code(x,y) == 7
824
825
826Implementation Note
827
828    This extension allows TexSubImage2D and CompressedTexSubImage2D to perform
829    partial updates to compressed images, but generally requires that the
830    updated area be aligned to 4x4 block boundaries.  If the width or height
831    is not a multiple of four, there will be 4x4 blocks at the edge of the
832    image that contain "extra" texels that are not part of the image.  This
833    spec has an exception allowing edits that partially cover such blocks as
834    long as the edit covers all texels in the block belonging to the image.
835    For example, in a 2D texture of size 70x50, it is legal to update the
836    single partial block covering the four texels from (68,48) to (69,49) by
837    setting (<xoffset>, <yoffset>) to (68,48) and <width> and <height> to 2.
838
839    When this extension was originally written, non-bordered textures were
840    required to have widths and heights that were powers of two.  Therefore,
841    the only cases where partial blocks could occur were if the width or
842    height of the texture image was one or two.  The original spec language
843    allowed partial block edits only if the width or height of the region
844    edited was equal to the full texture size.  That language didn't handle
845    cases such as the 70x50 example above.
846
847    This specification was updated in April, 2009 to allow such edits.
848    Multiple OpenGL implementers correctly implemented the original
849    restriction, and partial edits that include partially covered tiles will
850    result in INVALID_OPERATION errors on older drivers.
851
852
853NVIDIA Implementation Note
854
855    NVIDIA GeForce 6 and 7 Series of GPUs (NV4x- and G7x-based GPUs)
856    and their Quadro counterparts (Quadro FX 4000, 4400, 4500; Quadro
857    NVS 440; etc.) do not ignore the order of the 16-bit RGB values
858    color0 and color1 when decoding DXT3 and DXT5 texture formats (i.e.,
859    COMPRESSED_RGBA_S3TC_DXT5_EXT and COMPRESSED_RGBA_S3TC_DXT5_EXT).
860    This is at variance with the specification language saying:
861
862        Each RGB image data block is encoded according to the
863        COMPRESSED_RGB_S3TC_DXT1_EXT format, with the exception that
864        the two code bits always use the non-transparent encodings.
865        In other words, they are treated as though color0 > color1,
866        regardless of the actual values of color0 and color1.
867
868    With these NV4x and G7x GPUs, when decoding the DXT3 and DXT5 formats,
869    if color0 <= color1 then the code(x,y) values of 2 and 3 encode
870    (RGB0+RGB1)/2 and BLACK respectively (as is the case for DXT1).
871
872    All other NVIDIA GPUs (those based on GPU designs other than NV4x
873    and G7x) implement DXT3 and DXT5 decoding strictly according to the
874    specification.  Specifically, the order of color0 and color1 does
875    not affect the decoding of the DXT3 and DXT5 format, consistent with
876    the specification paragraph cited above.
877
878    To ensure reliable decoding of DXT3 and DXT5 textures, please avoid
879    encoding an RGB image data block with color0 <= color1 when the
880    block also uses code(x,y) values of 2 and 3.
881
882Revision History
883
884    1.6   07/15/13 sgrajewski Added OpenGL ES 2.0.25 and 3.0.2 dependencies.
885
886    1.5   11/03/09 pbrown     Fix typo in the encoding description of the
887                              3-bit "bits" fields in DXT5.
888
889    1.4   04/13/09 pbrown     Add interaction with non-power-of-two textures
890                              from OpenGL 2.0 / ARB_texture_non_power_of_two.
891                              Allow CompressedTexSubImage2D to perform edits
892                              that include partial tiles at the edge of the
893                              image as long as the specified width/height
894                              parameters line up with the edge.  Thanks to
895                              Emil Persson for finding this issue.
896
897    1.3   07/07/07 mjk        Correct NVIDIA note about DXT3/5 decoding issue.
898
899    1.2   01/26/06 mjk        Add NVIDIA note about DXT3/5 decoding issue.
900
901    1.1,  11/16/01 pbrown:    Updated contact info, clarified where texels
902                              fall within a single block.
903
904    1.0,  07/07/00 prbrown1:  Published final version agreed to by working
905                              group members.
906
907    0.9,  06/24/00 prbrown1:  Documented that block-aligned TexSubImage calls
908                              do not modify existing texels outside the
909                              modified blocks.  Added caveat to allow for a
910                              (0,0)-anchored TexSubImage operation of
911                              arbitrary size.
912
913    0.7,  04/11/00 prbrown1:  Added issues on DXT1, DXT3, and DXT5 encodings
914                              where the MSDN documentation doesn't match what
915                              is really done.  Added enum values from the
916                              extension registry.
917
918    0.4,  03/28/00 prbrown1:  Updated to reflect final version of the
919                              ARB_texture_compression extension.  Allowed
920                              block-aligned TexSubImage calls.
921
922    0.3,  03/07/00 prbrown1:  Resolved issues pertaining to the format of RGB
923                              blocks in the DXT3 and DXT5 formats (they don't
924                              ever use the "transparent" encoding).  Fixed
925                              decoding of DXT1 blocks.  Pointed out issue of
926                              "transparent" texels in DXT1 encodings having
927                              different behaviors for RGB and RGBA internal
928                              formats.
929
930    0.2,  02/23/00 prbrown1:  Minor revisions; added several issues.
931
932    0.11, 02/17/00 prbrown1:  Slight modification to error semantics
933                              (INVALID_ENUM instead of INVALID_OPERATION).
934
935    0.1,  02/15/00 prbrown1:  Initial revision.
936