15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_pvrtc_sRGB
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_pvrtc_sRGB
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Gokhan Avkarogullari, Apple
125bd8deadSopenharmony_ci    Ben Bowman, Imagination Technologies
135bd8deadSopenharmony_ci    Benj Lipchak, Apple
145bd8deadSopenharmony_ci    John Rosasco, Apple
155bd8deadSopenharmony_ci    Richard Schreyer, Apple
165bd8deadSopenharmony_ci    Anthony Tai, Apple
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciContact
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    Benj Lipchak, Apple Inc., (lipchak 'at' apple.com)
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ciStatus
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ci    Complete
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ciVersion
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ci    Last Modified Date:     June 26, 2013
295bd8deadSopenharmony_ci    Revision:               3
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ciNumber
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ci    OpenGL ES Extension #155
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ciDependencies
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ci    OpenGL ES 2.0 is required.
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ci    IMG_texture_compression_pvrtc is required.
405bd8deadSopenharmony_ci    
415bd8deadSopenharmony_ci    This extension extends the OpenGL ES 2.0.25 (Full Specification) and
425bd8deadSopenharmony_ci    the OpenGL ES Shading Language Specification v1.00 revision 16.
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ci    This extension follows precedent and issue resolution of the following
455bd8deadSopenharmony_ci    specifications except where otherwise noted:
465bd8deadSopenharmony_ci        http://www.opengl.org/registry/specs/EXT/texture_sRGB.txt
475bd8deadSopenharmony_ci        http://www.khronos.org/registry/gles/extensions/OES/OES_framebuffer_object.txt
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ci    For single-reference completeness, some of the issues from the issues lists 
505bd8deadSopenharmony_ci    of these specifications have been copied into this extension.
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    This extension follows the conventions of and extends the EXT_sRGB
535bd8deadSopenharmony_ci    extension at:
545bd8deadSopenharmony_ci        http://www.khronos.org/registry/gles/extensions/EXT/EXT_sRGB.txt
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    EXT_texture_storage affects the definition of this extension.
575bd8deadSopenharmony_ci
585bd8deadSopenharmony_ci    IMG_texture_compression_pvrtc2 affects the definition of this extension.
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ciOverview
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ci    The response from electronic display systems given RGB tristimulus values 
635bd8deadSopenharmony_ci    for each pixel is non-linear.  Gamma correction is the process of encoding 
645bd8deadSopenharmony_ci    or decoding images in a manner that will correct for non-linear response 
655bd8deadSopenharmony_ci    profiles of output devices.  The displayed results of gamma-corrected pixel 
665bd8deadSopenharmony_ci    data are more consistent and predictable for the author of such pixel data 
675bd8deadSopenharmony_ci    than it would otherwise be with linearly encoded pixel data.
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ci    This EXT_pvrtc_sRGB extension specifies additional tokens for gamma 
705bd8deadSopenharmony_ci    corrected PVRTC compressed sRGB data.  
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci    Texture assets are developed and evaluated for use in OpenGL applications 
735bd8deadSopenharmony_ci    using electronic displays with non-linear responses.  This extension 
745bd8deadSopenharmony_ci    provides a better measure of consistency between textures developed within 
755bd8deadSopenharmony_ci    an asset toolchain and their final rendered result with an OpenGL 
765bd8deadSopenharmony_ci    application that uses those textures.
775bd8deadSopenharmony_ci
785bd8deadSopenharmony_ci    Conventional OpenGL texture tristimulus values as well as their alpha 
795bd8deadSopenharmony_ci    component are encoded linearly.  The textures introduced by this extension 
805bd8deadSopenharmony_ci    are encoded with gamma correction in the tristimulus components but 
815bd8deadSopenharmony_ci    linearly in the alpha component.
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ci    When gamma corrected texture samples are fetched and operated on by ALU 
845bd8deadSopenharmony_ci    operations in an OpenGL shading program those samples will be converted 
855bd8deadSopenharmony_ci    from gamma corrected space to linear space for logical simplicity and 
865bd8deadSopenharmony_ci    performance of the shader.
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci    Texture filtering operations as well as mipmap generation are carried out 
895bd8deadSopenharmony_ci    in linear space.
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ciIP Status
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci    No known IP issues outstanding.
945bd8deadSopenharmony_ci
955bd8deadSopenharmony_ciIssues
965bd8deadSopenharmony_ci
975bd8deadSopenharmony_ci    (1) What must be specified as far as how do you convert to and from
985bd8deadSopenharmony_ci        sRGB and linear RGB color spaces?
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci        RESOLVED:  The specification language needs to only supply the
1015bd8deadSopenharmony_ci        sRGB to linear RGB conversion.
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci        For completeness, the accepted linear RGB to sRGB conversion
1045bd8deadSopenharmony_ci        is as follows:
1055bd8deadSopenharmony_ci
1065bd8deadSopenharmony_ci        Given a linear RGB component, cl, convert it to an sRGB component,
1075bd8deadSopenharmony_ci        cs, in the range [0,1], with this pseudo-code:
1085bd8deadSopenharmony_ci
1095bd8deadSopenharmony_ci            if (isnan(cl)) {
1105bd8deadSopenharmony_ci                /* Map IEEE-754 Not-a-number to zero. */
1115bd8deadSopenharmony_ci                cs = 0.0;
1125bd8deadSopenharmony_ci            } else if (cl > 1.0) {
1135bd8deadSopenharmony_ci                cs = 1.0;
1145bd8deadSopenharmony_ci            } else if (cl < 0.0) {
1155bd8deadSopenharmony_ci                cs = 0.0;
1165bd8deadSopenharmony_ci            } else if (cl < 0.0031308) {
1175bd8deadSopenharmony_ci                cs = 12.92 * cl;
1185bd8deadSopenharmony_ci            } else {
1195bd8deadSopenharmony_ci                cs = 1.055 * pow(cl, 0.41666) - 0.055;
1205bd8deadSopenharmony_ci            }
1215bd8deadSopenharmony_ci    
1225bd8deadSopenharmony_ci         sRGB components are typically stored as unsigned 8-bit
1235bd8deadSopenharmony_ci         fixed-point values.  If cs is computed with the above
1245bd8deadSopenharmony_ci         pseudo-code, cs can be converted to a [0,255] integer with this
1255bd8deadSopenharmony_ci         formula:
1265bd8deadSopenharmony_ci    
1275bd8deadSopenharmony_ci            csi = floor(255.0 * cs + 0.5)
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ci    (2) Does this extension guarantee images rendered with sRGB textures will
1305bd8deadSopenharmony_ci        "look good" when output to a device supporting an sRGB color space?
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci        RESOLVED:  No.
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci        With this extension, artists can author content in an sRGB color
1355bd8deadSopenharmony_ci        space and provide that sRGB content for use as texture imagery
1365bd8deadSopenharmony_ci        that can be properly converted to linear RGB and filtered as part
1375bd8deadSopenharmony_ci        of texturing in a way that preserves the sRGB distribution of
1385bd8deadSopenharmony_ci        precision, but that does NOT mean sRGB pixels are output
1395bd8deadSopenharmony_ci        to the framebuffer.  Indeed, this extension provides texture
1405bd8deadSopenharmony_ci        formats that convert sRGB to linear RGB as part of filtering.
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci        With programmable shading, an application could perform a
1435bd8deadSopenharmony_ci        linear RGB to sRGB conversion just prior to emitting color
1445bd8deadSopenharmony_ci        values from the shader.  Even so, OpenGL blending (other than
1455bd8deadSopenharmony_ci        simple modulation) will perform linear math operations on values
1465bd8deadSopenharmony_ci        stored in a non-linear space which is technically incorrect for
1475bd8deadSopenharmony_ci        sRGB-encoded colors.
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci        One way to think about these sRGB texture formats is that they
1505bd8deadSopenharmony_ci        simply provide color components with a distribution of values
1515bd8deadSopenharmony_ci        distributed to favor precision towards 0 rather than evenly
1525bd8deadSopenharmony_ci        distributing the precision with conventional non-sRGB formats
1535bd8deadSopenharmony_ci        such as GL_RGB8.
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci     (3) Should the square compressed texture restriction be applied to this
1565bd8deadSopenharmony_ci         extension given the current state of hardware on which compressed
1575bd8deadSopenharmony_ci         sRGB textures are expected to be implemented ?
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ci         RESOLVED: Yes
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci         This extension does not relax any constraint established by the
1625bd8deadSopenharmony_ci         IMG_texture_compression_pvrtc specification upon which it is
1635bd8deadSopenharmony_ci         dependent.  The compressed gamma-corrected formats provided in this
1645bd8deadSopenharmony_ci         extension have the same characteristics and constraints as their
1655bd8deadSopenharmony_ci         non-gamma-corrected counterparts in the IMG_texture_compression_pvrtc
1665bd8deadSopenharmony_ci         specification.
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci     (4) If hardware doesn't support rendering to sRGB textures to levels
1695bd8deadSopenharmony_ci         other than the base level 0 how is this expressed through the API?
1705bd8deadSopenharmony_ci        
1715bd8deadSopenharmony_ci          RESOLVED: Yes
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci         N/A.  This specification only includes compressed formats which are
1745bd8deadSopenharmony_ci         not color-renderable per the ES 2.0 specification.
1755bd8deadSopenharmony_ci      
1765bd8deadSopenharmony_ci     (5) Can PVRTC gamma corrected textures, as described in this
1775bd8deadSopenharmony_ci         specification, cannot be used as a framebuffer-attachable image and
1785bd8deadSopenharmony_ci         thus cannot be rendered to:
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ci         RESOLVED: No
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci         Rendering to PVRTC textures is not usually supported by embedded
1835bd8deadSopenharmony_ci         hardware and this specification makes no exceptions to that effect.
1845bd8deadSopenharmony_ci
1855bd8deadSopenharmony_ci     (6) The desktop extension EXT_texture_sRGB_decode to allow toggling
1865bd8deadSopenharmony_ci         texel fetch gamma decoding on and off.  Is this capability 
1875bd8deadSopenharmony_ci         warranted for this OpenGL ES specification ?
1885bd8deadSopenharmony_ci
1895bd8deadSopenharmony_ci         RESOLVED: Yes
1905bd8deadSopenharmony_ci
1915bd8deadSopenharmony_ci         Decode will not be included in this specification.  This feature
1925bd8deadSopenharmony_ci         can be added as an amendment / separate extension if sufficient
1935bd8deadSopenharmony_ci         demand warrants it.
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ci     (7) Generating mipmaps without hardware support for linearizing,
1965bd8deadSopenharmony_ci         processing then re-applying gamma is a costly operation and
1975bd8deadSopenharmony_ci         brings into question having sRGB support for GenerateMipmaps().
1985bd8deadSopenharmony_ci         Evaluate hardware aspects to this issue and update this 
1995bd8deadSopenharmony_ci         specification accordingly.
2005bd8deadSopenharmony_ci
2015bd8deadSopenharmony_ci         RESOLVED: No
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ci     (8) Should there be an interaction with IMG_texture_compression_pvrtc2?
2045bd8deadSopenharmony_ci        
2055bd8deadSopenharmony_ci         RESOLVED: Yes
2065bd8deadSopenharmony_ci
2075bd8deadSopenharmony_ci         If PVRTC2 is supported, then further enums are added to enable 
2085bd8deadSopenharmony_ci         sRGB decode of those formats.  Note that these formats are not
2095bd8deadSopenharmony_ci         available on all implementations (namely iOS), so be sure to 
2105bd8deadSopenharmony_ci         check for the extension string.
2115bd8deadSopenharmony_ci
2125bd8deadSopenharmony_ciNew Procedures and Functions
2135bd8deadSopenharmony_ci    
2145bd8deadSopenharmony_ci    None
2155bd8deadSopenharmony_ci
2165bd8deadSopenharmony_ciNew Tokens
2175bd8deadSopenharmony_ci
2185bd8deadSopenharmony_ci    Accepted by the <internalformat> parameter of CompressedTexImage2D and 
2195bd8deadSopenharmony_ci    TexStorage2DEXT and the <format> parameter of CompressedTexSubImage2D:
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci        COMPRESSED_SRGB_PVRTC_2BPPV1_EXT               0x8A54
2225bd8deadSopenharmony_ci        COMPRESSED_SRGB_PVRTC_4BPPV1_EXT               0x8A55
2235bd8deadSopenharmony_ci        COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT         0x8A56
2245bd8deadSopenharmony_ci        COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT         0x8A57
2255bd8deadSopenharmony_ci
2265bd8deadSopenharmony_ciAdditions to Chapter 3 of the 2.0.25 Specification (Rasterization)
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci    -- Section 3.7.3, Compressed Texture Images
2295bd8deadSopenharmony_ci
2305bd8deadSopenharmony_ci    Add Table 3.9.1 "Gamma Corrected Compressed Texture Formats"
2315bd8deadSopenharmony_ci
2325bd8deadSopenharmony_ci        COMPRESSED_SRGB_PVRTC_2BPPV1_EXT
2335bd8deadSopenharmony_ci        COMPRESSED_SRGB_PVRTC_4BPPV1_EXT
2345bd8deadSopenharmony_ci        COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT
2355bd8deadSopenharmony_ci        COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT
2365bd8deadSopenharmony_ci
2375bd8deadSopenharmony_ci    -- Section 3.8, Texture Access, Add paragraph after first paragraph 
2385bd8deadSopenharmony_ci       (page 85):
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ci    When a texture, of formats included in table 3.9.1, sample is performed
2415bd8deadSopenharmony_ci    from a bound texture that is gamma corrected the sample will be implicitly
2425bd8deadSopenharmony_ci    converted to its corresponding linear value.
2435bd8deadSopenharmony_ci
2445bd8deadSopenharmony_ciAdditions to Chapter 8 "Built-in Functions" of the OpenGL ES Shading Language
2455bd8deadSopenharmony_cidocument version 1.00, document revision 16:
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci    -- Section 8.7 "Texture Lookup Functions", add paragraph after 2nd
2485bd8deadSopenharmony_ci       paragraph (page 71):
2495bd8deadSopenharmony_ci
2505bd8deadSopenharmony_ci    Then the 2D texture currently bound to "sampler" in the texture lookup
2515bd8deadSopenharmony_ci    functions is a gamma corrected 2D texture (as listed in Table 3.9.1
2525bd8deadSopenharmony_ci    of the OpenGL ES 2.0 specification) the vec4 return value of the
2535bd8deadSopenharmony_ci    sampler functions will be converted into its linear space equivalent value
2545bd8deadSopenharmony_ci    in accordance with the parameters established by the EXT_pvrtc_sRGB 
2555bd8deadSopenharmony_ci    extension.
2565bd8deadSopenharmony_ci
2575bd8deadSopenharmony_ciDependencies on IMG_texture_compression_pvrtc2
2585bd8deadSopenharmony_ci
2595bd8deadSopenharmony_ci    If IMG_texture_compression_pvrtc2 is supported, then 
2605bd8deadSopenharmony_ci
2615bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0
2625bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1
2635bd8deadSopenharmony_ci        
2645bd8deadSopenharmony_ci    are accepted by the <internalformat> parameter of CompressedTexImage2D and 
2655bd8deadSopenharmony_ci    TexStorage2DEXT and the <format> parameter of CompressedTexSubImage2D, and 
2665bd8deadSopenharmony_ci    are added to table 3.9.1 "Gamma Corrected Compressed Texture Formats".
2675bd8deadSopenharmony_ci
2685bd8deadSopenharmony_ci    Errors
2695bd8deadSopenharmony_ci
2705bd8deadSopenharmony_ci    Modify the errors introduced by IMG_texture_compression_pvrtc2 as below:
2715bd8deadSopenharmony_ci
2725bd8deadSopenharmony_ci    INVALID_OPERATION is generated by CompressedTexSubImage2D if
2735bd8deadSopenharmony_ci    INTERNAL_FORMAT is COMPRESSED_RGBA_PVRTC_2BPPV2_IMG or 
2745bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG and any of the following apply:
2755bd8deadSopenharmony_ci
2765bd8deadSopenharmony_ci        * <xoffset> is not a multiple of eight.
2775bd8deadSopenharmony_ci        * <yoffset> is not a multiple of four.
2785bd8deadSopenharmony_ci        * <width> is not a multiple of eight, except when the sum of <width>
2795bd8deadSopenharmony_ci          and <xoffset> is equal to TEXTURE_WIDTH.
2805bd8deadSopenharmony_ci        * <height> is not a multiple of four, except when the sum of <height>
2815bd8deadSopenharmony_ci          and <yoffset> is equal to TEXTURE_HEIGHT.
2825bd8deadSopenharmony_ci        * <format> does not match the internal format of the texture image
2835bd8deadSopenharmony_ci          being modified.
2845bd8deadSopenharmony_ci
2855bd8deadSopenharmony_ci    INVALID_OPERATION is generated by CompressedTexSubImage2D if
2865bd8deadSopenharmony_ci    INTERNAL_FORMAT is COMPRESSED_RGBA_PVRTC_4BPPV2_IMG or
2875bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG and any of the following apply:
2885bd8deadSopenharmony_ci
2895bd8deadSopenharmony_ci        * <xoffset> is not a multiple of four.
2905bd8deadSopenharmony_ci        * <yoffset> is not a multiple of four.
2915bd8deadSopenharmony_ci        * <width> is not a multiple of four, except when the sum of <width>
2925bd8deadSopenharmony_ci          and <xoffset> is equal to TEXTURE_WIDTH.
2935bd8deadSopenharmony_ci        * <height> is not a multiple of four, except when the sum of <height>
2945bd8deadSopenharmony_ci          and <yoffset> is equal to TEXTURE_HEIGHT.
2955bd8deadSopenharmony_ci        * <format> does not match the internal format of the texture image
2965bd8deadSopenharmony_ci          being modified.
2975bd8deadSopenharmony_ci
2985bd8deadSopenharmony_ci
2995bd8deadSopenharmony_ciDependencies on EXT_texture_storage
3005bd8deadSopenharmony_ci
3015bd8deadSopenharmony_ci    If EXT_texture_storage is not supported, then all references to
3025bd8deadSopenharmony_ci    TexStorage2DEXT should be ignored.
3035bd8deadSopenharmony_ci
3045bd8deadSopenharmony_ciErrors
3055bd8deadSopenharmony_ci
3065bd8deadSopenharmony_ci    Relax INVALID_ENUM errors for the new <internalformat> and <format>
3075bd8deadSopenharmony_ci    parameters for CompressedTexImage2D and CompressedTexSubImage2D introduced
3085bd8deadSopenharmony_ci    by this specification.
3095bd8deadSopenharmony_ci
3105bd8deadSopenharmony_ci    INVALID_OPERATION is generated by CompressedTexSubImage2D if <format>
3115bd8deadSopenharmony_ci    is COMPRESSED_SRGB_PVRTC_4BPPV1_EXT, COMPRESSED_SRGB_PVRTC_2BPPV1_EXT,
3125bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT, or 
3135bd8deadSopenharmony_ci    COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT and any of the following apply: 
3145bd8deadSopenharmony_ci    <width> is not equal to TEXTURE_WIDTH; <height> is not equal to 
3155bd8deadSopenharmony_ci    TEXTURE_HEIGHT; <xoffset> and <yoffset> are not zero.
3165bd8deadSopenharmony_ci
3175bd8deadSopenharmony_ciRevision History
3185bd8deadSopenharmony_ci
3195bd8deadSopenharmony_ci    #1 February 6 2013, Benj Lipchak
3205bd8deadSopenharmony_ci        - initial version
3215bd8deadSopenharmony_ci    #2 June 26 2013, Benj Lipchak
3225bd8deadSopenharmony_ci        - promotion from APPLE to EXT
3235bd8deadSopenharmony_ci    #3 June 28 2013, Ben Bowman
3245bd8deadSopenharmony_ci        - Added issue 8 and interaction with IMG_texture_compression_pvrtc2
325