15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_sRGB_write_control
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_sRGB_write_control
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Matt Trusten
125bd8deadSopenharmony_ci    Maurice Ribble
135bd8deadSopenharmony_ci
145bd8deadSopenharmony_ci    Parts of this specification were taken from ARB_framebuffer_sRGB
155bd8deadSopenharmony_ci    Parts of this specification were taken from EXT_sRGB
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ciContact
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ci    Maurice Ribble, Qualcomm (mribble 'at' qti.qualcomm.com)
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ciStatus
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    Complete
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ciVersion
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ci    Version #2, August 5, 2013
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ciNumber
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ci    OpenGL ES Extension #153
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ciDependencies
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    This extension requires OpenGL ES 2.0 and EXT_sRGB or OpenGL ES 3.0
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ci    This extension is based on the wording and functionality of the OpenGL ES
385bd8deadSopenharmony_ci    3.0 specification.
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ciOverview
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    This extension's intent is to expose new functionality which allows an
435bd8deadSopenharmony_ci    application the ability to decide if the conversion from linear space to
445bd8deadSopenharmony_ci    sRGB is necessary by enabling or disabling this conversion at framebuffer
455bd8deadSopenharmony_ci    write or blending time. An application which passes non-linear vector data
465bd8deadSopenharmony_ci    to a shader may not want the color conversion occurring, and by disabling
475bd8deadSopenharmony_ci    conversion the application can be simplified, sometimes in very significant
485bd8deadSopenharmony_ci    and more optimal ways.
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ciNew Procedures and Functions
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    None
535bd8deadSopenharmony_ci
545bd8deadSopenharmony_ciNew Tokens
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    Accepted by the <cap> parameter of Enable, Disable, and IsEnabled,
575bd8deadSopenharmony_ci    and by the <pname> parameter of GetBooleanv, GetFloatv, GetIntegerv and
585bd8deadSopenharmony_ci    GetInteger64v:
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ci        FRAMEBUFFER_SRGB_EXT                         0x8DB9
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ciAdditions to Chapter 3 of the 3.0 Specification (Rasterization)
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ci    None
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ciAdditions to Chapter 4 of the 3.0 Specification (Per-Fragment Operations and
675bd8deadSopenharmony_cithe Framebuffer)
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ciModify Section 4.1.7: Blending
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci    If the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer
725bd8deadSopenharmony_ci    attachment corresponding to the destination buffer is SRGB (see section
735bd8deadSopenharmony_ci    6.1.13) and FRAMEBUFFER_SRGB_EXT is enabled, the R, G, and B
745bd8deadSopenharmony_ci    destination color values (after conversion from fixedpoint to
755bd8deadSopenharmony_ci    floating-point) are considered to be encoded for the sRGB color space and
765bd8deadSopenharmony_ci    hence must be linearized prior to their use in blending. Each R, G, and B
775bd8deadSopenharmony_ci    component is converted in the same fashion described for sRGB texture
785bd8deadSopenharmony_ci    components in section 3.8.16.
795bd8deadSopenharmony_ci    If the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING is not SRGB, or
805bd8deadSopenharmony_ci    FRAMEBUFFER_SRGB_EXT is disabled, no linearization is performed.
815bd8deadSopenharmony_ci
825bd8deadSopenharmony_ciModify Section 4.1.8: sRGB Conversion
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ci    If the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer
855bd8deadSopenharmony_ci    attachment corresponding to the destination buffer is SRGB (see section
865bd8deadSopenharmony_ci    6.1.13) and FRAMEBUFFER_SRGB_EXT is enabled, the R, G, and B
875bd8deadSopenharmony_ci    values after blending are converted into the non-linear sRGB color space by
885bd8deadSopenharmony_ci    computing
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci             {  0.0,                          0         <= cl
915bd8deadSopenharmony_ci             {  12.92 * c,                    0         <  cl < 0.0031308
925bd8deadSopenharmony_ci        cs = {  1.055 * cl^0.41666 - 0.055,   0.0031308 <= cl < 1
935bd8deadSopenharmony_ci             {  1.0,                                       cl >= 1
945bd8deadSopenharmony_ci
955bd8deadSopenharmony_ci    where cl is the R, G, or B element and cs is the result (effectively
965bd8deadSopenharmony_ci    converted into an sRGB color space).
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ciModify Section 4.3.2: Copying Pixels
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci    When values are taken from the read buffer, if the value of FRAMEBUFFER_-
1015bd8deadSopenharmony_ci    ATTACHMENT_COLOR_ENCODING for the framebuffer attachment corresponding to
1025bd8deadSopenharmony_ci    the read buffer is SRGB (see section 6.1.13), the red, green, and blue
1035bd8deadSopenharmony_ci    components are converted from the non-linear sRGB color space according to
1045bd8deadSopenharmony_ci    equation 3.24 if FRAMEBUFFER_SRGB_EXT is enabled.
1055bd8deadSopenharmony_ci
1065bd8deadSopenharmony_ciInteractions with OpenGL ES 2.0 and EXT_sRGB:
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci    In the case of not working with OpenGL ES 3.0, sRGB conversion is dictacted
1095bd8deadSopenharmony_ci    by EXT_sRGB. The following changes should be made to EXT_sRGB to support
1105bd8deadSopenharmony_ci    this extension properly in this case:
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci    In "Additions to Chapter 4 of the Specification", the third paragraph after
1135bd8deadSopenharmony_ci    "with the following sentences", the following excerpt should be changed
1145bd8deadSopenharmony_ci    from:
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci        If the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT is not SRGB,
1175bd8deadSopenharmony_ci        no linearization is performed.
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci    to:
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_ci        If the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT is not SRGB,
1225bd8deadSopenharmony_ci        or FRAMEBUFFER_SRGB_EXT is disabled, no linearization is performed.
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ci    In the "ADD new section 4.1.X..." section, change the first paragraph which
1255bd8deadSopenharmony_ci    reads:
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ci        "If the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT for the
1285bd8deadSopenharmony_ci        framebuffer attachment corresponding to the destination buffer is SRGB,
1295bd8deadSopenharmony_ci        the R, G, and B values after blending are converted into the non-linear
1305bd8deadSopenharmony_ci        sRGB color space by computing:
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci             {  0.0,                          cl        <= 0
1335bd8deadSopenharmony_ci             {  12.92 * c,                    0         <  cl < 0.0031308
1345bd8deadSopenharmony_ci        cs = {  1.055 * cl^0.41666 - 0.055,   0.0031308 <= cl < 1
1355bd8deadSopenharmony_ci             {  1.0,                                       cl >= 1
1365bd8deadSopenharmony_ci
1375bd8deadSopenharmony_ci        where cl is the R, G, or B element and cs is the result (effectively
1385bd8deadSopenharmony_ci        converted into an sRGB color space).
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci    to:
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci        "If the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT for the
1435bd8deadSopenharmony_ci        framebuffer attachment corresponding to the destination buffer is SRGB,
1445bd8deadSopenharmony_ci        and FRAMEBUFFER_SRGB_EXT is enabled, the R, G, and B values after
1455bd8deadSopenharmony_ci        blending are converted into the non-linear sRGB color space by
1465bd8deadSopenharmony_ci        computing:
1475bd8deadSopenharmony_ci
1485bd8deadSopenharmony_ci             {  0.0,                          cl        <= 0
1495bd8deadSopenharmony_ci             {  12.92 * c,                    0         <  cl < 0.0031308
1505bd8deadSopenharmony_ci        cs = {  1.055 * cl^0.41666 - 0.055,   0.0031308 <= cl < 1
1515bd8deadSopenharmony_ci             {  1.0,                                       cl >= 1
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ci        where cl is the R, G, or B element and cs is the result (effectively
1545bd8deadSopenharmony_ci        converted into an sRGB color space).
1555bd8deadSopenharmony_ci
1565bd8deadSopenharmony_ci    and after the second paragraph, before the following:
1575bd8deadSopenharmony_ci
1585bd8deadSopenharmony_ci        The following should be added to table 4.5 Renderbuffer Image formats:
1595bd8deadSopenharmony_ci        SRGB8_ALPHA8_EXT     color_renderable 8  8  8  8  -  -
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci    add:
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci        If FRAMEBUFFER_SRGB_EXT is disabled, no conversion into linear space
1645bd8deadSopenharmony_ci        will occur.
1655bd8deadSopenharmony_ci
1665bd8deadSopenharmony_ciErrors
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci    Relaxation of INVALID_ENUM errors
1695bd8deadSopenharmony_ci    ---------------------------------
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ci    Enable, Disable, IsEnabled, GetBooleanv, GetFloatv, GetIntegerv and
1725bd8deadSopenharmony_ci    GetInteger64v now accept the new token as allowed in the "New Tokens"
1735bd8deadSopenharmony_ci    section.
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ciNew State
1765bd8deadSopenharmony_ci
1775bd8deadSopenharmony_ci    Add to table 6.11 (Pixel Operations)
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ci    Get Value             Type  Get Command  Initial Value  Description      Sec.   Attribute
1805bd8deadSopenharmony_ci    --------------------  ----  -----------  -------------  ---------------  -----  -------------------
1815bd8deadSopenharmony_ci    FRAMEBUFFER_SRGB_EXT  B     IsEnabled    True           sRGB update and  4.1.X  color-buffer/enable
1825bd8deadSopenharmony_ci                                                            blending enable
1835bd8deadSopenharmony_ci
1845bd8deadSopenharmony_ciNew Implementation Dependent State
1855bd8deadSopenharmony_ci
1865bd8deadSopenharmony_ci    None
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ciIssues
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci    1)  What should this extension be called?
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci        As a place holder we are using: EXT_sRGB_write_control
1935bd8deadSopenharmony_ci
1945bd8deadSopenharmony_ci        This was chosen because EXT_framebuffer_sRGB does not make it
1955bd8deadSopenharmony_ci        immediately obvious that this extension is only dealing with operations
1965bd8deadSopenharmony_ci        after the pixel path, and EXT_sRGB_write_control seems more clear. The
1975bd8deadSopenharmony_ci        original is named with ARB, ARB_framebuffer_sRGB, so it may also make
1985bd8deadSopenharmony_ci        sense to change the name to EXT_framebuffer_sRGB.
1995bd8deadSopenharmony_ci
2005bd8deadSopenharmony_ci    2)  How is sRGB blending done in the default state (FRAMEBUFFER_SRGB_EXT
2015bd8deadSopenharmony_ci        is enabled)?
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ci        RESOLVED:  Blending is a linear operation so should be performed
2045bd8deadSopenharmony_ci        on values in linear spaces.  sRGB-encoded values are in a
2055bd8deadSopenharmony_ci        non-linear space so sRGB blending should convert sRGB-encoded
2065bd8deadSopenharmony_ci        values from the framebuffer to linear values, blend, and then
2075bd8deadSopenharmony_ci        sRGB-encode the result to store it in the framebuffer.
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci        The destination color RGB components are each converted
2105bd8deadSopenharmony_ci        from sRGB to a linear value.  Blending is then performed.
2115bd8deadSopenharmony_ci        The source color and constant color are simply assumed to be
2125bd8deadSopenharmony_ci        treated as linear color components.  Then the result of blending
2135bd8deadSopenharmony_ci        is converted to an sRGB encoding and stored in the framebuffer.
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ci    3)  How are multiple render targets handled?
2165bd8deadSopenharmony_ci
2175bd8deadSopenharmony_ci        RESOLVED:  Render targets that are not sRGB capable ignore the
2185bd8deadSopenharmony_ci        state of the GL_FRAMEBUFFER_SRGB_EXT enable for sRGB update and
2195bd8deadSopenharmony_ci        blending. So only the render targets that are sRGB-capable perform
2205bd8deadSopenharmony_ci        sRGB blending and update when GL_FRAMEBUFFER_SRGB_EXT is enabled.
2215bd8deadSopenharmony_ci
2225bd8deadSopenharmony_ci    4)  Why is the sRGB framebuffer GL_FRAMEBUFFER_SRGB_EXT enabled by default?
2235bd8deadSopenharmony_ci
2245bd8deadSopenharmony_ci        Based on the the GLES 3.0 spec, if this conversion choice is disabled
2255bd8deadSopenharmony_ci        by default then current apps which expect this conversion to happen
2265bd8deadSopenharmony_ci        will be broken and the output will not look as intended.
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci    5)  FRAMEBUFFER_SRGB seems concerned with writing to sRGB framebuffers and
2295bd8deadSopenharmony_ci        blending operations. How do we want to handle the operations which
2305bd8deadSopenharmony_ci        include reading from a framebuffer, such as glBlitFramebuffer,
2315bd8deadSopenharmony_ci        glReadPixels, or glCopyTexImage?
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ci        This flag will affect glBlitFramebuffer, but will not affect
2345bd8deadSopenharmony_ci        glReadPixels or glCopyTex[Sub]Image.
2355bd8deadSopenharmony_ci
2365bd8deadSopenharmony_ci        If the implementation does not support OpenGL ES 3.0 and instead
2375bd8deadSopenharmony_ci        supports OpenGL 2.0 and EXT_sRGB, references to glBlitFramebuffer can
2385bd8deadSopenharmony_ci        be ignored. However, the above will be true if the implementation
2395bd8deadSopenharmony_ci        supports NV_framebuffer_blit.
2405bd8deadSopenharmony_ci
2415bd8deadSopenharmony_ci    6) How does this extension interact with multisampling?
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ci        RESOLVED:  There are no explicit interactions.  However, arguably
2445bd8deadSopenharmony_ci        if the color samples for multisampling are sRGB encoded, the
2455bd8deadSopenharmony_ci        samples should be linearized before being "resolved" for display
2465bd8deadSopenharmony_ci        and then recoverted to sRGB if the output device expects sRGB
2475bd8deadSopenharmony_ci        encoded color components.
2485bd8deadSopenharmony_ci
2495bd8deadSopenharmony_ci        This is really a video scan-out issue and beyond the scope
2505bd8deadSopenharmony_ci        of this extension which is focused on the rendering issues.
2515bd8deadSopenharmony_ci        However some implementation advice is provided:
2525bd8deadSopenharmony_ci
2535bd8deadSopenharmony_ci        The implementation sufficiently aware of the gamma correction
2545bd8deadSopenharmony_ci        configured for the display device could decide to perform an
2555bd8deadSopenharmony_ci        sRGB-correct multisample resolve.  Whether this occurs or not
2565bd8deadSopenharmony_ci        could be determined by a control panel setting or inferred by
2575bd8deadSopenharmony_ci        the application's use of this extension.
2585bd8deadSopenharmony_ci
2595bd8deadSopenharmony_ciRevision History
2605bd8deadSopenharmony_ci  #02    8/05/2013    Matt Trusten     Minor bug fixes
2615bd8deadSopenharmony_ci                                       Added multisampling issue from
2625bd8deadSopenharmony_ci                                         ARB_framebuffer_sRGB
2635bd8deadSopenharmony_ci
2645bd8deadSopenharmony_ci  #01    6/04/2013    Matt Trusten     First draft.
265