Name

    ANGLE_iosurface_client_buffer

Name Strings

    EGL_ANGLE_iosurface_client_buffer

Contributors

    Corentin Wallez
    Geoff Lang
    James Darpinian
    Le Hoang Quyen

Contacts

    Corentin Wallez, Google Inc. (cwallez 'at' google.com)

Status

    Draft

Version
    Version 8, Sep 30, 2026

Number

    EGL Extension #??

Dependencies

    This extension is written against the wording of the EGL 1.4
    Specification.

    EXT_yuv_surface and ANGLE_yuv_internal_format affect the definition
    of this extension.

Overview

    This extension allows creating EGL surfaces from IOSurface objects.

New Types

    None

New Procedures and Functions

    None

New Tokens

    Accepted in the <buftype> parameter of eglCreatePbufferFromClientBuffer:

        EGL_IOSURFACE_ANGLE            0x3454
        EGL_IOSURFACE_PLANE_ANGLE      0x345A
        EGL_TEXTURE_RECTANGLE_ANGLE    0x345B
        EGL_TEXTURE_TYPE_ANGLE         0x345C
        EGL_TEXTURE_INTERNAL_FORMAT_ANGLE 0x345D
        EGL_IOSURFACE_USAGE_HINT_ANGLE 0x348A
        EGL_IOSURFACE_ORIENTATION_ANGLE 0x34F9

    Accepted as bits in the value of EGL_IOSURFACE_ORIENTATION_ANGLE:

        EGL_IOSURFACE_ORIENTATION_INVERT_X_ANGLE 0x0001
        EGL_IOSURFACE_ORIENTATION_INVERT_Y_ANGLE 0x0002
        EGL_IOSURFACE_ORIENTATION_SWAP_XY_ANGLE  0x0004

    Accepted as the value of EGL_YUV_COLOR_SPACE_HINT_EXT in the
    <attrib_list> parameter of eglCreatePbufferFromClientBuffer:

        EGL_SMPTE_240M_ANGLE           0x34FA

    Accepted in the <attribute> parameter of
    eglGetConfigAttrib:

        EGL_BIND_TO_TEXTURE_TARGET_ANGLE 0x348D

