15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_texture_compression_bptc
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_texture_compression_bptc
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Daniel Koch, NVIDIA Corporation (dkoch 'at' nvidia.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Contributors to ARB_texture_compression_bptc
165bd8deadSopenharmony_ci    Daniel Koch, NVIDIA
175bd8deadSopenharmony_ci    Jason Schmidt, NVIDIA
185bd8deadSopenharmony_ci    Slawomir Grajewski, Intel
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ciNotice
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ci    Copyright (c) 2010-2013 The Khronos Group Inc. Copyright terms at
235bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ciStatus
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ci    Complete.
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ciVersion
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ci    Last Modified Date:         December 10, 2019
325bd8deadSopenharmony_ci    Revision:                   2
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ciNumber
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ci    OpenGL ES Extension #287
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ciDependencies
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ci    OpenGL ES 3.0 is required.
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    This extension is written against the OpenGL ES 3.2 Specification
435bd8deadSopenharmony_ci    (Nov. 3, 2016).
445bd8deadSopenharmony_ci
455bd8deadSopenharmony_ciOverview
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ci    This extension provides additional texture compression functionality
485bd8deadSopenharmony_ci    specific to the BPTC and BPTC_FLOAT compressed texture formats (called BC7
495bd8deadSopenharmony_ci    and BC6H respectively in Microsoft's DirectX API).
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ci    Traditional block compression methods as typified by s3tc and latc
525bd8deadSopenharmony_ci    compress a block of pixels into indicies along a gradient. This works well
535bd8deadSopenharmony_ci    for smooth images, but can have quality issues along sharp edges and
545bd8deadSopenharmony_ci    strong chrominance transitions. To improve quality in these problematic
555bd8deadSopenharmony_ci    cases, the BPTC formats can divide each block into multiple partitions,
565bd8deadSopenharmony_ci    each of which are compressed using an independent gradient.
575bd8deadSopenharmony_ci
585bd8deadSopenharmony_ci    In addition, it is desirable to directly support high dynamic range
595bd8deadSopenharmony_ci    imagery in compressed formats, which is accomplished by the BPTC_FLOAT
605bd8deadSopenharmony_ci    formats.
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ciIP Status
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ci    No known IP claims.
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ciNew Procedures and Functions
675bd8deadSopenharmony_ci
685bd8deadSopenharmony_ci    None.
695bd8deadSopenharmony_ci
705bd8deadSopenharmony_ciNew Tokens
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci    Accepted by the <internalformat> parameter of TexImage2D, TexImage3D,
735bd8deadSopenharmony_ci    TexStorage2D, TexStorage3D, CompressedTexImage2D, and CompressedTexImage3D
745bd8deadSopenharmony_ci    and the <format> parameter of CompressedTexSubImage2D and
755bd8deadSopenharmony_ci    CompressedTexSubImage3D:
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci        COMPRESSED_RGBA_BPTC_UNORM_EXT                     0x8E8C
785bd8deadSopenharmony_ci        COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT               0x8E8D
795bd8deadSopenharmony_ci        COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT               0x8E8E
805bd8deadSopenharmony_ci        COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT             0x8E8F
815bd8deadSopenharmony_ci
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ciAdditions to Chapter 8 of the OpenGL ES 3.2 Specification (Rasterization)
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ci    Add to Section 8.4, Table 8.2: Valid combinations of format, type,
865bd8deadSopenharmony_ci    and sized internalFormat
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci                           External
895bd8deadSopenharmony_ci                           Bytes
905bd8deadSopenharmony_ci    Format  Type           Per Pixel  Internal Format
915bd8deadSopenharmony_ci    ------  -------------  ---------  --------------------------------------
925bd8deadSopenharmony_ci    RGBA    UNSIGNED_BYTE  8          COMPRESSED_RGBA_BPTC_UNORM_EXT
935bd8deadSopenharmony_ci    RGBA    UNSIGNED_BYTE  8          COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT
945bd8deadSopenharmony_ci    RGB     FLOAT          8          COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT
955bd8deadSopenharmony_ci    RGB     FLOAT          8          COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT
965bd8deadSopenharmony_ci
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ci    Add to Section 8.7, Table 8.17: Compressed internal formats
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci    Compressed Internal Format             Base      Block    Border  3D   Cube
1015bd8deadSopenharmony_ci                                           Internal  Width x  Type    Tex  Map
1025bd8deadSopenharmony_ci                                           Format    Height                Array
1035bd8deadSopenharmony_ci                                                                           Tex
1045bd8deadSopenharmony_ci    ---------------------------------      --------  -------  ------  ---  -----
1055bd8deadSopenharmony_ci    COMPRESSED_RGBA_BPTC_UNORM_EXT         RGBA      4x4      unorm   yes  yes
1065bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT   RGBA      4x4      unorm   yes  yes
1075bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT   RGB       4x4      float   yes  yes
1085bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT RGB       4x4      float   yes  yes
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ci    Add to Section 8.7, Compressed Texture Images (adding to the end of the
1125bd8deadSopenharmony_ci    Errors section)
1135bd8deadSopenharmony_ci
1145bd8deadSopenharmony_ci    If <internalformat> is COMPRESSED_RGBA_BPTC_UNORM_EXT,
1155bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
1165bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
1175bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT the compressed texture is stored
1185bd8deadSopenharmony_ci    using the specified BPTC compressed texture image format.  The BPTC
1195bd8deadSopenharmony_ci    texture compression algorithm supports only 2D images without borders,
1205bd8deadSopenharmony_ci    though 3D images can be compressed as multiple slices of compressed 2D
1215bd8deadSopenharmony_ci    images.  CompressedTexImage2D and CompressedTexImage3D will produce an
1225bd8deadSopenharmony_ci    INVALID_OPERATION error if <border> is non-zero.
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ci    If the internal format of the texture image being modified is
1255bd8deadSopenharmony_ci    COMPRESSED_RGBA_BPTC_UNORM_EXT, COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
1265bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
1275bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT the texture is stored using the
1285bd8deadSopenharmony_ci    specified BPTC compressed texture image formats. Since BPTC
1295bd8deadSopenharmony_ci    images are easily edited along 4x4 texel boundaries, the limitations on
1305bd8deadSopenharmony_ci    CompressedTexSubImage2D and CompressedTexSubImage3D are relaxed.
1315bd8deadSopenharmony_ci    CompressedTexSubImage2D and CompressedTexSubImage3D will result in an
1325bd8deadSopenharmony_ci    INVALID_OPERATION error only if one of the following conditions occurs:
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci        * <width> is not a multiple of four, and <width> plus <xoffset> is not
1355bd8deadSopenharmony_ci          equal to TEXTURE_WIDTH;
1365bd8deadSopenharmony_ci
1375bd8deadSopenharmony_ci        * <height> is not a multiple of four, and <height> plus <yoffset> is
1385bd8deadSopenharmony_ci          not equal to TEXTURE_HEIGHT; or
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci        * <xoffset> or <yoffset> is not a multiple of four.
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci    The contents of any 4x4 block of texels of a BPTC compressed texture image
1435bd8deadSopenharmony_ci    that does not intersect the area being modified are preserved during valid
1445bd8deadSopenharmony_ci    TexSubImage2D/3D calls.
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ciAdditions to Appendix C of the OpenGL ES 3.2 Specification (Compressed Texture
1475bd8deadSopenharmony_ciImage Formats)
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci    Add a new Section C.4 (BPTC Compressed Texture Image Formats)
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci    BPTC formats are described in the "BPTC Compressed Texture Image Formats"
1525bd8deadSopenharmony_ci    chapter of the Khronos Data Format Specification. The mapping between
1535bd8deadSopenharmony_ci    OpenGL ES BPTC formats and that specification is shown in table C.4.
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci    OpenGL ES format                        Data Format Specification
1565bd8deadSopenharmony_ci                                            Description
1575bd8deadSopenharmony_ci    -------------------------------         -------------------------
1585bd8deadSopenharmony_ci    COMPRESSED_RGBA_BPTC_UNORM_EXT          BC7
1595bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT    BC7 sRGB
1605bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT    BC6H signed
1615bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT  BC6H unsigned
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL/EGL Specifications
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci    None.
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ciErrors
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci    INVALID_OPERATION is generated by CompressedTexImage2D if
1705bd8deadSopenharmony_ci    <internalformat> is COMPRESSED_RGBA_BPTC_UNORM_EXT,
1715bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
1725bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
1735bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT and <border> is not equal to zero.
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci    INVALID_OPERATION is generated by TexSubImage2D if
1765bd8deadSopenharmony_ci    TEXTURE_INTERNAL_FORMAT is COMPRESSED_RGBA_BPTC_UNORM_EXT,
1775bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
1785bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
1795bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT and any of the following apply:
1805bd8deadSopenharmony_ci
1815bd8deadSopenharmony_ci        * <width> is not a multiple of four, <width> plus <xoffset> is not
1825bd8deadSopenharmony_ci           equal to TEXTURE_WIDTH, and either <xoffset> or <yoffset> is
1835bd8deadSopenharmony_ci           non-zero;
1845bd8deadSopenharmony_ci
1855bd8deadSopenharmony_ci        * <height> is not a multiple of four, <height> plus <yoffset> is not
1865bd8deadSopenharmony_ci          equal to TEXTURE_HEIGHT, and either <xoffset> or <yoffset> is
1875bd8deadSopenharmony_ci          non-zero; or
1885bd8deadSopenharmony_ci
1895bd8deadSopenharmony_ci        * <xoffset> or <yoffset> is not a multiple of four.
1905bd8deadSopenharmony_ci
1915bd8deadSopenharmony_ci    INVALID_OPERATION is generated by CompressedTexSubImage2D if
1925bd8deadSopenharmony_ci    TEXTURE_INTERNAL_FORMAT is COMPRESSED_RGBA_BPTC_UNORM_EXT,
1935bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
1945bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, or
1955bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT and any of the following apply:
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci        * <width> is not a multiple of four, and <width> plus <xoffset> is not
1985bd8deadSopenharmony_ci          equal to TEXTURE_WIDTH;
1995bd8deadSopenharmony_ci
2005bd8deadSopenharmony_ci        * <height> is not a multiple of four, and <height> plus <yoffset> is
2015bd8deadSopenharmony_ci          not equal to TEXTURE_HEIGHT; or
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ci        * <xoffset> or <yoffset> is not a multiple of four.
2045bd8deadSopenharmony_ci
2055bd8deadSopenharmony_ci    INVALID_OPERATION is generated by TexImage2D, TexImage3D, TexStorage2D, and
2065bd8deadSopenharmony_ci    TexStorage3D if a BPTC format is used as the <internalFormat> parameter
2075bd8deadSopenharmony_ci    with a <type> and <format> combination NOT listed:
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci    InternalFormat                          Format      Type
2105bd8deadSopenharmony_ci    ----------------------                  ----------  --------------
2115bd8deadSopenharmony_ci    COMPRESSED_RGBA_BPTC_UNORM_EXT          RGBA        UNSIGNED_BYTE
2125bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT    RGBA        UNSIGNED_BYTE
2135bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT    RGB         FLOAT
2145bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT  RGB         FLOAT
2155bd8deadSopenharmony_ci
2165bd8deadSopenharmony_ciNew Implementation Dependent State
2175bd8deadSopenharmony_ci
2185bd8deadSopenharmony_ci    None
2195bd8deadSopenharmony_ci
2205bd8deadSopenharmony_ciAppendix
2215bd8deadSopenharmony_ci
2225bd8deadSopenharmony_ci    BPTC Compressed Texture Image Format
2235bd8deadSopenharmony_ci
2245bd8deadSopenharmony_ci    Compressed texture images stored using the BPTC compressed image formats
2255bd8deadSopenharmony_ci    are represented as a collection of 4x4 texel blocks, where each block
2265bd8deadSopenharmony_ci    contains 128 bits of texel data.  The image is encoded as a normal 2D
2275bd8deadSopenharmony_ci    raster image in which each 4x4 block is treated as a single pixel.  If a
2285bd8deadSopenharmony_ci    BPTC image has a width or height that is not a multiple of four, the data
2295bd8deadSopenharmony_ci    corresponding to texels outside the image are irrelevant and undefined.
2305bd8deadSopenharmony_ci
2315bd8deadSopenharmony_ci    When a BPTC image with a width of <w>, height of <h>, and block size of
2325bd8deadSopenharmony_ci    <blocksize> (16 bytes) is decoded, the corresponding image size (in bytes)
2335bd8deadSopenharmony_ci    is:
2345bd8deadSopenharmony_ci
2355bd8deadSopenharmony_ci        ceil(<w>/4) * ceil(<h>/4) * blocksize.
2365bd8deadSopenharmony_ci
2375bd8deadSopenharmony_ci    When decoding a BPTC image, the block containing the texel at offset
2385bd8deadSopenharmony_ci    (<x>, <y>) begins at an offset (in bytes) relative to the base of the
2395bd8deadSopenharmony_ci    image of:
2405bd8deadSopenharmony_ci
2415bd8deadSopenharmony_ci        blocksize * (ceil(<w>/4) * floor(<y>/4) + floor(<x>/4)).
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ci    The data corresponding to a specific texel (<x>, <y>) are extracted from a
2445bd8deadSopenharmony_ci    4x4 texel block using a relative (x,y) value of
2455bd8deadSopenharmony_ci
2465bd8deadSopenharmony_ci        (<x> modulo 4, <y> modulo 4).
2475bd8deadSopenharmony_ci
2485bd8deadSopenharmony_ci    There are two distinct BPTC image formats each of which has two
2495bd8deadSopenharmony_ci    variants. COMPRESSED_RGBA_BPTC_UNORM_EXT and
2505bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT compress 8-bit fixed-point
2515bd8deadSopenharmony_ci    data. COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT and
2525bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT compress high dynamic range
2535bd8deadSopenharmony_ci    floating point values. The formats are similar, so the description of the
2545bd8deadSopenharmony_ci    float format will reference significant sections of the UNORM description.
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci    COMPRESSED_RGBA_BPTC_UNORM_EXT (and the SRGB_ALPHA equivalent): Each 4x4
2575bd8deadSopenharmony_ci    block of texels consists of 128 bits of RGBA or SRGB_ALPHA image data.
2585bd8deadSopenharmony_ci
2595bd8deadSopenharmony_ci    Each block contains enough information to select and decode a pair of
2605bd8deadSopenharmony_ci    colors called endpoints, interpolate between those endpoints in a variety
2615bd8deadSopenharmony_ci    of ways, then remap the result into the final output.
2625bd8deadSopenharmony_ci
2635bd8deadSopenharmony_ci    Each block can contain data in one of eight modes. The mode is identified
2645bd8deadSopenharmony_ci    by the lowest bits of the lowest byte. It is encoded as zero or more zeros
2655bd8deadSopenharmony_ci    followed by a one. For example, using x to indicate a bit not included in
2665bd8deadSopenharmony_ci    the mode number, mode 0 is encoded as xxxxxxx1 in the low byte in binary,
2675bd8deadSopenharmony_ci    mode 5 is xx100000, and mode 7 is 10000000. Encoding the low byte as zero
2685bd8deadSopenharmony_ci    is reserved and should not be used when encoding a BPTC texture.
2695bd8deadSopenharmony_ci
2705bd8deadSopenharmony_ci    All further decoding is driven by the values derived from the mode listed
2715bd8deadSopenharmony_ci    in Table.M below. The fields in the block are always in the same order for
2725bd8deadSopenharmony_ci    all modes. Starting at the lowest bit after the mode and going up from LSB
2735bd8deadSopenharmony_ci    to MSB in byte stream order, these fields are: partition number, rotation,
2745bd8deadSopenharmony_ci    index selection, color, alpha, per-endpoint P-bit, shared P-bit, primary
2755bd8deadSopenharmony_ci    indices, and secondary indices. The number of bits to be read in each
2765bd8deadSopenharmony_ci    field is determined directly from the table.
2775bd8deadSopenharmony_ci
2785bd8deadSopenharmony_ci    Each block can be divided into between 1 and 3 groups of pixels with
2795bd8deadSopenharmony_ci    independent compression parameters called subsets. A texel in a block with
2805bd8deadSopenharmony_ci    one subset is always considered to be in subset zero. Otherwise, a number
2815bd8deadSopenharmony_ci    determined by the number of partition bits is used to look up in the
2825bd8deadSopenharmony_ci    partition tables Table.P2 or Table.P3 for 2 and 3 subsets
2835bd8deadSopenharmony_ci    respectively. This partitioning is indexed by the X and Y within the block
2845bd8deadSopenharmony_ci    to generate the subset index.
2855bd8deadSopenharmony_ci
2865bd8deadSopenharmony_ci    Each block has two colors for each subset, stored first by endpoint, then
2875bd8deadSopenharmony_ci    by subset, then by color. For example, a format with two subsets and five
2885bd8deadSopenharmony_ci    color bits would have five bits of red for endpoint 0 of the first subset,
2895bd8deadSopenharmony_ci    then five bits of red for endpoint 1, then the two ends of the second
2905bd8deadSopenharmony_ci    subset, then green and blue stored similarly. If a block has non-zero
2915bd8deadSopenharmony_ci    alpha bits, the alpha data follows the color data with the same
2925bd8deadSopenharmony_ci    organization. If not, alpha is overridden to 1.0. These bits are treated
2935bd8deadSopenharmony_ci    as the high bits of a fixed-point value in a byte. If the format has
2945bd8deadSopenharmony_ci    shared P-bits, there are two endpoint bits, the lower of which applies to
2955bd8deadSopenharmony_ci    both endpoints of subset 0 and the upper of which applies to both
2965bd8deadSopenharmony_ci    endpoints of subset 1. If the format has a per-endpoint P-bits, then there
2975bd8deadSopenharmony_ci    are 2*subsets P-bits stored in the same order as color and alpha. Both
2985bd8deadSopenharmony_ci    kinds of P-bits are added as a bit below the color data stored in the
2995bd8deadSopenharmony_ci    byte. So, for a format with 5 red bits, the P-bit ends up in bit 2. For
3005bd8deadSopenharmony_ci    final scaling, the top bits of the value are replicated into any remaining
3015bd8deadSopenharmony_ci    bits in the byte. For the preceding example, bits 6 and 7 would be written
3025bd8deadSopenharmony_ci    to bits 0 and 1.
3035bd8deadSopenharmony_ci
3045bd8deadSopenharmony_ci    The endpoint colors are interpolated using index values stored in the
3055bd8deadSopenharmony_ci    block. The index bits are stored in x-major order. Each index has the
3065bd8deadSopenharmony_ci    number of bits indicated by the mode except for one special index per
3075bd8deadSopenharmony_ci    subset called the anchor index. Since the ordering of the endpoints is
3085bd8deadSopenharmony_ci    unimportant, we can save one bit on one index per subset by ordering the
3095bd8deadSopenharmony_ci    endpoints such that the highest bit is guaranteed to be zero. In partition
3105bd8deadSopenharmony_ci    zero, the anchor index is always index zero. In other partitions, the
3115bd8deadSopenharmony_ci    anchor index is specified by tables Table.A2 and Table.A3. If secondary
3125bd8deadSopenharmony_ci    index bits are present, they are read in the same manner. The anchor index
3135bd8deadSopenharmony_ci    information is only used to determine the number of bits each index has
3145bd8deadSopenharmony_ci    when it's read from the block data.
3155bd8deadSopenharmony_ci
3165bd8deadSopenharmony_ci    The endpoint color and alpha values used for final interpolation are the
3175bd8deadSopenharmony_ci    decoded values corresponding to the applicable subset as selected
3185bd8deadSopenharmony_ci    above. The index value for interpolating color comes from the secondary
3195bd8deadSopenharmony_ci    index for the texel if the format has an index selection bit and its value
3205bd8deadSopenharmony_ci    is one and from the primary index otherwise. The alpha index comes from
3215bd8deadSopenharmony_ci    the secondary index if the block has a secondary index and the block
3225bd8deadSopenharmony_ci    either doesn't have an index selection bit or that bit is zero and the
3235bd8deadSopenharmony_ci    primary index otherwise.
3245bd8deadSopenharmony_ci
3255bd8deadSopenharmony_ci    Interpolation is always performed using a 6-bit interpolation factor. The
3265bd8deadSopenharmony_ci    effective interpolation factors for 2, 3, and 4 bit indices are given
3275bd8deadSopenharmony_ci    below:
3285bd8deadSopenharmony_ci
3295bd8deadSopenharmony_ci        2: 0, 21, 43, 64
3305bd8deadSopenharmony_ci        3: 0, 9, 18, 27, 37, 46, 55, 64
3315bd8deadSopenharmony_ci        4: 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64
3325bd8deadSopenharmony_ci
3335bd8deadSopenharmony_ci    The interpolation results in an RGBA color. If rotation bits are present,
3345bd8deadSopenharmony_ci    this color is remapped according to:
3355bd8deadSopenharmony_ci
3365bd8deadSopenharmony_ci        0: no change
3375bd8deadSopenharmony_ci        1: swap(a,r)
3385bd8deadSopenharmony_ci        2: swap(a,g)
3395bd8deadSopenharmony_ci        3: swap(a,b)
3405bd8deadSopenharmony_ci
3415bd8deadSopenharmony_ci    These 8-bit values show up in the shader interpreted as either RGBA8 or
3425bd8deadSopenharmony_ci    SRGB8_ALPHA8 for COMPRESSED_RGBA_BPTC_UNORM_EXT and
3435bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT respectively.
3445bd8deadSopenharmony_ci
3455bd8deadSopenharmony_ci
3465bd8deadSopenharmony_ci    Table.M
3475bd8deadSopenharmony_ci
3485bd8deadSopenharmony_ci    Mode NS PB RB ISB CB AB EPB SPB IB IB2
3495bd8deadSopenharmony_ci    ---- -- -- -- --- -- -- --- --- -- ---
3505bd8deadSopenharmony_ci    0    3  4  0  0   4  0  1   0   3  0
3515bd8deadSopenharmony_ci    1    2  6  0  0   6  0  0   1   3  0
3525bd8deadSopenharmony_ci    2    3  6  0  0   5  0  0   0   2  0
3535bd8deadSopenharmony_ci    3    2  6  0  0   7  0  1   0   2  0
3545bd8deadSopenharmony_ci    4    1  0  2  1   5  6  0   0   2  3
3555bd8deadSopenharmony_ci    5    1  0  2  0   7  8  0   0   2  2
3565bd8deadSopenharmony_ci    6    1  0  0  0   7  7  1   0   4  0
3575bd8deadSopenharmony_ci    7    2  6  0  0   5  5  1   0   2  0
3585bd8deadSopenharmony_ci
3595bd8deadSopenharmony_ci    The columns are as as follows:
3605bd8deadSopenharmony_ci
3615bd8deadSopenharmony_ci    Mode: As described above
3625bd8deadSopenharmony_ci
3635bd8deadSopenharmony_ci    NS: Number of subsets in each partition
3645bd8deadSopenharmony_ci
3655bd8deadSopenharmony_ci    PB: Partition bits
3665bd8deadSopenharmony_ci
3675bd8deadSopenharmony_ci    RB: Rotation bits
3685bd8deadSopenharmony_ci
3695bd8deadSopenharmony_ci    ISB: Index selection bits
3705bd8deadSopenharmony_ci
3715bd8deadSopenharmony_ci    CB: Color bits
3725bd8deadSopenharmony_ci
3735bd8deadSopenharmony_ci    AB: Alpha bits
3745bd8deadSopenharmony_ci
3755bd8deadSopenharmony_ci    EPB: Endpoint P-bits
3765bd8deadSopenharmony_ci
3775bd8deadSopenharmony_ci    SPB: Shared P-bits
3785bd8deadSopenharmony_ci
3795bd8deadSopenharmony_ci    IB: Index bits per element
3805bd8deadSopenharmony_ci
3815bd8deadSopenharmony_ci    IB2: Secondary index bits per element
3825bd8deadSopenharmony_ci
3835bd8deadSopenharmony_ci
3845bd8deadSopenharmony_ci    Table.P2
3855bd8deadSopenharmony_ci
3865bd8deadSopenharmony_ci    (each row is one 4x4 block)
3875bd8deadSopenharmony_ci
3885bd8deadSopenharmony_ci
3895bd8deadSopenharmony_ci    0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1
3905bd8deadSopenharmony_ci    0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1
3915bd8deadSopenharmony_ci    0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1
3925bd8deadSopenharmony_ci    0,0,0,1,0,0,1,1,0,0,1,1,0,1,1,1
3935bd8deadSopenharmony_ci    0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,1
3945bd8deadSopenharmony_ci    0,0,1,1,0,1,1,1,0,1,1,1,1,1,1,1
3955bd8deadSopenharmony_ci    0,0,0,1,0,0,1,1,0,1,1,1,1,1,1,1
3965bd8deadSopenharmony_ci    0,0,0,0,0,0,0,1,0,0,1,1,0,1,1,1
3975bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1
3985bd8deadSopenharmony_ci    0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1
3995bd8deadSopenharmony_ci    0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1
4005bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1
4015bd8deadSopenharmony_ci    0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1
4025bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1
4035bd8deadSopenharmony_ci    0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1
4045bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1
4055bd8deadSopenharmony_ci    0,0,0,0,1,0,0,0,1,1,1,0,1,1,1,1
4065bd8deadSopenharmony_ci    0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0
4075bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0
4085bd8deadSopenharmony_ci    0,1,1,1,0,0,1,1,0,0,0,1,0,0,0,0
4095bd8deadSopenharmony_ci    0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0
4105bd8deadSopenharmony_ci    0,0,0,0,1,0,0,0,1,1,0,0,1,1,1,0
4115bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0
4125bd8deadSopenharmony_ci    0,1,1,1,0,0,1,1,0,0,1,1,0,0,0,1
4135bd8deadSopenharmony_ci    0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0
4145bd8deadSopenharmony_ci    0,0,0,0,1,0,0,0,1,0,0,0,1,1,0,0
4155bd8deadSopenharmony_ci    0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0
4165bd8deadSopenharmony_ci    0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0
4175bd8deadSopenharmony_ci    0,0,0,1,0,1,1,1,1,1,1,0,1,0,0,0
4185bd8deadSopenharmony_ci    0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0
4195bd8deadSopenharmony_ci    0,1,1,1,0,0,0,1,1,0,0,0,1,1,1,0
4205bd8deadSopenharmony_ci    0,0,1,1,1,0,0,1,1,0,0,1,1,1,0,0
4215bd8deadSopenharmony_ci    0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
4225bd8deadSopenharmony_ci    0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1
4235bd8deadSopenharmony_ci    0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0
4245bd8deadSopenharmony_ci    0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0
4255bd8deadSopenharmony_ci    0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0
4265bd8deadSopenharmony_ci    0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0
4275bd8deadSopenharmony_ci    0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1
4285bd8deadSopenharmony_ci    0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1
4295bd8deadSopenharmony_ci    0,1,1,1,0,0,1,1,1,1,0,0,1,1,1,0
4305bd8deadSopenharmony_ci    0,0,0,1,0,0,1,1,1,1,0,0,1,0,0,0
4315bd8deadSopenharmony_ci    0,0,1,1,0,0,1,0,0,1,0,0,1,1,0,0
4325bd8deadSopenharmony_ci    0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0
4335bd8deadSopenharmony_ci    0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0
4345bd8deadSopenharmony_ci    0,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1
4355bd8deadSopenharmony_ci    0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1
4365bd8deadSopenharmony_ci    0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0
4375bd8deadSopenharmony_ci    0,1,0,0,1,1,1,0,0,1,0,0,0,0,0,0
4385bd8deadSopenharmony_ci    0,0,1,0,0,1,1,1,0,0,1,0,0,0,0,0
4395bd8deadSopenharmony_ci    0,0,0,0,0,0,1,0,0,1,1,1,0,0,1,0
4405bd8deadSopenharmony_ci    0,0,0,0,0,1,0,0,1,1,1,0,0,1,0,0
4415bd8deadSopenharmony_ci    0,1,1,0,1,1,0,0,1,0,0,1,0,0,1,1
4425bd8deadSopenharmony_ci    0,0,1,1,0,1,1,0,1,1,0,0,1,0,0,1
4435bd8deadSopenharmony_ci    0,1,1,0,0,0,1,1,1,0,0,1,1,1,0,0
4445bd8deadSopenharmony_ci    0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,0
4455bd8deadSopenharmony_ci    0,1,1,0,1,1,0,0,1,1,0,0,1,0,0,1
4465bd8deadSopenharmony_ci    0,1,1,0,0,0,1,1,0,0,1,1,1,0,0,1
4475bd8deadSopenharmony_ci    0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1
4485bd8deadSopenharmony_ci    0,0,0,1,1,0,0,0,1,1,1,0,0,1,1,1
4495bd8deadSopenharmony_ci    0,0,0,0,1,1,1,1,0,0,1,1,0,0,1,1
4505bd8deadSopenharmony_ci    0,0,1,1,0,0,1,1,1,1,1,1,0,0,0,0
4515bd8deadSopenharmony_ci    0,0,1,0,0,0,1,0,1,1,1,0,1,1,1,0
4525bd8deadSopenharmony_ci    0,1,0,0,0,1,0,0,0,1,1,1,0,1,1,1
4535bd8deadSopenharmony_ci
4545bd8deadSopenharmony_ci    Table.P3
4555bd8deadSopenharmony_ci
4565bd8deadSopenharmony_ci    0,0,1,1,0,0,1,1,0,2,2,1,2,2,2,2
4575bd8deadSopenharmony_ci    0,0,0,1,0,0,1,1,2,2,1,1,2,2,2,1
4585bd8deadSopenharmony_ci    0,0,0,0,2,0,0,1,2,2,1,1,2,2,1,1
4595bd8deadSopenharmony_ci    0,2,2,2,0,0,2,2,0,0,1,1,0,1,1,1
4605bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,1,1,2,2,1,1,2,2
4615bd8deadSopenharmony_ci    0,0,1,1,0,0,1,1,0,0,2,2,0,0,2,2
4625bd8deadSopenharmony_ci    0,0,2,2,0,0,2,2,1,1,1,1,1,1,1,1
4635bd8deadSopenharmony_ci    0,0,1,1,0,0,1,1,2,2,1,1,2,2,1,1
4645bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2
4655bd8deadSopenharmony_ci    0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2
4665bd8deadSopenharmony_ci    0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2
4675bd8deadSopenharmony_ci    0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2
4685bd8deadSopenharmony_ci    0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2
4695bd8deadSopenharmony_ci    0,1,2,2,0,1,2,2,0,1,2,2,0,1,2,2
4705bd8deadSopenharmony_ci    0,0,1,1,0,1,1,2,1,1,2,2,1,2,2,2
4715bd8deadSopenharmony_ci    0,0,1,1,2,0,0,1,2,2,0,0,2,2,2,0
4725bd8deadSopenharmony_ci    0,0,0,1,0,0,1,1,0,1,1,2,1,1,2,2
4735bd8deadSopenharmony_ci    0,1,1,1,0,0,1,1,2,0,0,1,2,2,0,0
4745bd8deadSopenharmony_ci    0,0,0,0,1,1,2,2,1,1,2,2,1,1,2,2
4755bd8deadSopenharmony_ci    0,0,2,2,0,0,2,2,0,0,2,2,1,1,1,1
4765bd8deadSopenharmony_ci    0,1,1,1,0,1,1,1,0,2,2,2,0,2,2,2
4775bd8deadSopenharmony_ci    0,0,0,1,0,0,0,1,2,2,2,1,2,2,2,1
4785bd8deadSopenharmony_ci    0,0,0,0,0,0,1,1,0,1,2,2,0,1,2,2
4795bd8deadSopenharmony_ci    0,0,0,0,1,1,0,0,2,2,1,0,2,2,1,0
4805bd8deadSopenharmony_ci    0,1,2,2,0,1,2,2,0,0,1,1,0,0,0,0
4815bd8deadSopenharmony_ci    0,0,1,2,0,0,1,2,1,1,2,2,2,2,2,2
4825bd8deadSopenharmony_ci    0,1,1,0,1,2,2,1,1,2,2,1,0,1,1,0
4835bd8deadSopenharmony_ci    0,0,0,0,0,1,1,0,1,2,2,1,1,2,2,1
4845bd8deadSopenharmony_ci    0,0,2,2,1,1,0,2,1,1,0,2,0,0,2,2
4855bd8deadSopenharmony_ci    0,1,1,0,0,1,1,0,2,0,0,2,2,2,2,2
4865bd8deadSopenharmony_ci    0,0,1,1,0,1,2,2,0,1,2,2,0,0,1,1
4875bd8deadSopenharmony_ci    0,0,0,0,2,0,0,0,2,2,1,1,2,2,2,1
4885bd8deadSopenharmony_ci    0,0,0,0,0,0,0,2,1,1,2,2,1,2,2,2
4895bd8deadSopenharmony_ci    0,2,2,2,0,0,2,2,0,0,1,2,0,0,1,1
4905bd8deadSopenharmony_ci    0,0,1,1,0,0,1,2,0,0,2,2,0,2,2,2
4915bd8deadSopenharmony_ci    0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0
4925bd8deadSopenharmony_ci    0,0,0,0,1,1,1,1,2,2,2,2,0,0,0,0
4935bd8deadSopenharmony_ci    0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0
4945bd8deadSopenharmony_ci    0,1,2,0,2,0,1,2,1,2,0,1,0,1,2,0
4955bd8deadSopenharmony_ci    0,0,1,1,2,2,0,0,1,1,2,2,0,0,1,1
4965bd8deadSopenharmony_ci    0,0,1,1,1,1,2,2,2,2,0,0,0,0,1,1
4975bd8deadSopenharmony_ci    0,1,0,1,0,1,0,1,2,2,2,2,2,2,2,2
4985bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,2,1,2,1,2,1,2,1
4995bd8deadSopenharmony_ci    0,0,2,2,1,1,2,2,0,0,2,2,1,1,2,2
5005bd8deadSopenharmony_ci    0,0,2,2,0,0,1,1,0,0,2,2,0,0,1,1
5015bd8deadSopenharmony_ci    0,2,2,0,1,2,2,1,0,2,2,0,1,2,2,1
5025bd8deadSopenharmony_ci    0,1,0,1,2,2,2,2,2,2,2,2,0,1,0,1
5035bd8deadSopenharmony_ci    0,0,0,0,2,1,2,1,2,1,2,1,2,1,2,1
5045bd8deadSopenharmony_ci    0,1,0,1,0,1,0,1,0,1,0,1,2,2,2,2
5055bd8deadSopenharmony_ci    0,2,2,2,0,1,1,1,0,2,2,2,0,1,1,1
5065bd8deadSopenharmony_ci    0,0,0,2,1,1,1,2,0,0,0,2,1,1,1,2
5075bd8deadSopenharmony_ci    0,0,0,0,2,1,1,2,2,1,1,2,2,1,1,2
5085bd8deadSopenharmony_ci    0,2,2,2,0,1,1,1,0,1,1,1,0,2,2,2
5095bd8deadSopenharmony_ci    0,0,0,2,1,1,1,2,1,1,1,2,0,0,0,2
5105bd8deadSopenharmony_ci    0,1,1,0,0,1,1,0,0,1,1,0,2,2,2,2
5115bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,2,1,1,2,2,1,1,2
5125bd8deadSopenharmony_ci    0,1,1,0,0,1,1,0,2,2,2,2,2,2,2,2
5135bd8deadSopenharmony_ci    0,0,2,2,0,0,1,1,0,0,1,1,0,0,2,2
5145bd8deadSopenharmony_ci    0,0,2,2,1,1,2,2,1,1,2,2,0,0,2,2
5155bd8deadSopenharmony_ci    0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,2
5165bd8deadSopenharmony_ci    0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1
5175bd8deadSopenharmony_ci    0,2,2,2,1,2,2,2,0,2,2,2,1,2,2,2
5185bd8deadSopenharmony_ci    0,1,0,1,2,2,2,2,2,2,2,2,2,2,2,2
5195bd8deadSopenharmony_ci    0,1,1,1,2,0,1,1,2,2,0,1,2,2,2,0
5205bd8deadSopenharmony_ci
5215bd8deadSopenharmony_ci    Table.A2 (Anchor index values for the second subset of two-subset
5225bd8deadSopenharmony_ci    partitioning)
5235bd8deadSopenharmony_ci
5245bd8deadSopenharmony_ci    (wrapped for readability - values run right then down)
5255bd8deadSopenharmony_ci
5265bd8deadSopenharmony_ci    15,15,15,15,15,15,15,15,
5275bd8deadSopenharmony_ci    15,15,15,15,15,15,15,15,
5285bd8deadSopenharmony_ci    15, 2, 8, 2, 2, 8, 8,15,
5295bd8deadSopenharmony_ci     2, 8, 2, 2, 8, 8, 2, 2,
5305bd8deadSopenharmony_ci    15,15, 6, 8, 2, 8,15,15,
5315bd8deadSopenharmony_ci     2, 8, 2, 2, 2,15,15, 6,
5325bd8deadSopenharmony_ci     6, 2, 6, 8,15,15, 2, 2,
5335bd8deadSopenharmony_ci    15,15,15,15,15, 2, 2,15,
5345bd8deadSopenharmony_ci
5355bd8deadSopenharmony_ci    Table.A3a (Anchor index values for the second subset of three-subset
5365bd8deadSopenharmony_ci    partitioning)
5375bd8deadSopenharmony_ci
5385bd8deadSopenharmony_ci    (wrapped for readability - values run right then down)
5395bd8deadSopenharmony_ci
5405bd8deadSopenharmony_ci     3, 3,15,15, 8, 3,15,15,
5415bd8deadSopenharmony_ci     8, 8, 6, 6, 6, 5, 3, 3,
5425bd8deadSopenharmony_ci     3, 3, 8,15, 3, 3, 6,10,
5435bd8deadSopenharmony_ci     5, 8, 8, 6, 8, 5,15,15,
5445bd8deadSopenharmony_ci     8,15, 3, 5, 6,10, 8,15,
5455bd8deadSopenharmony_ci    15, 3,15, 5,15,15,15,15,
5465bd8deadSopenharmony_ci     3,15, 5, 5, 5, 8, 5,10,
5475bd8deadSopenharmony_ci     5,10, 8,13,15,12, 3, 3,
5485bd8deadSopenharmony_ci
5495bd8deadSopenharmony_ci    Table.A3b (Anchor index values for the third subset of three-subset
5505bd8deadSopenharmony_ci    partitioning)
5515bd8deadSopenharmony_ci
5525bd8deadSopenharmony_ci    (wrapped for readability - values run right then down)
5535bd8deadSopenharmony_ci
5545bd8deadSopenharmony_ci    15, 8, 8, 3,15,15, 3, 8,
5555bd8deadSopenharmony_ci    15,15,15,15,15,15,15, 8,
5565bd8deadSopenharmony_ci    15, 8,15, 3,15, 8,15, 8,
5575bd8deadSopenharmony_ci     3,15, 6,10,15,15,10, 8,
5585bd8deadSopenharmony_ci    15, 3,15,10,10, 8, 9,10,
5595bd8deadSopenharmony_ci     6,15, 8,15, 3, 6, 6, 8,
5605bd8deadSopenharmony_ci    15, 3,15,15,15,15,15,15,
5615bd8deadSopenharmony_ci    15,15,15,15, 3,15,15, 8,
5625bd8deadSopenharmony_ci
5635bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT and
5645bd8deadSopenharmony_ci    COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: Each 4x4 block of texels consists
5655bd8deadSopenharmony_ci    of 128 bits of RGB data. These formats are very similar and will be
5665bd8deadSopenharmony_ci    described together. In the description and pseudocode below, <signed> will
5675bd8deadSopenharmony_ci    be used as a condition which is true for the SIGNED format and false for
5685bd8deadSopenharmony_ci    the UNSIGNED format. Both formats only contain RGB data, so the returned
5695bd8deadSopenharmony_ci    alpha value is 1.0. If a block uses a reserved or invalid encoding, the
5705bd8deadSopenharmony_ci    return value is (0,0,0,1).
5715bd8deadSopenharmony_ci
5725bd8deadSopenharmony_ci    Each block can contain data in one of 14 modes. The mode number is encoded
5735bd8deadSopenharmony_ci    in either the low two bits or the low five bits. If the low two bits are
5745bd8deadSopenharmony_ci    less than two, that is the mode number, otherwise the low five bits the
5755bd8deadSopenharmony_ci    mode number. Mode numbers not listed in Table.MF are reserved (19, 23, 27,
5765bd8deadSopenharmony_ci    and 31).
5775bd8deadSopenharmony_ci
5785bd8deadSopenharmony_ci    The data for the compressed blocks is stored in a different format for
5795bd8deadSopenharmony_ci    each mode. The formats are specified in Table.F. The format strings are
5805bd8deadSopenharmony_ci    intended to be read from left to right with the LSB on the left. Each
5815bd8deadSopenharmony_ci    element is of the form v[a:b]. If a>=b, this indicates to extract b-a+1
5825bd8deadSopenharmony_ci    bits from the block at that location and put it in the corresponding bits
5835bd8deadSopenharmony_ci    of the variable v. If a<b, then the bits are reversed. v[a] is used as a
5845bd8deadSopenharmony_ci    shorthand for the one bit v[a:a]. As an example, m[1:0],g2[4] would move
5855bd8deadSopenharmony_ci    the low two bits from the block into the low two bits of m then the next
5865bd8deadSopenharmony_ci    bit of the block into bit 4 of g2. The variable names given in the table
5875bd8deadSopenharmony_ci    will be referred to in the language below.
5885bd8deadSopenharmony_ci
5895bd8deadSopenharmony_ci    Subsets and indices work in much the same way as described for the
5905bd8deadSopenharmony_ci    fixed-point formats above. If a float block has no partition bits, then it
5915bd8deadSopenharmony_ci    is a single-subset block. If it has partition bits, then it is a 2 subset
5925bd8deadSopenharmony_ci    block. The partition index references the first half of Table.P2. Indices
5935bd8deadSopenharmony_ci    are read in the same way as the fixed-point formats including obeying the
5945bd8deadSopenharmony_ci    anchor values for index 0 and as needed by Table.A2.
5955bd8deadSopenharmony_ci
5965bd8deadSopenharmony_ci    In a single-subset blocks, the two endpoints are contained in r0,g0,b0
5975bd8deadSopenharmony_ci    (hence e0) and r1,g1,b1 (hence e1). In a two-subset block, the endpoints
5985bd8deadSopenharmony_ci    for the second subset are in r2,g2,b2 and r3,g3,b3. The value in e0 is
5995bd8deadSopenharmony_ci    sign-extended if the format of the texture is signed. The values in e1 and
6005bd8deadSopenharmony_ci    e2 and e3 if the block is two-subset are sign-extended if the format of
6015bd8deadSopenharmony_ci    the texture is signed or if the block mode has transformed endpoints. If
6025bd8deadSopenharmony_ci    the mode has transformed endpoints, the values from e0 are used as a base
6035bd8deadSopenharmony_ci    to offset all other endpoints, wrapped at the number of endpoint bits. For
6045bd8deadSopenharmony_ci    example, r1 = (r0+r1) & ((1<<EPB)-1).
6055bd8deadSopenharmony_ci
6065bd8deadSopenharmony_ci    Next, the endpoints are unquantized to maximize the usage of the bits and
6075bd8deadSopenharmony_ci    to ensure that the negative ranges are oriented properly to interpolate as
6085bd8deadSopenharmony_ci    a two's complement value. The following pseudocode assumes the computation
6095bd8deadSopenharmony_ci    is being done using sufficiently large intermediate values to avoid
6105bd8deadSopenharmony_ci    overflow. For the unsigned float format, we unquantize a value x to unq
6115bd8deadSopenharmony_ci    by:
6125bd8deadSopenharmony_ci
6135bd8deadSopenharmony_ci     if (EPB >= 15)
6145bd8deadSopenharmony_ci        unq = x;
6155bd8deadSopenharmony_ci     else if (x == 0)
6165bd8deadSopenharmony_ci        unq = 0;
6175bd8deadSopenharmony_ci     else if (x == ((1<<EPB)-1))
6185bd8deadSopenharmony_ci        unq = 0xFFFF;
6195bd8deadSopenharmony_ci     else
6205bd8deadSopenharmony_ci        unq = ((x << 15) + 0x4000) >> (EPB-1);
6215bd8deadSopenharmony_ci
6225bd8deadSopenharmony_ci    The signed float unquantization is similar, but needs to worry about
6235bd8deadSopenharmony_ci    orienting the negative range:
6245bd8deadSopenharmony_ci
6255bd8deadSopenharmony_ci     s = 0;
6265bd8deadSopenharmony_ci     if (EPB >= 16)
6275bd8deadSopenharmony_ci        unq = x;
6285bd8deadSopenharmony_ci     else {
6295bd8deadSopenharmony_ci       if (x < 0) {
6305bd8deadSopenharmony_ci         s = 1;
6315bd8deadSopenharmony_ci         x = -x;
6325bd8deadSopenharmony_ci       }
6335bd8deadSopenharmony_ci
6345bd8deadSopenharmony_ci       if (x == 0)
6355bd8deadSopenharmony_ci         unq = 0;
6365bd8deadSopenharmony_ci       else if (x >= ((1<<(EPB-1))-1))
6375bd8deadSopenharmony_ci         unq = 0x7FFF;
6385bd8deadSopenharmony_ci       else
6395bd8deadSopenharmony_ci         unq = ((x << 15) + 0x4000) >> (EPB-1);
6405bd8deadSopenharmony_ci
6415bd8deadSopenharmony_ci       if (s)
6425bd8deadSopenharmony_ci         unq = -unq;
6435bd8deadSopenharmony_ci     }
6445bd8deadSopenharmony_ci
6455bd8deadSopenharmony_ci    After the endpoints are unquantized, interpolation proceeds as in the
6465bd8deadSopenharmony_ci    fixed-point formats above including the interpolation weight table.
6475bd8deadSopenharmony_ci
6485bd8deadSopenharmony_ci    The interpolated values are passed through a final unquantization
6495bd8deadSopenharmony_ci    step. For the unsigned format, this step simply multiplies by 31/64. The
6505bd8deadSopenharmony_ci    signed format negates negative components, multiplies by 31/32, then or's
6515bd8deadSopenharmony_ci    in the sign bit if the original value was negative.
6525bd8deadSopenharmony_ci
6535bd8deadSopenharmony_ci    The resultant value should be a legal 16-bit half float which is then
6545bd8deadSopenharmony_ci    returned as a float to the shader.
6555bd8deadSopenharmony_ci
6565bd8deadSopenharmony_ci    Table.MF
6575bd8deadSopenharmony_ci
6585bd8deadSopenharmony_ci    MN Tr PB EPB Delta Bits
6595bd8deadSopenharmony_ci    -- -- -- --- ----------
6605bd8deadSopenharmony_ci    0  1  5  10  {5, 5, 5}
6615bd8deadSopenharmony_ci    1  1  5  7   {6, 6, 6}
6625bd8deadSopenharmony_ci    2  1  5  11  {5, 4, 4}
6635bd8deadSopenharmony_ci    6  1  5  11  {4, 5, 4}
6645bd8deadSopenharmony_ci    10 1  5  11  {4, 4, 5}
6655bd8deadSopenharmony_ci    14 1  5  9   {5, 5, 5}
6665bd8deadSopenharmony_ci    18 1  5  8   {6, 5, 5}
6675bd8deadSopenharmony_ci    22 1  5  8   {5, 6, 5}
6685bd8deadSopenharmony_ci    26 1  5  8   {5, 5, 6}
6695bd8deadSopenharmony_ci    30 0  5  6   {6, 6, 6}
6705bd8deadSopenharmony_ci    3  0  0  10  {10, 10, 10}
6715bd8deadSopenharmony_ci    7  1  0  11  {9, 9, 9}
6725bd8deadSopenharmony_ci    11 1  0  12  {8, 8, 8}
6735bd8deadSopenharmony_ci    15 1  0  16  {4, 4, 4}
6745bd8deadSopenharmony_ci
6755bd8deadSopenharmony_ci    MN: Mode number
6765bd8deadSopenharmony_ci    Tr: Transformed endpoints
6775bd8deadSopenharmony_ci    PB: Partition bits
6785bd8deadSopenharmony_ci    EPB: Endpoint bits
6795bd8deadSopenharmony_ci
6805bd8deadSopenharmony_ci
6815bd8deadSopenharmony_ci    Table.F
6825bd8deadSopenharmony_ci
6835bd8deadSopenharmony_ci    MN Format
6845bd8deadSopenharmony_ci    -- ------------------------------------------------------------------------
6855bd8deadSopenharmony_ci    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],
6865bd8deadSopenharmony_ci       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]
6875bd8deadSopenharmony_ci
6885bd8deadSopenharmony_ci    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],
6895bd8deadSopenharmony_ci       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],
6905bd8deadSopenharmony_ci       b2[3:0],r2[5:0],r3[5:0]
6915bd8deadSopenharmony_ci
6925bd8deadSopenharmony_ci    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],
6935bd8deadSopenharmony_ci       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]
6945bd8deadSopenharmony_ci
6955bd8deadSopenharmony_ci    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],
6965bd8deadSopenharmony_ci       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],
6975bd8deadSopenharmony_ci       g2[4],b3[3]
6985bd8deadSopenharmony_ci
6995bd8deadSopenharmony_ci    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],
7005bd8deadSopenharmony_ci       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],
7015bd8deadSopenharmony_ci       b3[4],b3[3]
7025bd8deadSopenharmony_ci
7035bd8deadSopenharmony_ci    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],
7045bd8deadSopenharmony_ci       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]
7055bd8deadSopenharmony_ci
7065bd8deadSopenharmony_ci    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],
7075bd8deadSopenharmony_ci       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],
7085bd8deadSopenharmony_ci       r3[5:0]
7095bd8deadSopenharmony_ci
7105bd8deadSopenharmony_ci    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],
7115bd8deadSopenharmony_ci       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],
7125bd8deadSopenharmony_ci       b3[2],r3[4:0],b3[3]
7135bd8deadSopenharmony_ci
7145bd8deadSopenharmony_ci    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],
7155bd8deadSopenharmony_ci       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],
7165bd8deadSopenharmony_ci       b3[2],r3[4:0],b3[3]
7175bd8deadSopenharmony_ci
7185bd8deadSopenharmony_ci    30 m[4:0],r0[5:0],g3[4],b3[0],b3[1],b2[4],g0[5:0],g2[5],b2[5],b3[2],
7195bd8deadSopenharmony_ci       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],
7205bd8deadSopenharmony_ci       b1[5:0],b2[3:0],r2[5:0],r3[5:0]
7215bd8deadSopenharmony_ci
7225bd8deadSopenharmony_ci    3  m[4:0],r0[9:0],g0[9:0],b0[9:0],r1[9:0],g1[9:0],b1[9:0]
7235bd8deadSopenharmony_ci
7245bd8deadSopenharmony_ci    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],
7255bd8deadSopenharmony_ci       b0[10]
7265bd8deadSopenharmony_ci
7275bd8deadSopenharmony_ci    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],
7285bd8deadSopenharmony_ci       b1[7:0],b0[10:11]
7295bd8deadSopenharmony_ci
7305bd8deadSopenharmony_ci    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],
7315bd8deadSopenharmony_ci       b1[3:0],b0[10:15]
7325bd8deadSopenharmony_ci
7335bd8deadSopenharmony_ci
7345bd8deadSopenharmony_ciIssues
7355bd8deadSopenharmony_ci
7365bd8deadSopenharmony_ci    Note: These issues apply specifically to the definition of the
7375bd8deadSopenharmony_ci    EXT_texture_compression_bptc specification, which is based on the OpenGL
7385bd8deadSopenharmony_ci    extension ARB_texture_compression_bptc. For the full set of historical
7395bd8deadSopenharmony_ci    issues, see ARB_texture_compression_bptc which can be found
7405bd8deadSopenharmony_ci    in the OpenGL Registry.
7415bd8deadSopenharmony_ci
7425bd8deadSopenharmony_ci    (1) What functionality was changed relative to ARB_texture_compression_bptc?
7435bd8deadSopenharmony_ci
7445bd8deadSopenharmony_ci       BPTC formats are not accepted as <internalFormat> parameters by
7455bd8deadSopenharmony_ci       CopyTexSubImage2D or CopyTexSubImage3D.
7465bd8deadSopenharmony_ci       Queries to GL_NUM_COMPRESSED_TEXTURE_FORMATS and
7475bd8deadSopenharmony_ci       GL_COMPRESSED_TEXTURE_FORMATS should return the BPTC formats.
7485bd8deadSopenharmony_ci       More restrictions are placed on the use of BPTC formats with TexImage*
7495bd8deadSopenharmony_ci       and TexStorage*.
7505bd8deadSopenharmony_ci
7515bd8deadSopenharmony_ci
7525bd8deadSopenharmony_ciRevision History
7535bd8deadSopenharmony_ci
7545bd8deadSopenharmony_ci    Rev.    Date    Author       Changes
7555bd8deadSopenharmony_ci    ----  --------  -----------  --------------------------------------------
7565bd8deadSopenharmony_ci     2    12/10/19  pdaniell     Fix shared p-bits specification to match
7575bd8deadSopenharmony_ci                                 DX and the Khronos Data Format spec.
7585bd8deadSopenharmony_ci                                 
7595bd8deadSopenharmony_ci     1    04/10/17  jaschmidt    EXT version based on revision 9 of
7605bd8deadSopenharmony_ci                                 ARB_texture_compression_bptc
761