• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    EXT_texture_compression_bptc
4
5Name Strings
6
7    GL_EXT_texture_compression_bptc
8
9Contact
10
11    Daniel Koch, NVIDIA Corporation (dkoch 'at' nvidia.com)
12
13Contributors
14
15    Contributors to ARB_texture_compression_bptc
16    Daniel Koch, NVIDIA
17    Jason Schmidt, NVIDIA
18    Slawomir Grajewski, Intel
19
20Notice
21
22    Copyright (c) 2010-2013 The Khronos Group Inc. Copyright terms at
23        http://www.khronos.org/registry/speccopyright.html
24
25Status
26
27    Complete.
28
29Version
30
31    Last Modified Date:         December 10, 2019
32    Revision:                   2
33
34Number
35
36    OpenGL ES Extension #287
37
38Dependencies
39
40    OpenGL ES 3.0 is required.
41
42    This extension is written against the OpenGL ES 3.2 Specification
43    (Nov. 3, 2016).
44
45Overview
46
47    This extension provides additional texture compression functionality
48    specific to the BPTC and BPTC_FLOAT compressed texture formats (called BC7
49    and BC6H respectively in Microsoft's DirectX API).
50
51    Traditional block compression methods as typified by s3tc and latc
52    compress a block of pixels into indicies along a gradient. This works well
53    for smooth images, but can have quality issues along sharp edges and
54    strong chrominance transitions. To improve quality in these problematic
55    cases, the BPTC formats can divide each block into multiple partitions,
56    each of which are compressed using an independent gradient.
57
58    In addition, it is desirable to directly support high dynamic range
59    imagery in compressed formats, which is accomplished by the BPTC_FLOAT
60    formats.
61
62IP Status
63
64    No known IP claims.
65
66New Procedures and Functions
67
68    None.
69
70New Tokens
71
72    Accepted by the <internalformat> parameter of TexImage2D, TexImage3D,
73    TexStorage2D, TexStorage3D, CompressedTexImage2D, and CompressedTexImage3D
74    and the <format> parameter of CompressedTexSubImage2D and
75    CompressedTexSubImage3D:
76
77        COMPRESSED_RGBA_BPTC_UNORM_EXT                     0x8E8C
78        COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT               0x8E8D
79        COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT               0x8E8E
80        COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT             0x8E8F
81
82
83Additions to Chapter 8 of the OpenGL ES 3.2 Specification (Rasterization)
84
85    Add to Section 8.4, Table 8.2: Valid combinations of format, type,
86    and sized internalFormat
87
88                           External
89                           Bytes
90    Format  Type           Per Pixel  Internal Format
91    ------  -------------  ---------  --------------------------------------
92    RGBA    UNSIGNED_BYTE  8          COMPRESSED_RGBA_BPTC_UNORM_EXT
93    RGBA    UNSIGNED_BYTE  8          COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT
94    RGB     FLOAT          8          COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT
95    RGB     FLOAT          8          COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT
96
97
98    Add to Section 8.7, Table 8.17: Compressed internal formats
99
100    Compressed Internal Format             Base      Block    Border  3D   Cube
101                                           Internal  Width x  Type    Tex  Map
102                                           Format    Height                Array
103                                                                           Tex
104    ---------------------------------      --------  -------  ------  ---  -----
105    COMPRESSED_RGBA_BPTC_UNORM_EXT         RGBA      4x4      unorm   yes  yes
106    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT   RGBA      4x4      unorm   yes  yes
107    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT   RGB       4x4      float   yes  yes
108    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT RGB       4x4      float   yes  yes
109
110
111    Add to Section 8.7, Compressed Texture Images (adding to the end of the
112    Errors section)
113
114    If <internalformat> is COMPRESSED_RGBA_BPTC_UNORM_EXT,
115    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
116    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
117    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT the compressed texture is stored
118    using the specified BPTC compressed texture image format.  The BPTC
119    texture compression algorithm supports only 2D images without borders,
120    though 3D images can be compressed as multiple slices of compressed 2D
121    images.  CompressedTexImage2D and CompressedTexImage3D will produce an
122    INVALID_OPERATION error if <border> is non-zero.
123
124    If the internal format of the texture image being modified is
125    COMPRESSED_RGBA_BPTC_UNORM_EXT, COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
126    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
127    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT the texture is stored using the
128    specified BPTC compressed texture image formats. Since BPTC
129    images are easily edited along 4x4 texel boundaries, the limitations on
130    CompressedTexSubImage2D and CompressedTexSubImage3D are relaxed.
131    CompressedTexSubImage2D and CompressedTexSubImage3D will result in an
132    INVALID_OPERATION error only if one of the following conditions occurs:
133
134        * <width> is not a multiple of four, and <width> plus <xoffset> is not
135          equal to TEXTURE_WIDTH;
136
137        * <height> is not a multiple of four, and <height> plus <yoffset> is
138          not equal to TEXTURE_HEIGHT; or
139
140        * <xoffset> or <yoffset> is not a multiple of four.
141
142    The contents of any 4x4 block of texels of a BPTC compressed texture image
143    that does not intersect the area being modified are preserved during valid
144    TexSubImage2D/3D calls.
145
146Additions to Appendix C of the OpenGL ES 3.2 Specification (Compressed Texture
147Image Formats)
148
149    Add a new Section C.4 (BPTC Compressed Texture Image Formats)
150
151    BPTC formats are described in the "BPTC Compressed Texture Image Formats"
152    chapter of the Khronos Data Format Specification. The mapping between
153    OpenGL ES BPTC formats and that specification is shown in table C.4.
154
155    OpenGL ES format                        Data Format Specification
156                                            Description
157    -------------------------------         -------------------------
158    COMPRESSED_RGBA_BPTC_UNORM_EXT          BC7
159    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT    BC7 sRGB
160    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT    BC6H signed
161    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT  BC6H unsigned
162
163Additions to the AGL/GLX/WGL/EGL Specifications
164
165    None.
166
167Errors
168
169    INVALID_OPERATION is generated by CompressedTexImage2D if
170    <internalformat> is COMPRESSED_RGBA_BPTC_UNORM_EXT,
171    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
172    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
173    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT and <border> is not equal to zero.
174
175    INVALID_OPERATION is generated by TexSubImage2D if
176    TEXTURE_INTERNAL_FORMAT is COMPRESSED_RGBA_BPTC_UNORM_EXT,
177    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
178    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
179    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT and any of the following apply:
180
181        * <width> is not a multiple of four, <width> plus <xoffset> is not
182           equal to TEXTURE_WIDTH, and either <xoffset> or <yoffset> is
183           non-zero;
184
185        * <height> is not a multiple of four, <height> plus <yoffset> is not
186          equal to TEXTURE_HEIGHT, and either <xoffset> or <yoffset> is
187          non-zero; or
188
189        * <xoffset> or <yoffset> is not a multiple of four.
190
191    INVALID_OPERATION is generated by CompressedTexSubImage2D if
192    TEXTURE_INTERNAL_FORMAT is COMPRESSED_RGBA_BPTC_UNORM_EXT,
193    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
194    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
195    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT and any of the following apply:
196
197        * <width> is not a multiple of four, and <width> plus <xoffset> is not
198          equal to TEXTURE_WIDTH;
199
200        * <height> is not a multiple of four, and <height> plus <yoffset> is
201          not equal to TEXTURE_HEIGHT; or
202
203        * <xoffset> or <yoffset> is not a multiple of four.
204
205    INVALID_OPERATION is generated by TexImage2D, TexImage3D, TexStorage2D, and
206    TexStorage3D if a BPTC format is used as the <internalFormat> parameter
207    with a <type> and <format> combination NOT listed:
208
209    InternalFormat                          Format      Type
210    ----------------------                  ----------  --------------
211    COMPRESSED_RGBA_BPTC_UNORM_EXT          RGBA        UNSIGNED_BYTE
212    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT    RGBA        UNSIGNED_BYTE
213    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT    RGB         FLOAT
214    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT  RGB         FLOAT
215
216New Implementation Dependent State
217
218    None
219
220Appendix
221
222    BPTC Compressed Texture Image Format
223
224    Compressed texture images stored using the BPTC compressed image formats
225    are represented as a collection of 4x4 texel blocks, where each block
226    contains 128 bits of texel data.  The image is encoded as a normal 2D
227    raster image in which each 4x4 block is treated as a single pixel.  If a
228    BPTC image has a width or height that is not a multiple of four, the data
229    corresponding to texels outside the image are irrelevant and undefined.
230
231    When a BPTC image with a width of <w>, height of <h>, and block size of
232    <blocksize> (16 bytes) is decoded, the corresponding image size (in bytes)
233    is:
234
235        ceil(<w>/4) * ceil(<h>/4) * blocksize.
236
237    When decoding a BPTC image, the block containing the texel at offset
238    (<x>, <y>) begins at an offset (in bytes) relative to the base of the
239    image of:
240
241        blocksize * (ceil(<w>/4) * floor(<y>/4) + floor(<x>/4)).
242
243    The data corresponding to a specific texel (<x>, <y>) are extracted from a
244    4x4 texel block using a relative (x,y) value of
245
246        (<x> modulo 4, <y> modulo 4).
247
248    There are two distinct BPTC image formats each of which has two
249    variants. COMPRESSED_RGBA_BPTC_UNORM_EXT and
250    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT compress 8-bit fixed-point
251    data. COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT and
252    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT compress high dynamic range
253    floating point values. The formats are similar, so the description of the
254    float format will reference significant sections of the UNORM description.
255
256    COMPRESSED_RGBA_BPTC_UNORM_EXT (and the SRGB_ALPHA equivalent): Each 4x4
257    block of texels consists of 128 bits of RGBA or SRGB_ALPHA image data.
258
259    Each block contains enough information to select and decode a pair of
260    colors called endpoints, interpolate between those endpoints in a variety
261    of ways, then remap the result into the final output.
262
263    Each block can contain data in one of eight modes. The mode is identified
264    by the lowest bits of the lowest byte. It is encoded as zero or more zeros
265    followed by a one. For example, using x to indicate a bit not included in
266    the mode number, mode 0 is encoded as xxxxxxx1 in the low byte in binary,
267    mode 5 is xx100000, and mode 7 is 10000000. Encoding the low byte as zero
268    is reserved and should not be used when encoding a BPTC texture.
269
270    All further decoding is driven by the values derived from the mode listed
271    in Table.M below. The fields in the block are always in the same order for
272    all modes. Starting at the lowest bit after the mode and going up from LSB
273    to MSB in byte stream order, these fields are: partition number, rotation,
274    index selection, color, alpha, per-endpoint P-bit, shared P-bit, primary
275    indices, and secondary indices. The number of bits to be read in each
276    field is determined directly from the table.
277
278    Each block can be divided into between 1 and 3 groups of pixels with
279    independent compression parameters called subsets. A texel in a block with
280    one subset is always considered to be in subset zero. Otherwise, a number
281    determined by the number of partition bits is used to look up in the
282    partition tables Table.P2 or Table.P3 for 2 and 3 subsets
283    respectively. This partitioning is indexed by the X and Y within the block
284    to generate the subset index.
285
286    Each block has two colors for each subset, stored first by endpoint, then
287    by subset, then by color. For example, a format with two subsets and five
288    color bits would have five bits of red for endpoint 0 of the first subset,
289    then five bits of red for endpoint 1, then the two ends of the second
290    subset, then green and blue stored similarly. If a block has non-zero
291    alpha bits, the alpha data follows the color data with the same
292    organization. If not, alpha is overridden to 1.0. These bits are treated
293    as the high bits of a fixed-point value in a byte. If the format has
294    shared P-bits, there are two endpoint bits, the lower of which applies to
295    both endpoints of subset 0 and the upper of which applies to both
296    endpoints of subset 1. If the format has a per-endpoint P-bits, then there
297    are 2*subsets P-bits stored in the same order as color and alpha. Both
298    kinds of P-bits are added as a bit below the color data stored in the
299    byte. So, for a format with 5 red bits, the P-bit ends up in bit 2. For
300    final scaling, the top bits of the value are replicated into any remaining
301    bits in the byte. For the preceding example, bits 6 and 7 would be written
302    to bits 0 and 1.
303
304    The endpoint colors are interpolated using index values stored in the
305    block. The index bits are stored in x-major order. Each index has the
306    number of bits indicated by the mode except for one special index per
307    subset called the anchor index. Since the ordering of the endpoints is
308    unimportant, we can save one bit on one index per subset by ordering the
309    endpoints such that the highest bit is guaranteed to be zero. In partition
310    zero, the anchor index is always index zero. In other partitions, the
311    anchor index is specified by tables Table.A2 and Table.A3. If secondary
312    index bits are present, they are read in the same manner. The anchor index
313    information is only used to determine the number of bits each index has
314    when it's read from the block data.
315
316    The endpoint color and alpha values used for final interpolation are the
317    decoded values corresponding to the applicable subset as selected
318    above. The index value for interpolating color comes from the secondary
319    index for the texel if the format has an index selection bit and its value
320    is one and from the primary index otherwise. The alpha index comes from
321    the secondary index if the block has a secondary index and the block
322    either doesn't have an index selection bit or that bit is zero and the
323    primary index otherwise.
324
325    Interpolation is always performed using a 6-bit interpolation factor. The
326    effective interpolation factors for 2, 3, and 4 bit indices are given
327    below:
328
329        2: 0, 21, 43, 64
330        3: 0, 9, 18, 27, 37, 46, 55, 64
331        4: 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64
332
333    The interpolation results in an RGBA color. If rotation bits are present,
334    this color is remapped according to:
335
336        0: no change
337        1: swap(a,r)
338        2: swap(a,g)
339        3: swap(a,b)
340
341    These 8-bit values show up in the shader interpreted as either RGBA8 or
342    SRGB8_ALPHA8 for COMPRESSED_RGBA_BPTC_UNORM_EXT and
343    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT respectively.
344
345
346    Table.M
347
348    Mode NS PB RB ISB CB AB EPB SPB IB IB2
349    ---- -- -- -- --- -- -- --- --- -- ---
350    0    3  4  0  0   4  0  1   0   3  0
351    1    2  6  0  0   6  0  0   1   3  0
352    2    3  6  0  0   5  0  0   0   2  0
353    3    2  6  0  0   7  0  1   0   2  0
354    4    1  0  2  1   5  6  0   0   2  3
355    5    1  0  2  0   7  8  0   0   2  2
356    6    1  0  0  0   7  7  1   0   4  0
357    7    2  6  0  0   5  5  1   0   2  0
358
359    The columns are as as follows:
360
361    Mode: As described above
362
363    NS: Number of subsets in each partition
364
365    PB: Partition bits
366
367    RB: Rotation bits
368
369    ISB: Index selection bits
370
371    CB: Color bits
372
373    AB: Alpha bits
374
375    EPB: Endpoint P-bits
376
377    SPB: Shared P-bits
378
379    IB: Index bits per element
380
381    IB2: Secondary index bits per element
382
383
384    Table.P2
385
386    (each row is one 4x4 block)
387
388
389    0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1
390    0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1
391    0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1
392    0,0,0,1,0,0,1,1,0,0,1,1,0,1,1,1
393    0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,1
394    0,0,1,1,0,1,1,1,0,1,1,1,1,1,1,1
395    0,0,0,1,0,0,1,1,0,1,1,1,1,1,1,1
396    0,0,0,0,0,0,0,1,0,0,1,1,0,1,1,1
397    0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1
398    0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1
399    0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1
400    0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1
401    0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1
402    0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1
403    0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1
404    0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1
405    0,0,0,0,1,0,0,0,1,1,1,0,1,1,1,1
406    0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0
407    0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0
408    0,1,1,1,0,0,1,1,0,0,0,1,0,0,0,0
409    0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0
410    0,0,0,0,1,0,0,0,1,1,0,0,1,1,1,0
411    0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0
412    0,1,1,1,0,0,1,1,0,0,1,1,0,0,0,1
413    0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0
414    0,0,0,0,1,0,0,0,1,0,0,0,1,1,0,0
415    0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0
416    0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0
417    0,0,0,1,0,1,1,1,1,1,1,0,1,0,0,0
418    0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0
419    0,1,1,1,0,0,0,1,1,0,0,0,1,1,1,0
420    0,0,1,1,1,0,0,1,1,0,0,1,1,1,0,0
421    0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
422    0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1
423    0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0
424    0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0
425    0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0
426    0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0
427    0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1
428    0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1
429    0,1,1,1,0,0,1,1,1,1,0,0,1,1,1,0
430    0,0,0,1,0,0,1,1,1,1,0,0,1,0,0,0
431    0,0,1,1,0,0,1,0,0,1,0,0,1,1,0,0
432    0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0
433    0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0
434    0,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1
435    0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1
436    0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0
437    0,1,0,0,1,1,1,0,0,1,0,0,0,0,0,0
438    0,0,1,0,0,1,1,1,0,0,1,0,0,0,0,0
439    0,0,0,0,0,0,1,0,0,1,1,1,0,0,1,0
440    0,0,0,0,0,1,0,0,1,1,1,0,0,1,0,0
441    0,1,1,0,1,1,0,0,1,0,0,1,0,0,1,1
442    0,0,1,1,0,1,1,0,1,1,0,0,1,0,0,1
443    0,1,1,0,0,0,1,1,1,0,0,1,1,1,0,0
444    0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,0
445    0,1,1,0,1,1,0,0,1,1,0,0,1,0,0,1
446    0,1,1,0,0,0,1,1,0,0,1,1,1,0,0,1
447    0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1
448    0,0,0,1,1,0,0,0,1,1,1,0,0,1,1,1
449    0,0,0,0,1,1,1,1,0,0,1,1,0,0,1,1
450    0,0,1,1,0,0,1,1,1,1,1,1,0,0,0,0
451    0,0,1,0,0,0,1,0,1,1,1,0,1,1,1,0
452    0,1,0,0,0,1,0,0,0,1,1,1,0,1,1,1
453
454    Table.P3
455
456    0,0,1,1,0,0,1,1,0,2,2,1,2,2,2,2
457    0,0,0,1,0,0,1,1,2,2,1,1,2,2,2,1
458    0,0,0,0,2,0,0,1,2,2,1,1,2,2,1,1
459    0,2,2,2,0,0,2,2,0,0,1,1,0,1,1,1
460    0,0,0,0,0,0,0,0,1,1,2,2,1,1,2,2
461    0,0,1,1,0,0,1,1,0,0,2,2,0,0,2,2
462    0,0,2,2,0,0,2,2,1,1,1,1,1,1,1,1
463    0,0,1,1,0,0,1,1,2,2,1,1,2,2,1,1
464    0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2
465    0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2
466    0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2
467    0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2
468    0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2
469    0,1,2,2,0,1,2,2,0,1,2,2,0,1,2,2
470    0,0,1,1,0,1,1,2,1,1,2,2,1,2,2,2
471    0,0,1,1,2,0,0,1,2,2,0,0,2,2,2,0
472    0,0,0,1,0,0,1,1,0,1,1,2,1,1,2,2
473    0,1,1,1,0,0,1,1,2,0,0,1,2,2,0,0
474    0,0,0,0,1,1,2,2,1,1,2,2,1,1,2,2
475    0,0,2,2,0,0,2,2,0,0,2,2,1,1,1,1
476    0,1,1,1,0,1,1,1,0,2,2,2,0,2,2,2
477    0,0,0,1,0,0,0,1,2,2,2,1,2,2,2,1
478    0,0,0,0,0,0,1,1,0,1,2,2,0,1,2,2
479    0,0,0,0,1,1,0,0,2,2,1,0,2,2,1,0
480    0,1,2,2,0,1,2,2,0,0,1,1,0,0,0,0
481    0,0,1,2,0,0,1,2,1,1,2,2,2,2,2,2
482    0,1,1,0,1,2,2,1,1,2,2,1,0,1,1,0
483    0,0,0,0,0,1,1,0,1,2,2,1,1,2,2,1
484    0,0,2,2,1,1,0,2,1,1,0,2,0,0,2,2
485    0,1,1,0,0,1,1,0,2,0,0,2,2,2,2,2
486    0,0,1,1,0,1,2,2,0,1,2,2,0,0,1,1
487    0,0,0,0,2,0,0,0,2,2,1,1,2,2,2,1
488    0,0,0,0,0,0,0,2,1,1,2,2,1,2,2,2
489    0,2,2,2,0,0,2,2,0,0,1,2,0,0,1,1
490    0,0,1,1,0,0,1,2,0,0,2,2,0,2,2,2
491    0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0
492    0,0,0,0,1,1,1,1,2,2,2,2,0,0,0,0
493    0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0
494    0,1,2,0,2,0,1,2,1,2,0,1,0,1,2,0
495    0,0,1,1,2,2,0,0,1,1,2,2,0,0,1,1
496    0,0,1,1,1,1,2,2,2,2,0,0,0,0,1,1
497    0,1,0,1,0,1,0,1,2,2,2,2,2,2,2,2
498    0,0,0,0,0,0,0,0,2,1,2,1,2,1,2,1
499    0,0,2,2,1,1,2,2,0,0,2,2,1,1,2,2
500    0,0,2,2,0,0,1,1,0,0,2,2,0,0,1,1
501    0,2,2,0,1,2,2,1,0,2,2,0,1,2,2,1
502    0,1,0,1,2,2,2,2,2,2,2,2,0,1,0,1
503    0,0,0,0,2,1,2,1,2,1,2,1,2,1,2,1
504    0,1,0,1,0,1,0,1,0,1,0,1,2,2,2,2
505    0,2,2,2,0,1,1,1,0,2,2,2,0,1,1,1
506    0,0,0,2,1,1,1,2,0,0,0,2,1,1,1,2
507    0,0,0,0,2,1,1,2,2,1,1,2,2,1,1,2
508    0,2,2,2,0,1,1,1,0,1,1,1,0,2,2,2
509    0,0,0,2,1,1,1,2,1,1,1,2,0,0,0,2
510    0,1,1,0,0,1,1,0,0,1,1,0,2,2,2,2
511    0,0,0,0,0,0,0,0,2,1,1,2,2,1,1,2
512    0,1,1,0,0,1,1,0,2,2,2,2,2,2,2,2
513    0,0,2,2,0,0,1,1,0,0,1,1,0,0,2,2
514    0,0,2,2,1,1,2,2,1,1,2,2,0,0,2,2
515    0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,2
516    0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1
517    0,2,2,2,1,2,2,2,0,2,2,2,1,2,2,2
518    0,1,0,1,2,2,2,2,2,2,2,2,2,2,2,2
519    0,1,1,1,2,0,1,1,2,2,0,1,2,2,2,0
520
521    Table.A2 (Anchor index values for the second subset of two-subset
522    partitioning)
523
524    (wrapped for readability - values run right then down)
525
526    15,15,15,15,15,15,15,15,
527    15,15,15,15,15,15,15,15,
528    15, 2, 8, 2, 2, 8, 8,15,
529     2, 8, 2, 2, 8, 8, 2, 2,
530    15,15, 6, 8, 2, 8,15,15,
531     2, 8, 2, 2, 2,15,15, 6,
532     6, 2, 6, 8,15,15, 2, 2,
533    15,15,15,15,15, 2, 2,15,
534
535    Table.A3a (Anchor index values for the second subset of three-subset
536    partitioning)
537
538    (wrapped for readability - values run right then down)
539
540     3, 3,15,15, 8, 3,15,15,
541     8, 8, 6, 6, 6, 5, 3, 3,
542     3, 3, 8,15, 3, 3, 6,10,
543     5, 8, 8, 6, 8, 5,15,15,
544     8,15, 3, 5, 6,10, 8,15,
545    15, 3,15, 5,15,15,15,15,
546     3,15, 5, 5, 5, 8, 5,10,
547     5,10, 8,13,15,12, 3, 3,
548
549    Table.A3b (Anchor index values for the third subset of three-subset
550    partitioning)
551
552    (wrapped for readability - values run right then down)
553
554    15, 8, 8, 3,15,15, 3, 8,
555    15,15,15,15,15,15,15, 8,
556    15, 8,15, 3,15, 8,15, 8,
557     3,15, 6,10,15,15,10, 8,
558    15, 3,15,10,10, 8, 9,10,
559     6,15, 8,15, 3, 6, 6, 8,
560    15, 3,15,15,15,15,15,15,
561    15,15,15,15, 3,15,15, 8,
562
563    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT and
564    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: Each 4x4 block of texels consists
565    of 128 bits of RGB data. These formats are very similar and will be
566    described together. In the description and pseudocode below, <signed> will
567    be used as a condition which is true for the SIGNED format and false for
568    the UNSIGNED format. Both formats only contain RGB data, so the returned
569    alpha value is 1.0. If a block uses a reserved or invalid encoding, the
570    return value is (0,0,0,1).
571
572    Each block can contain data in one of 14 modes. The mode number is encoded
573    in either the low two bits or the low five bits. If the low two bits are
574    less than two, that is the mode number, otherwise the low five bits the
575    mode number. Mode numbers not listed in Table.MF are reserved (19, 23, 27,
576    and 31).
577
578    The data for the compressed blocks is stored in a different format for
579    each mode. The formats are specified in Table.F. The format strings are
580    intended to be read from left to right with the LSB on the left. Each
581    element is of the form v[a:b]. If a>=b, this indicates to extract b-a+1
582    bits from the block at that location and put it in the corresponding bits
583    of the variable v. If a<b, then the bits are reversed. v[a] is used as a
584    shorthand for the one bit v[a:a]. As an example, m[1:0],g2[4] would move
585    the low two bits from the block into the low two bits of m then the next
586    bit of the block into bit 4 of g2. The variable names given in the table
587    will be referred to in the language below.
588
589    Subsets and indices work in much the same way as described for the
590    fixed-point formats above. If a float block has no partition bits, then it
591    is a single-subset block. If it has partition bits, then it is a 2 subset
592    block. The partition index references the first half of Table.P2. Indices
593    are read in the same way as the fixed-point formats including obeying the
594    anchor values for index 0 and as needed by Table.A2.
595
596    In a single-subset blocks, the two endpoints are contained in r0,g0,b0
597    (hence e0) and r1,g1,b1 (hence e1). In a two-subset block, the endpoints
598    for the second subset are in r2,g2,b2 and r3,g3,b3. The value in e0 is
599    sign-extended if the format of the texture is signed. The values in e1 and
600    e2 and e3 if the block is two-subset are sign-extended if the format of
601    the texture is signed or if the block mode has transformed endpoints. If
602    the mode has transformed endpoints, the values from e0 are used as a base
603    to offset all other endpoints, wrapped at the number of endpoint bits. For
604    example, r1 = (r0+r1) & ((1<<EPB)-1).
605
606    Next, the endpoints are unquantized to maximize the usage of the bits and
607    to ensure that the negative ranges are oriented properly to interpolate as
608    a two's complement value. The following pseudocode assumes the computation
609    is being done using sufficiently large intermediate values to avoid
610    overflow. For the unsigned float format, we unquantize a value x to unq
611    by:
612
613     if (EPB >= 15)
614        unq = x;
615     else if (x == 0)
616        unq = 0;
617     else if (x == ((1<<EPB)-1))
618        unq = 0xFFFF;
619     else
620        unq = ((x << 15) + 0x4000) >> (EPB-1);
621
622    The signed float unquantization is similar, but needs to worry about
623    orienting the negative range:
624
625     s = 0;
626     if (EPB >= 16)
627        unq = x;
628     else {
629       if (x < 0) {
630         s = 1;
631         x = -x;
632       }
633
634       if (x == 0)
635         unq = 0;
636       else if (x >= ((1<<(EPB-1))-1))
637         unq = 0x7FFF;
638       else
639         unq = ((x << 15) + 0x4000) >> (EPB-1);
640
641       if (s)
642         unq = -unq;
643     }
644
645    After the endpoints are unquantized, interpolation proceeds as in the
646    fixed-point formats above including the interpolation weight table.
647
648    The interpolated values are passed through a final unquantization
649    step. For the unsigned format, this step simply multiplies by 31/64. The
650    signed format negates negative components, multiplies by 31/32, then or's
651    in the sign bit if the original value was negative.
652
653    The resultant value should be a legal 16-bit half float which is then
654    returned as a float to the shader.
655
656    Table.MF
657
658    MN Tr PB EPB Delta Bits
659    -- -- -- --- ----------
660    0  1  5  10  {5, 5, 5}
661    1  1  5  7   {6, 6, 6}
662    2  1  5  11  {5, 4, 4}
663    6  1  5  11  {4, 5, 4}
664    10 1  5  11  {4, 4, 5}
665    14 1  5  9   {5, 5, 5}
666    18 1  5  8   {6, 5, 5}
667    22 1  5  8   {5, 6, 5}
668    26 1  5  8   {5, 5, 6}
669    30 0  5  6   {6, 6, 6}
670    3  0  0  10  {10, 10, 10}
671    7  1  0  11  {9, 9, 9}
672    11 1  0  12  {8, 8, 8}
673    15 1  0  16  {4, 4, 4}
674
675    MN: Mode number
676    Tr: Transformed endpoints
677    PB: Partition bits
678    EPB: Endpoint bits
679
680
681    Table.F
682
683    MN Format
684    -- ------------------------------------------------------------------------
685    0  m[1:0],g2[4],b2[4],b3[4],r0[9:0],g0[9:0],b0[9:0],r1[4:0],g3[4],g2[3:0],
686       g1[4:0],b3[0],g3[3:0],b1[4:0],b3[1],b2[3:0],r2[4:0],b3[2],r3[4:0],b3[3]
687
688    1  m[1:0],g2[5],g3[4],g3[5],r0[6:0],b3[0],b3[1],b2[4],g0[6:0],b2[5],b3[2],
689       g2[4],b0[6:0],b3[3],b3[5],b3[4],r1[5:0],g2[3:0],g1[5:0],g3[3:0],b1[5:0],
690       b2[3:0],r2[5:0],r3[5:0]
691
692    2  m[4:0],r0[9:0],g0[9:0],b0[9:0],r1[4:0],r0[10],g2[3:0],g1[3:0],g0[10],
693       b3[0],g3[3:0],b1[3:0],b0[10],b3[1],b2[3:0],r2[4:0],b3[2],r3[4:0],b3[3]
694
695    6  m[4:0],r0[9:0],g0[9:0],b0[9:0],r1[3:0],r0[10],g3[4],g2[3:0],g1[4:0],
696       g0[10],g3[3:0],b1[3:0],b0[10],b3[1],b2[3:0],r2[3:0],b3[0],b3[2],r3[3:0],
697       g2[4],b3[3]
698
699    10 m[4:0],r0[9:0],g0[9:0],b0[9:0],r1[3:0],r0[10],b2[4],g2[3:0],g1[3:0],
700       g0[10],b3[0],g3[3:0],b1[4:0],b0[10],b2[3:0],r2[3:0],b3[1],b3[2],r3[3:0],
701       b3[4],b3[3]
702
703    14 m[4:0],r0[8:0],b2[4],g0[8:0],g2[4],b0[8:0],b3[4],r1[4:0],g3[4],g2[3:0],
704       g1[4:0],b3[0],g3[3:0],b1[4:0],b3[1],b2[3:0],r2[4:0],b3[2],r3[4:0],b3[3]
705
706    18 m[4:0],r0[7:0],g3[4],b2[4],g0[7:0],b3[2],g2[4],b0[7:0],b3[3],b3[4],
707       r1[5:0],g2[3:0],g1[4:0],b3[0],g3[3:0],b1[4:0],b3[1],b2[3:0],r2[5:0],
708       r3[5:0]
709
710    22 m[4:0],r0[7:0],b3[0],b2[4],g0[7:0],g2[5],g2[4],b0[7:0],g3[5],b3[4],
711       r1[4:0],g3[4],g2[3:0],g1[5:0],g3[3:0],b1[4:0],b3[1],b2[3:0],r2[4:0],
712       b3[2],r3[4:0],b3[3]
713
714    26 m[4:0],r0[7:0],b3[1],b2[4],g0[7:0],b2[5],g2[4],b0[7:0],b3[5],b3[4],
715       r1[4:0],g3[4],g2[3:0],g1[4:0],b3[0],g3[3:0],b1[5:0],b2[3:0],r2[4:0],
716       b3[2],r3[4:0],b3[3]
717
718    30 m[4:0],r0[5:0],g3[4],b3[0],b3[1],b2[4],g0[5:0],g2[5],b2[5],b3[2],
719       g2[4],b0[5:0],g3[5],b3[3],b3[5],b3[4],r1[5:0],g2[3:0],g1[5:0],g3[3:0],
720       b1[5:0],b2[3:0],r2[5:0],r3[5:0]
721
722    3  m[4:0],r0[9:0],g0[9:0],b0[9:0],r1[9:0],g1[9:0],b1[9:0]
723
724    7  m[4:0],r0[9:0],g0[9:0],b0[9:0],r1[8:0],r0[10],g1[8:0],g0[10],b1[8:0],
725       b0[10]
726
727    11 m[4:0],r0[9:0],g0[9:0],b0[9:0],r1[7:0],r0[10:11],g1[7:0],g0[10:11],
728       b1[7:0],b0[10:11]
729
730    15 m[4:0],r0[9:0],g0[9:0],b0[9:0],r1[3:0],r0[10:15],g1[3:0],g0[10:15],
731       b1[3:0],b0[10:15]
732
733
734Issues
735
736    Note: These issues apply specifically to the definition of the
737    EXT_texture_compression_bptc specification, which is based on the OpenGL
738    extension ARB_texture_compression_bptc. For the full set of historical
739    issues, see ARB_texture_compression_bptc which can be found
740    in the OpenGL Registry.
741
742    (1) What functionality was changed relative to ARB_texture_compression_bptc?
743
744       BPTC formats are not accepted as <internalFormat> parameters by
745       CopyTexSubImage2D or CopyTexSubImage3D.
746       Queries to GL_NUM_COMPRESSED_TEXTURE_FORMATS and
747       GL_COMPRESSED_TEXTURE_FORMATS should return the BPTC formats.
748       More restrictions are placed on the use of BPTC formats with TexImage*
749       and TexStorage*.
750
751
752Revision History
753
754    Rev.    Date    Author       Changes
755    ----  --------  -----------  --------------------------------------------
756     2    12/10/19  pdaniell     Fix shared p-bits specification to match
757                                 DX and the Khronos Data Format spec.
758
759     1    04/10/17  jaschmidt    EXT version based on revision 9 of
760                                 ARB_texture_compression_bptc
761