Additions to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors)

    Replace the last sentence of paragraph 1 of Section 3.5.3 with the
    following text.
    "Currently, the only client API resources which may be bound in this
    fashion are OpenVG VGImage objects and IOSurface objects."

    Replace the third paragraph of Section 3.5.3 with the following text.
    "<buftype> specifies the type of buffer to be bound. The only allowed values
    of <buftype> are EGL_OPENVG_IMAGE and EGL_IOSURFACE_ANGLE".

    Append the following text to the fourth paragraph of Section 3.5.3.
    "When <buftype> is EGL_IOSURFACE_ANGLE, <buffer> must be a valid IOSurface
    object case into the type EGLClientBuffer."

    Append to the end of Section 3.5.3.
    "When <buftype> is EGL_IOSURFACE_ANGLE, <attrib_list> must contain all the
    following attributes otherwise EGL_BAD_PARAMETER is generated. The
    attributes must satisfy the following constraints otherwise
    EGL_BAD_ATTRIBUTE is generated:
      - EGL_TEXTURE_TYPE_ANGLE, and EGL_TEXTURE_INTERNAL_FORMAT_ANGLE followed
    by OpenGL enums for texture types, and texture internal format
    respectively.
      - EGL_TEXTURE_FORMAT with a value of EGL_TEXTURE_RGBA
      - EGL_WIDTH with a value between 1 and the width of <buffer>.
      - EGL_HEIGHT with a value between 1 and the height of <buffer>.
      - EGL_TEXTURE_TARGET with a value that matches the attribute
      EGL_BIND_TO_TEXTURE_TARGET_ANGLE as queried from eglGetConfigAttrib.
      - EGL_IOSURFACE_PLANE_ANGLE with a value between 0 and the number of
    planes of <buffer> (exclusive).

    In addition the EGL_TEXTURE_TYPE_ANGLE and
    EGL_TEXTURE_INTERNAL_FORMAT_ANGLE attributes must be one of the
    combinations listed in table egl.iosurface.formats or an
    EGL_BAD_PARAMETER is generated. The combination must also be a valid
    combinations for glTexImage2D or EGL_BAD_PARAMETER is generated.

    The attribute EGL_IOSURFACE_USAGE_HINT_ANGLE may optionally be specified as
    a combination of the bits EGL_IOSURFACE_READ_HINT_ANGLE and
    EGL_IOSURFACE_WRITE_HINT_ANGLE. On the iOS Simulator platform, where
    IOSurface support is incomplete, these hints indicate whether the intent is
    to read from the IOSurface, write to it, or both. Explicitly passing 0 for
    this attribute is equivalent to setting both the read and write usage
    bits. This attribute is ignored on other platforms."

    ---------------------------------------------------------------------------
    Texture Type               Texture Internal Format
    ---------------------------------------------------------------------------
    GL_UNSIGNED_BYTE               GL_RED
    GL_UNSIGNED_SHORT              GL_RED
    GL_UNSIGNED_SHORT              GL_R16UI
    GL_UNSIGNED_BYTE               GL_RG
    GL_UNSIGNED_SHORT              GL_RG
    GL_UNSIGNED_BYTE               GL_RGB
    GL_UNSIGNED_BYTE               GL_RGBA
    GL_UNSIGNED_BYTE               GL_BGRA_EXT
    GL_UNSIGNED_INT_2_10_10_10_REV GL_RGB10_A2
    GL_HALF_FLOAT                  GL_RGBA
    ---------------------------------------------------------------------------
    Table egl.iosurface.formats - Valid combinations of format, type and
    internal format for IOSurface-backed pbuffers.
    ---------------------------------------------------------------------------

    Append to the end of Section 3.5.3.
    "When <buftype> is EGL_IOSURFACE_ANGLE, EGL_TEXTURE_TYPE_ANGLE is
    GL_UNSIGNED_BYTE and EGL_TEXTURE_INTERNAL_FORMAT_ANGLE is
    GL_G8_B8R8_2PLANE_420_UNORM_ANGLE, <buffer> must have at least two planes,
    the first holding 8-bit Y samples and the second holding 8-bit Cb and Cr
    samples at half the width and height, rounded up, otherwise
    EGL_BAD_ATTRIBUTE is generated. EGL_IOSURFACE_PLANE_ANGLE is ignored. The
    pbuffer covers the whole <buffer>: EGL_WIDTH and EGL_HEIGHT must be equal
    to the width and height of the first plane, swapped if
    EGL_IOSURFACE_ORIENTATION_ANGLE contains
    EGL_IOSURFACE_ORIENTATION_SWAP_XY_ANGLE, otherwise EGL_BAD_ATTRIBUTE is
    generated.

    The attributes EGL_YUV_COLOR_SPACE_HINT_EXT and EGL_SAMPLE_RANGE_HINT_EXT
    may optionally be specified to select the YCbCr to RGB conversion.
    EGL_YUV_COLOR_SPACE_HINT_EXT is one of EGL_ITU_REC601_EXT,
    EGL_ITU_REC709_EXT, EGL_ITU_REC2020_EXT or EGL_SMPTE_240M_ANGLE, and
    defaults to EGL_ITU_REC601_EXT. EGL_SAMPLE_RANGE_HINT_EXT is one of
    EGL_YUV_NARROW_RANGE_EXT or EGL_YUV_FULL_RANGE_EXT, and defaults to
    EGL_YUV_NARROW_RANGE_EXT. Other values generate EGL_BAD_ATTRIBUTE.
    Specifying either attribute for other internal formats generates
    EGL_BAD_ATTRIBUTE, as a non-zero EGL_IOSURFACE_ORIENTATION_ANGLE does.

    The attribute EGL_IOSURFACE_ORIENTATION_ANGLE may optionally be specified
    as a combination of the bits EGL_IOSURFACE_ORIENTATION_INVERT_X_ANGLE,
    EGL_IOSURFACE_ORIENTATION_INVERT_Y_ANGLE and
    EGL_IOSURFACE_ORIENTATION_SWAP_XY_ANGLE, and defaults to 0. Other bits
    generate EGL_BAD_ATTRIBUTE. A non-zero value for other internal formats
    generates EGL_BAD_ATTRIBUTE. The attribute describes how <buffer> maps to
    the texture image of the pbuffer: the texel at normalized coordinates
    (s, t) of the texture image is the RGB conversion of <buffer> sampled at
    normalized coordinates computed by the following steps:
      - If EGL_IOSURFACE_ORIENTATION_INVERT_Y_ANGLE is set, t becomes 1 - t.
      - If EGL_IOSURFACE_ORIENTATION_INVERT_X_ANGLE is set, s becomes 1 - s.
      - If EGL_IOSURFACE_ORIENTATION_SWAP_XY_ANGLE is set, (s, t) becomes
        (t, s).

    A texture bound to such a pbuffer can only be used as the source of
    glCopyTextureCHROMIUM and glCopySubTextureCHROMIUM, which copy the texture
    image defined above. Such a pbuffer cannot be made current: if <draw> or
    <read> of eglMakeCurrent is such a pbuffer, EGL_BAD_MATCH is generated."

    Append to the end of Section 3.5.3.
    "When a pbuffer is created with type EGL_IOSURFACE_ANGLE, the contents
    of the associcated IOSurface object are undefined while the pbuffer is
    bound to a client texture."

    Append to the end of Table 3.1.
    ---------------------------------------------------------------------------
    Attribute                           Type    Notes
    ---------------------------------------------------------------------------
    EGL_BIND_TO_TEXTURE_TARGET_ANGLE    enum    Texture target supported by
    IOSurface-backed pbuffers.
    ---------------------------------------------------------------------------


Issues

    1. Can RGB formats be supported?

    RESOLVED: Support for RGB internal formats is added in version 3. Surfaces
    with an RGB format will ensure that the alpha channel of the IOSurface is
    reset to 1.0 when it is used.

Revision History

    Version 1, 2017/12/06 - first draft.
    Version 2, 2019/04/01 - Allow MakeCurrent.
    Version 3, 2019/08/13 - Allow RGB internal formats
    Version 4, 2019/12/28 - Add usage hint; require TEXTURE_RECTANGLE on macOS
                            and TEXTURE_2D on iOS
    Version 5, 2020/06/30 - Allow RGB10_A2 internal formats
    Version 6, 2020/08/25 - Allow R16 and RG16 formats for P010 surfaces
    Version 7, 2023/09/19 - Allow RGBA/RGBX surfaces
    Version 8, 2026/09/30 - Allow G8_B8R8_2PLANE_420_UNORM_ANGLE surfaces
                            with YUV hints and orientation
