15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci EXT_external_buffer 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_EXT_external_buffer 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Jeff Leger (jleger 'at' qti.qualcomm.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Sam Holmes 165bd8deadSopenharmony_ci Maurice Ribble 175bd8deadSopenharmony_ci Matt Netsch 185bd8deadSopenharmony_ci Jeremy Gebben 195bd8deadSopenharmony_ci John Bates 205bd8deadSopenharmony_ci Craig Donner 215bd8deadSopenharmony_ci Jeff Leger 225bd8deadSopenharmony_ci Rob VanReenen 235bd8deadSopenharmony_ci Tom Kneeland 245bd8deadSopenharmony_ci Jesse Hall 255bd8deadSopenharmony_ci Jan-Harald Fredriksen 265bd8deadSopenharmony_ci Daniel Koch 275bd8deadSopenharmony_ci Mathias Heyer 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ciStatus 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ci Complete 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciVersion 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci Last Modified Date: May 29, 2017 365bd8deadSopenharmony_ci Revision: 1.0 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ciNumber 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci OpenGL ES Extension #284 415bd8deadSopenharmony_ci OpenGL Extension #508 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ciDependencies 445bd8deadSopenharmony_ci 455bd8deadSopenharmony_ci OpenGL ES 3.1 and EXT_buffer_storage are required for OpenGL ES 465bd8deadSopenharmony_ci implementations. 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci OpenGL 4.4 is required for OpenGL implementations. 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci This extension is written against the OpenGL ES 3.1 (June 4, 2014) 515bd8deadSopenharmony_ci Specification. 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ci This extension is written against version 3 of EXT_buffer_storage. 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci The definition of this extension is affected by the presence of 565bd8deadSopenharmony_ci GL_EXT_direct_state_access, GL_ARB_direct_state_access, or OpenGL 4.5. 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ciOverview 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci Extension EXT_buffer_storage introduced immutable storage buffers to 625bd8deadSopenharmony_ci OpenGL ES. This extension allows the data store for an immutable buffer to 635bd8deadSopenharmony_ci be sourced from an external EGLClientBuffer, allowing sharing of EGL client 645bd8deadSopenharmony_ci buffers across APIs, across processes, and across different processing 655bd8deadSopenharmony_ci cores such as the GPU, CPU, and DSP. 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci Operations can then be performed on the external buffer using standard 685bd8deadSopenharmony_ci GL buffer object procedures. The data in the allocation is not copied to 695bd8deadSopenharmony_ci the buffer object's data store; the external allocation represents a single 705bd8deadSopenharmony_ci memory allocation that can be shared across multiple GL objects -- this 715bd8deadSopenharmony_ci aspect is similar to EGL external images. On the other hand, the external 725bd8deadSopenharmony_ci buffer does not provide lifetime guarantees including orphaning and sibling 735bd8deadSopenharmony_ci behavior as provided by EGL external images. 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci The EGLClientBuffer must be allocated in a way which permits this shared 765bd8deadSopenharmony_ci access. For example, on Android via a shareable Android hardware buffer. 775bd8deadSopenharmony_ci This extension does not enable support for arbitrary EGLClientBuffers to be 785bd8deadSopenharmony_ci used as an external buffer. 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci It is the application's responsibility to ensure synchronization between 815bd8deadSopenharmony_ci operations performed by separate components (DSP / CPU / GPU) and processes 825bd8deadSopenharmony_ci on the external buffer. Additionally the application is responsible for 835bd8deadSopenharmony_ci avoiding violating existing GL spec requirements. For example, mapping a 845bd8deadSopenharmony_ci single shared allocation to two GL buffer objects and then performing 855bd8deadSopenharmony_ci CopyBufferSubData such that the read and write regions overlap would 865bd8deadSopenharmony_ci violate the existing CopyBufferSubData spec regarding copies performed 875bd8deadSopenharmony_ci with the same buffer set for source and destination. 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci The application must take any steps necessary to ensure memory access to 905bd8deadSopenharmony_ci the external buffer behaves as required by the application. For example, 915bd8deadSopenharmony_ci preventing compilation differences in data padding from causing data to be 925bd8deadSopenharmony_ci inadvertently corrupted by using defined structure alignment methods such 935bd8deadSopenharmony_ci as the std140 layout qualifier. The application is responsible for 945bd8deadSopenharmony_ci managing the lifetime of the external buffer, ensuring that the external 955bd8deadSopenharmony_ci buffer is not deleted as long as there are any GL buffer objects referring 965bd8deadSopenharmony_ci to it. 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ciNew Types 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci /* 1015bd8deadSopenharmony_ci * GLeglClientBufferEXT is an opaque handle to an EGLClientBuffer 1025bd8deadSopenharmony_ci */ 1035bd8deadSopenharmony_ci typedef void* GLeglClientBufferEXT; 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ciNew Procedures and Functions 1065bd8deadSopenharmony_ci 1075bd8deadSopenharmony_ci void BufferStorageExternalEXT(enum target, 1085bd8deadSopenharmony_ci intptr offset, 1095bd8deadSopenharmony_ci sizeiptr size, 1105bd8deadSopenharmony_ci eglClientBufferEXT clientBuffer, 1115bd8deadSopenharmony_ci bitfield flags); 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci [[ The following is only added if GL_EXT_direct_state_access, 1145bd8deadSopenharmony_ci GL_ARB_direct_state_access, or OpenGL 4.5 is supported. ]] 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci void NamedBufferStorageExternalEXT(uint buffer, 1175bd8deadSopenharmony_ci intptr offset, 1185bd8deadSopenharmony_ci sizeiptr size, 1195bd8deadSopenharmony_ci eglClientBufferEXT clientBuffer, 1205bd8deadSopenharmony_ci bitfield flags); 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ciNew Tokens 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci None 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL ES 3.1 Specification (Buffer Objects) 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ciModify Section 6.2, (Creating and Modifying Buffer Object Data Stores). After 1295bd8deadSopenharmony_cithe section describing BufferStorageEXT, insert the following: 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci The command 1325bd8deadSopenharmony_ci 1335bd8deadSopenharmony_ci void BufferStorageExternalEXT(enum target, intptr offset, 1345bd8deadSopenharmony_ci sizeiptr size, eglClientBufferEXT clientBuffer, 1355bd8deadSopenharmony_ci bitfield flags); 1365bd8deadSopenharmony_ci 1375bd8deadSopenharmony_ci behaves similar to BufferStorageEXT, but rather than allocate an immutable 1385bd8deadSopenharmony_ci data store, the specified client buffer is referenced as the immutable 1395bd8deadSopenharmony_ci data store. Such a store may not be modified through further calls to 1405bd8deadSopenharmony_ci BufferStorageExternalEXT, BufferStorageEXT, or BufferData. 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci <target> Specifies the target buffer object. The symbolic constant must be 1435bd8deadSopenharmony_ci one of the targets listed in table 6.1. <offset> and <size> specify, in 1445bd8deadSopenharmony_ci basic machine units, the range of the client buffer to be bound to the data 1455bd8deadSopenharmony_ci store. <offset> must be zero. 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ci <clientBuffer> Is the handle of a valid EGLClientBuffer resource (cast 1485bd8deadSopenharmony_ci into type eglClientBufferEXT). The EGLClientBuffer must be allocated in a 1495bd8deadSopenharmony_ci platform-specific way which permits shared access. For example, on Android 1505bd8deadSopenharmony_ci via a sharable Android hardware buffer (struct AHardwareBuffer), converted 1515bd8deadSopenharmony_ci into EGLClientBuffer via extension EGL_ANDROID_get_native_client_buffer. 1525bd8deadSopenharmony_ci Other platforms would require a similar mechanism. This extension does not 1535bd8deadSopenharmony_ci enable support for arbitrary EGLClientBuffers to be used as a shared buffer. 1545bd8deadSopenharmony_ci <flags> is the bitwise OR of flags describing the intended usage of the buffer 1555bd8deadSopenharmony_ci object's external data store by the application. Valid flags and their 1565bd8deadSopenharmony_ci meanings are as described for BufferStorageEXT. 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci The values of the buffer object's state variables will match those for other 1595bd8deadSopenharmony_ci *BufferStorageEXT calls, as specified in table 6.3. 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci The behavior follows other immutable buffers; BufferStorageExternalEXT sets the 1625bd8deadSopenharmony_ci created buffer's BUFFER_IMMUTABLE_STORAGE_EXT to TRUE. 1635bd8deadSopenharmony_ci 1645bd8deadSopenharmony_ci [[ The following is only added if GL_EXT_direct_state_access, 1655bd8deadSopenharmony_ci GL_ARB_direct_state_access, or OpenGL 4.5 is supported. ]] 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci The command 1685bd8deadSopenharmony_ci 1695bd8deadSopenharmony_ci void NamedBufferStorageExternalEXT(uint buffer, intptr offset, 1705bd8deadSopenharmony_ci sizeiptr size, eglClientBufferEXT clientBuffer, 1715bd8deadSopenharmony_ci bitfield flags); 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci behaves similarly to BufferStorageExternalEXT, except that the buffer whose 1745bd8deadSopenharmony_ci storage is to be defined is specified by <buffer> rather than by the current 1755bd8deadSopenharmony_ci binding to <target>. 1765bd8deadSopenharmony_ci 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ciErrors 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci INVALID_OPERATION is generated by BufferStorageExternalEXT if zero is bound to 1815bd8deadSopenharmony_ci <target>. 1825bd8deadSopenharmony_ci 1835bd8deadSopenharmony_ci INVALID_OPERATION is generated by BufferStorageExternalEXT, if the 1845bd8deadSopenharmony_ci BUFFER_IMMUTABLE_STORAGE flag of the buffer bound to <target> is TRUE. 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageExternalEXT if <offset> is not 0. 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageExternalEXT if <size> is 0 1895bd8deadSopenharmony_ci or negative. 1905bd8deadSopenharmony_ci 1915bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageExternalEXT if <offset> + <size> 1925bd8deadSopenharmony_ci exceeds the size of the EGLClientBuffer. 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageExternalEXT if <flags> has any 1955bd8deadSopenharmony_ci bits set other than those defined above. 1965bd8deadSopenharmony_ci 1975bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageExternalEXT if <flags> contains 1985bd8deadSopenharmony_ci MAP_PERSISTENT_BIT_EXT but does not contain at least one of MAP_READ_BIT or 1995bd8deadSopenharmony_ci MAP_WRITE_BIT. 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageExternalEXT if <flags> contains 2025bd8deadSopenharmony_ci MAP_COHERENT_BIT_EXT, but does not also contain MAP_PERSISTENT_BIT_EXT. 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci INVALID_ENUM is generated by BufferStorageExternalEXT if <target> is not one 2055bd8deadSopenharmony_ci of the accepted buffer targets. 2065bd8deadSopenharmony_ci 2075bd8deadSopenharmony_ci INVALID_OPERATION is generated by BufferStorageExternalEXT if the shared 2085bd8deadSopenharmony_ci buffer is not allocated in a way which permits shared access by the GPU. 2095bd8deadSopenharmony_ci 2105bd8deadSopenharmony_ci [[ The following is only added if GL_EXT_direct_state_access or 2115bd8deadSopenharmony_ci GL_ARB_direct_state_access is supported. ]] 2125bd8deadSopenharmony_ci 2135bd8deadSopenharmony_ci An INVALID_OPERATION error is generated by NamedBufferStorageExternalEXT if 2145bd8deadSopenharmony_ci the BUFFER_IMMUTABLE_STORAGE_EXT flag of <buffer> is set to TRUE. 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ciInteractions with GL_EXT_direct_state_access, GL_ARB_direct_state_access and 2175bd8deadSopenharmony_ciOpenGL 4.5 2185bd8deadSopenharmony_ci 2195bd8deadSopenharmony_ci If none of GL_EXT_direct_state_access, GL_ARB_direct_state_access, or 2205bd8deadSopenharmony_ci OpenGL 4.5, the NamedBufferStorageExternalEXT entry-point is not 2215bd8deadSopenharmony_ci added and all references to it should be ignored. 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ciIssues 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci 1. How are possible GPU cache interactions handled? 2265bd8deadSopenharmony_ci 2275bd8deadSopenharmony_ci The application is responsible for synchronizing writes to the shared buffer 2285bd8deadSopenharmony_ci by other processing cores (e.g. DSP), and making those available to CPU 2295bd8deadSopenharmony_ci reads for the processing of client-side GL commands (e.g., BufferSubData). 2305bd8deadSopenharmony_ci The GL implementation should guarantee that available writes by other cores 2315bd8deadSopenharmony_ci (e.g., DSP) are visible to the GPU when server-side commands read from the 2325bd8deadSopenharmony_ci shared buffer. 2335bd8deadSopenharmony_ci 2345bd8deadSopenharmony_ci PROPOSED: The exact granularity with which available writes from other cores 2355bd8deadSopenharmony_ci e.g., DSP) become visible to the CPU and GPU is implementation dependent. 2365bd8deadSopenharmony_ci 2375bd8deadSopenharmony_ci 2. Should EGLClientBuffers, be directly referenced by the GL API? 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci For images, a set of EGL and client API extensions provide import/export 2405bd8deadSopenharmony_ci of EGLImages from client APIs and native buffers. The EGLImage also provides 2415bd8deadSopenharmony_ci lifetime guarantees including orphaning and sibling behavior. This extension 2425bd8deadSopenharmony_ci is more narrowly focused, specifically targeted to the import of EGLClientBuffers 2435bd8deadSopenharmony_ci as GL buffers, and requiring the application to manage the resource lifetime. 2445bd8deadSopenharmony_ci As such, it may not warrant a new EGL object or EGL extension. 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci RESOLVED: A corresponding EGL object and extension is not required. When 2475bd8deadSopenharmony_ci using this extension, applications are expected to cast EGLClientBuffer as 2485bd8deadSopenharmony_ci GLeglClientBufferEXT. 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ciRevision History 2515bd8deadSopenharmony_ci 2525bd8deadSopenharmony_ci Rev. Date Author Changes 2535bd8deadSopenharmony_ci ---- ---------- -------- ----------------------------------------- 2545bd8deadSopenharmony_ci 0.1 04/18/2017 sholmes Initial version. Based on QCOM_shared_buffer. 2555bd8deadSopenharmony_ci 0.2 05/16/2017 jleger Renamed the extension and reworked it to to 2565bd8deadSopenharmony_ci be an extension to EXT_buffer_storage. 2575bd8deadSopenharmony_ci 0.3 05/24/2017 jleger Add offset parameter and other cleanup. 2585bd8deadSopenharmony_ci 0.4 05/25/2017 jleger Add DSA entrypoint and minor cleanup. 2595bd8deadSopenharmony_ci 1.0 05/29/2017 dgkoch Add interactions with GL, minor cleanup. 260