1848b8605SmrgName 2848b8605Smrg 3848b8605Smrg MESA_drm_image 4848b8605Smrg 5848b8605SmrgName Strings 6848b8605Smrg 7848b8605Smrg EGL_MESA_drm_image 8848b8605Smrg 9848b8605SmrgContact 10848b8605Smrg 11848b8605Smrg Kristian Høgsberg <krh@bitplanet.net> 12848b8605Smrg 13848b8605SmrgStatus 14848b8605Smrg 15848b8605Smrg Proposal 16848b8605Smrg 17848b8605SmrgVersion 18848b8605Smrg 19848b8605Smrg Version 2, August 25, 2010 20848b8605Smrg 21848b8605SmrgNumber 22848b8605Smrg 23848b8605Smrg EGL Extension #not assigned 24848b8605Smrg 25848b8605SmrgDependencies 26848b8605Smrg 27848b8605Smrg Requires EGL 1.4 or later. This extension is written against the 28848b8605Smrg wording of the EGL 1.4 specification. 29848b8605Smrg 30848b8605Smrg EGL_KHR_base_image is required. 31848b8605Smrg 32848b8605SmrgOverview 33848b8605Smrg 34848b8605Smrg This extension provides entry points for integrating EGLImage with the 35848b8605Smrg Linux DRM mode setting and memory management drivers. The extension 36848b8605Smrg lets applications create EGLImages without a client API resource and 37848b8605Smrg lets the application get the DRM buffer handles. 38848b8605Smrg 39848b8605SmrgIP Status 40848b8605Smrg 41848b8605Smrg Open-source; freely implementable. 42848b8605Smrg 43848b8605SmrgNew Procedures and Functions 44848b8605Smrg 45848b8605Smrg EGLImageKHR eglCreateDRMImageMESA(EGLDisplay dpy, 46848b8605Smrg const EGLint *attrib_list); 47848b8605Smrg 48848b8605Smrg EGLBoolean eglExportDRMImageMESA(EGLDisplay dpy, 49848b8605Smrg EGLImageKHR image, 50848b8605Smrg EGLint *name, 51848b8605Smrg EGLint *handle, 52848b8605Smrg EGLint *stride); 53848b8605Smrg 54848b8605SmrgNew Tokens 55848b8605Smrg 56848b8605Smrg Accepted in the <attrib_list> parameter of eglCreateDRMImageMESA: 57848b8605Smrg 58848b8605Smrg EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 59848b8605Smrg EGL_DRM_BUFFER_USE_MESA 0x31D1 60848b8605Smrg 61848b8605Smrg Accepted as values for the EGL_IMAGE_FORMAT_MESA attribute: 62848b8605Smrg 63848b8605Smrg EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 64848b8605Smrg 65848b8605Smrg Bits accepted in EGL_DRM_BUFFER_USE_MESA: 66848b8605Smrg 67848b8605Smrg EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x0001 68848b8605Smrg EGL_DRM_BUFFER_USE_SHARE_MESA 0x0002 69848b8605Smrg EGL_DRM_BUFFER_USE_CURSOR_MESA 0x0004 70848b8605Smrg 71848b8605Smrg Accepted in the <target> parameter of eglCreateImageKHR: 72848b8605Smrg 73848b8605Smrg EGL_DRM_BUFFER_MESA 0x31D3 74848b8605Smrg 75848b8605Smrg Use when importing drm buffer: 76848b8605Smrg 77848b8605Smrg EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 78848b8605Smrg EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 79848b8605Smrg 80848b8605SmrgAdditions to the EGL 1.4 Specification: 81848b8605Smrg 82848b8605Smrg To create a DRM EGLImage, call 83848b8605Smrg 84848b8605Smrg EGLImageKHR eglCreateDRMImageMESA(EGLDisplay dpy, 85848b8605Smrg const EGLint *attrib_list); 86848b8605Smrg 87848b8605Smrg In the attribute list, pass EGL_WIDTH, EGL_HEIGHT and format and 88848b8605Smrg use in the attrib list using EGL_DRM_BUFFER_FORMAT_MESA and 89848b8605Smrg EGL_DRM_BUFFER_USE_MESA. The only format specified by this 90848b8605Smrg extension is EGL_DRM_BUFFER_FORMAT_ARGB32_MESA, where each pixel 91848b8605Smrg is a CPU-endian, 32-bit quantity, with alpha in the upper 8 bits, 92848b8605Smrg then red, then green, then blue. The bit values accepted by 93848b8605Smrg EGL_DRM_BUFFER_USE_MESA are EGL_DRM_BUFFER_USE_SCANOUT_MESA, 94848b8605Smrg EGL_DRM_BUFFER_USE_SHARE_MESA and EGL_DRM_BUFFER_USE_CURSOR_MESA. 95848b8605Smrg EGL_DRM_BUFFER_USE_SCANOUT_MESA requests that the created EGLImage 96848b8605Smrg should be usable as a scanout buffer with the DRM kernel 97848b8605Smrg modesetting API. EGL_DRM_BUFFER_USE_SHARE_MESA requests that the 98848b8605Smrg EGLImage can be shared with other processes by passing the 99848b8605Smrg underlying DRM buffer name. EGL_DRM_BUFFER_USE_CURSOR_MESA 100848b8605Smrg requests that the image must be usable as a cursor with KMS. When 101848b8605Smrg EGL_DRM_BUFFER_USE_CURSOR_MESA is set, width and height must both 102848b8605Smrg be 64. 103848b8605Smrg 104848b8605Smrg To create a process local handle or a global DRM name for a 105848b8605Smrg buffer, call 106848b8605Smrg 107848b8605Smrg EGLBoolean eglExportDRMImageMESA(EGLDisplay dpy, 108848b8605Smrg EGLImageKHR image, 109848b8605Smrg EGLint *name, 110848b8605Smrg EGLint *handle, 111848b8605Smrg EGLint *stride); 112848b8605Smrg 113848b8605Smrg If <name> is non-NULL, a global name is assigned to the image and 114848b8605Smrg written to <name>, the handle (local to the DRM file descriptor, 115848b8605Smrg for use with DRM kernel modesetting API) is written to <handle> if 116848b8605Smrg non-NULL and the stride (in bytes) is written to <stride>, if 117848b8605Smrg non-NULL. 118848b8605Smrg 119848b8605Smrg Import a shared buffer by calling eglCreateImageKHR with 120848b8605Smrg EGL_DRM_BUFFER_MESA as the target, using EGL_WIDTH, EGL_HEIGHT, 121848b8605Smrg EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_STRIDE_MESA 122848b8605Smrg in the attrib list. 123848b8605Smrg 124848b8605SmrgIssues 125848b8605Smrg 126848b8605Smrg 1. Why don't we use eglCreateImageKHR with a target that 127848b8605Smrg indicates that we want to create an EGLImage from scratch? 128848b8605Smrg 129848b8605Smrg RESOLVED: The eglCreateImageKHR entry point is reserved for 130848b8605Smrg creating an EGLImage from an already existing client API 131848b8605Smrg resource. This is fine when we're creating the EGLImage from 132848b8605Smrg an existing DRM buffer name, it doesn't seem right to overload 133848b8605Smrg the function to also allocate the underlying resource. 134848b8605Smrg 135848b8605Smrg 2. Why don't we use an eglQueryImageMESA type functions for 136848b8605Smrg querying the DRM EGLImage attributes (name, handle, and stride)? 137848b8605Smrg 138848b8605Smrg RESOLVED: The eglQueryImage function has been proposed often, 139848b8605Smrg but it goes against the EGLImage design. EGLImages are opaque 140848b8605Smrg handles to a 2D array of pixels, which can be passed between 141848b8605Smrg client APIs. By referencing an EGLImage in a client API, the 142848b8605Smrg EGLImage target (a texture, a renderbuffer or such) can be 143848b8605Smrg used to query the attributes of the EGLImage. We don't have a 144848b8605Smrg full client API for creating and querying DRM buffers, though, 145848b8605Smrg so we use a new EGL extension entry point instead. 146848b8605Smrg 147848b8605SmrgRevision History 148848b8605Smrg 149848b8605Smrg Version 1, June 3, 2010 150848b8605Smrg Initial draft (Kristian Høgsberg) 151848b8605Smrg Version 2, August 25, 2010 152848b8605Smrg Flesh out the extension a bit, add final EGL tokens, capture 153848b8605Smrg some of the original discussion in the issues section. 154