102f4aeb0Sopenharmony_ciName
202f4aeb0Sopenharmony_ci
302f4aeb0Sopenharmony_ci    MESA_drm_image
402f4aeb0Sopenharmony_ci
502f4aeb0Sopenharmony_ciName Strings
602f4aeb0Sopenharmony_ci
702f4aeb0Sopenharmony_ci    EGL_MESA_drm_image
802f4aeb0Sopenharmony_ci
902f4aeb0Sopenharmony_ciContact
1002f4aeb0Sopenharmony_ci
1102f4aeb0Sopenharmony_ci    Kristian Høgsberg <krh@bitplanet.net>
1202f4aeb0Sopenharmony_ci
1302f4aeb0Sopenharmony_ciStatus
1402f4aeb0Sopenharmony_ci
1502f4aeb0Sopenharmony_ci    Proposal
1602f4aeb0Sopenharmony_ci
1702f4aeb0Sopenharmony_ciVersion
1802f4aeb0Sopenharmony_ci
1902f4aeb0Sopenharmony_ci    Version 4, November 23, 2017
2002f4aeb0Sopenharmony_ci
2102f4aeb0Sopenharmony_ciNumber
2202f4aeb0Sopenharmony_ci
2302f4aeb0Sopenharmony_ci    EGL Extension #26
2402f4aeb0Sopenharmony_ci
2502f4aeb0Sopenharmony_ciDependencies
2602f4aeb0Sopenharmony_ci
2702f4aeb0Sopenharmony_ci    Requires EGL 1.4 or later.  This extension is written against the
2802f4aeb0Sopenharmony_ci    wording of the EGL 1.4 specification.
2902f4aeb0Sopenharmony_ci
3002f4aeb0Sopenharmony_ci    EGL_KHR_base_image is required.
3102f4aeb0Sopenharmony_ci
3202f4aeb0Sopenharmony_ciOverview
3302f4aeb0Sopenharmony_ci
3402f4aeb0Sopenharmony_ci    This extension provides entry points for integrating EGLImage with the
3502f4aeb0Sopenharmony_ci    Linux DRM mode setting and memory management drivers.  The extension
3602f4aeb0Sopenharmony_ci    lets applications create EGLImages without a client API resource and
3702f4aeb0Sopenharmony_ci    lets the application get the DRM buffer handles.
3802f4aeb0Sopenharmony_ci
3902f4aeb0Sopenharmony_ciIP Status
4002f4aeb0Sopenharmony_ci
4102f4aeb0Sopenharmony_ci    Open-source; freely implementable.
4202f4aeb0Sopenharmony_ci
4302f4aeb0Sopenharmony_ciNew Procedures and Functions
4402f4aeb0Sopenharmony_ci
4502f4aeb0Sopenharmony_ci    EGLImageKHR eglCreateDRMImageMESA(EGLDisplay dpy,
4602f4aeb0Sopenharmony_ci                                      const EGLint *attrib_list);
4702f4aeb0Sopenharmony_ci
4802f4aeb0Sopenharmony_ci    EGLBoolean eglExportDRMImageMESA(EGLDisplay dpy,
4902f4aeb0Sopenharmony_ci                                     EGLImageKHR image,
5002f4aeb0Sopenharmony_ci                                     EGLint *name,
5102f4aeb0Sopenharmony_ci				     EGLint *handle,
5202f4aeb0Sopenharmony_ci				     EGLint *stride);
5302f4aeb0Sopenharmony_ci
5402f4aeb0Sopenharmony_ciNew Tokens
5502f4aeb0Sopenharmony_ci
5602f4aeb0Sopenharmony_ci    Accepted in the <attrib_list> parameter of eglCreateDRMImageMESA:
5702f4aeb0Sopenharmony_ci
5802f4aeb0Sopenharmony_ci        EGL_DRM_BUFFER_FORMAT_MESA		0x31D0
5902f4aeb0Sopenharmony_ci        EGL_DRM_BUFFER_USE_MESA			0x31D1
6002f4aeb0Sopenharmony_ci
6102f4aeb0Sopenharmony_ci    Accepted as values for the EGL_IMAGE_FORMAT_MESA attribute:
6202f4aeb0Sopenharmony_ci
6302f4aeb0Sopenharmony_ci        EGL_DRM_BUFFER_FORMAT_ARGB32_MESA	0x31D2
6402f4aeb0Sopenharmony_ci
6502f4aeb0Sopenharmony_ci    Bits accepted in EGL_DRM_BUFFER_USE_MESA:
6602f4aeb0Sopenharmony_ci
6702f4aeb0Sopenharmony_ci        EGL_DRM_BUFFER_USE_SCANOUT_MESA		0x0001
6802f4aeb0Sopenharmony_ci        EGL_DRM_BUFFER_USE_SHARE_MESA		0x0002
6902f4aeb0Sopenharmony_ci        EGL_DRM_BUFFER_USE_CURSOR_MESA	0x0004
7002f4aeb0Sopenharmony_ci
7102f4aeb0Sopenharmony_ci    Accepted in the <target> parameter of eglCreateImageKHR:
7202f4aeb0Sopenharmony_ci
7302f4aeb0Sopenharmony_ci        EGL_DRM_BUFFER_MESA			0x31D3
7402f4aeb0Sopenharmony_ci
7502f4aeb0Sopenharmony_ci    Use when importing drm buffer:
7602f4aeb0Sopenharmony_ci
7702f4aeb0Sopenharmony_ci        EGL_DRM_BUFFER_STRIDE_MESA		0x31D4
7802f4aeb0Sopenharmony_ci        EGL_DRM_BUFFER_FORMAT_MESA		0x31D0
7902f4aeb0Sopenharmony_ci
8002f4aeb0Sopenharmony_ciAdditions to the EGL 1.4 Specification:
8102f4aeb0Sopenharmony_ci
8202f4aeb0Sopenharmony_ci    To create a DRM EGLImage, call
8302f4aeb0Sopenharmony_ci
8402f4aeb0Sopenharmony_ci        EGLImageKHR eglCreateDRMImageMESA(EGLDisplay dpy,
8502f4aeb0Sopenharmony_ci                                          const EGLint *attrib_list);
8602f4aeb0Sopenharmony_ci
8702f4aeb0Sopenharmony_ci    In the attribute list, pass EGL_WIDTH, EGL_HEIGHT and format and
8802f4aeb0Sopenharmony_ci    use in the attrib list using EGL_DRM_BUFFER_FORMAT_MESA and
8902f4aeb0Sopenharmony_ci    EGL_DRM_BUFFER_USE_MESA.  The only format specified by this
9002f4aeb0Sopenharmony_ci    extension is EGL_DRM_BUFFER_FORMAT_ARGB32_MESA, where each pixel
9102f4aeb0Sopenharmony_ci    is a CPU-endian, 32-bit quantity, with alpha in the upper 8 bits,
9202f4aeb0Sopenharmony_ci    then red, then green, then blue.  The bit values accepted by
9302f4aeb0Sopenharmony_ci    EGL_DRM_BUFFER_USE_MESA are EGL_DRM_BUFFER_USE_SCANOUT_MESA,
9402f4aeb0Sopenharmony_ci    EGL_DRM_BUFFER_USE_SHARE_MESA and EGL_DRM_BUFFER_USE_CURSOR_MESA.
9502f4aeb0Sopenharmony_ci    EGL_DRM_BUFFER_USE_SCANOUT_MESA requests that the created EGLImage
9602f4aeb0Sopenharmony_ci    should be usable as a scanout buffer with the DRM kernel
9702f4aeb0Sopenharmony_ci    modesetting API.  EGL_DRM_BUFFER_USE_SHARE_MESA requests that the
9802f4aeb0Sopenharmony_ci    EGLImage can be shared with other processes by passing the
9902f4aeb0Sopenharmony_ci    underlying DRM buffer name.  EGL_DRM_BUFFER_USE_CURSOR_MESA
10002f4aeb0Sopenharmony_ci    requests that the image must be usable as a cursor with KMS.  When
10102f4aeb0Sopenharmony_ci    EGL_DRM_BUFFER_USE_CURSOR_MESA is set, width and height must both
10202f4aeb0Sopenharmony_ci    be 64.
10302f4aeb0Sopenharmony_ci
10402f4aeb0Sopenharmony_ci    To create a process local handle or a global DRM name for a
10502f4aeb0Sopenharmony_ci    buffer, call
10602f4aeb0Sopenharmony_ci
10702f4aeb0Sopenharmony_ci        EGLBoolean eglExportDRMImageMESA(EGLDisplay dpy,
10802f4aeb0Sopenharmony_ci                                         EGLImageKHR image,
10902f4aeb0Sopenharmony_ci                                         EGLint *name,
11002f4aeb0Sopenharmony_ci                                         EGLint *handle,
11102f4aeb0Sopenharmony_ci                                         EGLint *stride);
11202f4aeb0Sopenharmony_ci
11302f4aeb0Sopenharmony_ci    If <name> is non-NULL, a global name is assigned to the image and
11402f4aeb0Sopenharmony_ci    written to <name>, the handle (local to the DRM file descriptor,
11502f4aeb0Sopenharmony_ci    for use with DRM kernel modesetting API) is written to <handle> if
11602f4aeb0Sopenharmony_ci    non-NULL and the stride (in bytes) is written to <stride>, if
11702f4aeb0Sopenharmony_ci    non-NULL.
11802f4aeb0Sopenharmony_ci
11902f4aeb0Sopenharmony_ci    Import a shared buffer by calling eglCreateImageKHR with
12002f4aeb0Sopenharmony_ci    EGL_DRM_BUFFER_MESA as the target, using EGL_WIDTH, EGL_HEIGHT,
12102f4aeb0Sopenharmony_ci    EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_STRIDE_MESA
12202f4aeb0Sopenharmony_ci    in the attrib list.
12302f4aeb0Sopenharmony_ci
12402f4aeb0Sopenharmony_ciIssues
12502f4aeb0Sopenharmony_ci
12602f4aeb0Sopenharmony_ci    1.  Why don't we use eglCreateImageKHR with a target that
12702f4aeb0Sopenharmony_ci        indicates that we want to create an EGLImage from scratch?
12802f4aeb0Sopenharmony_ci
12902f4aeb0Sopenharmony_ci        RESOLVED: The eglCreateImageKHR entry point is reserved for
13002f4aeb0Sopenharmony_ci        creating an EGLImage from an already existing client API
13102f4aeb0Sopenharmony_ci        resource.  This is fine when we're creating the EGLImage from
13202f4aeb0Sopenharmony_ci        an existing DRM buffer name, it doesn't seem right to overload
13302f4aeb0Sopenharmony_ci        the function to also allocate the underlying resource.
13402f4aeb0Sopenharmony_ci
13502f4aeb0Sopenharmony_ci    2.  Why don't we use an eglQueryImageMESA type functions for
13602f4aeb0Sopenharmony_ci        querying the DRM EGLImage attributes (name, handle, and stride)?
13702f4aeb0Sopenharmony_ci
13802f4aeb0Sopenharmony_ci        RESOLVED: The eglQueryImage function has been proposed often,
13902f4aeb0Sopenharmony_ci        but it goes against the EGLImage design.  EGLImages are opaque
14002f4aeb0Sopenharmony_ci        handles to a 2D array of pixels, which can be passed between
14102f4aeb0Sopenharmony_ci        client APIs.  By referencing an EGLImage in a client API, the
14202f4aeb0Sopenharmony_ci        EGLImage target (a texture, a renderbuffer or such) can be
14302f4aeb0Sopenharmony_ci        used to query the attributes of the EGLImage.  We don't have a
14402f4aeb0Sopenharmony_ci        full client API for creating and querying DRM buffers, though,
14502f4aeb0Sopenharmony_ci        so we use a new EGL extension entry point instead.
14602f4aeb0Sopenharmony_ci
14702f4aeb0Sopenharmony_ciRevision History
14802f4aeb0Sopenharmony_ci
14902f4aeb0Sopenharmony_ci    Version 1, June 3, 2010
15002f4aeb0Sopenharmony_ci        Initial draft (Kristian Høgsberg)
15102f4aeb0Sopenharmony_ci    Version 2, August 25, 2010
15202f4aeb0Sopenharmony_ci        Flesh out the extension a bit, add final EGL tokens, capture
15302f4aeb0Sopenharmony_ci        some of the original discussion in the issues section.
15402f4aeb0Sopenharmony_ci    Version 3, November 29, 2010 (Jon Leech)
15502f4aeb0Sopenharmony_ci        Fix typo.
15602f4aeb0Sopenharmony_ci    Version 4, November 23, 2017 (Kristian Høgsberg)
15702f4aeb0Sopenharmony_ci        Fix typos, add EGL_DRM_BUFFER_USE_CURSOR_MESA
158