15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci EXT_buffer_storage 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_EXT_buffer_storage 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Daniel Koch, NVIDIA Corporation (dkoch 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Jonas Gustavsson, Sony Mobile 165bd8deadSopenharmony_ci Slawomir Grajewski, Intel 175bd8deadSopenharmony_ci Klaus Gerlicher, NVIDIA 185bd8deadSopenharmony_ci Contributors to ARB_buffer_storage 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ciNotice 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ci Copyright (c) 2013 The Khronos Group Inc. Copyright terms at 235bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Portions Copyright (c) 2014 NVIDIA Corporation. 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciStatus 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci Complete 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciVersion 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci Last Modified Date: May 1, 2015 345bd8deadSopenharmony_ci Author Revision: 3 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ciNumber 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci OpenGL ES Extension #239 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ciDependencies 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci OpenGL ES 3.1 is required. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci This extension is written against the OpenGL ES 3.1 (June 4, 2014) 455bd8deadSopenharmony_ci Specification. 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ci The definition of this extension is affected by the presence of 485bd8deadSopenharmony_ci GL_EXT_direct_state_access. 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ciOverview 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci OpenGL ES has long supported buffer objects as a means of storing data 535bd8deadSopenharmony_ci that may be used to source vertex attributes, pixel data for textures, 545bd8deadSopenharmony_ci uniforms and other elements. In un-extended ES, buffer data stores 555bd8deadSopenharmony_ci are mutable - that is, they may be de-allocated or resized while they 565bd8deadSopenharmony_ci are in use. The GL_EXT_texture_storage extension added immutable storage 575bd8deadSopenharmony_ci for texture objects (and was subsequently incorporated into OpenGL ES 3.0). 585bd8deadSopenharmony_ci This extension further applies the concept of immutable storage to 595bd8deadSopenharmony_ci buffer objects. If an implementation is aware of a buffer's immutability, 605bd8deadSopenharmony_ci it may be able to make certain assumptions or apply particular 615bd8deadSopenharmony_ci optimizations in order to increase performance or reliability. 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci Furthermore, this extension allows applications to pass additional 645bd8deadSopenharmony_ci information about a requested allocation to the implementation which it 655bd8deadSopenharmony_ci may use to select memory heaps, caching behavior or allocation strategies. 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci Finally, this extension introduces the concept of persistent client 685bd8deadSopenharmony_ci mappings of buffer objects, which allow clients to retain pointers to a 695bd8deadSopenharmony_ci buffer's data store returned as the result of a mapping, and to issue 705bd8deadSopenharmony_ci drawing commands while those mappings are in place. 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ciNew Procedures and Functions 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci void BufferStorageEXT(enum target, 755bd8deadSopenharmony_ci sizeiptr size, 765bd8deadSopenharmony_ci const void * data, 775bd8deadSopenharmony_ci bitfield flags); 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ci When EXT_direct_state_access is present: 805bd8deadSopenharmony_ci 815bd8deadSopenharmony_ci void NamedBufferStorageEXT(uint buffer, 825bd8deadSopenharmony_ci sizeiptr size, 835bd8deadSopenharmony_ci const void * data, 845bd8deadSopenharmony_ci bitfield flags); 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ciNew Tokens 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci Accepted in the <flags> parameter of BufferStorageEXT and 895bd8deadSopenharmony_ci NamedBufferStorageEXT: 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci MAP_READ_BIT 0x0001 (existing) 925bd8deadSopenharmony_ci MAP_WRITE_BIT 0x0002 (existing) 935bd8deadSopenharmony_ci MAP_PERSISTENT_BIT_EXT 0x0040 945bd8deadSopenharmony_ci MAP_COHERENT_BIT_EXT 0x0080 955bd8deadSopenharmony_ci DYNAMIC_STORAGE_BIT_EXT 0x0100 965bd8deadSopenharmony_ci CLIENT_STORAGE_BIT_EXT 0x0200 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci Accepted as part of the <access> parameter to MapBufferRange: 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci MAP_PERSISTENT_BIT_EXT 0x0040 (as above) 1015bd8deadSopenharmony_ci MAP_COHERENT_BIT_EXT 0x0080 (as above) 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetBufferParameter{i|i64}v: 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci BUFFER_IMMUTABLE_STORAGE_EXT 0x821F 1065bd8deadSopenharmony_ci BUFFER_STORAGE_FLAGS_EXT 0x8220 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci Accepted by the <barriers> parameter of MemoryBarrier: 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ciIP Status 1135bd8deadSopenharmony_ci 1145bd8deadSopenharmony_ci No known IP claims. 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL ES 3.1 Specification 1175bd8deadSopenharmony_ci(OpenGL ES Fundamentals) 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ci Insert before the last line of Section 2.6.2, "Buffer Objects", p. 24: 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ci Under certain circumstances, the data store of a buffer object may 1225bd8deadSopenharmony_ci be shared between the client and server and accessed simultaneously 1235bd8deadSopenharmony_ci by both. 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL ES 3.1 Specification (Buffer Objects) 1265bd8deadSopenharmony_ci 1275bd8deadSopenharmony_ci Modify Section 6.1 (Creating and Binding Buffer Objects) 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ci Append to Table 6.2, "Buffer object parameters and their values", p.49: 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci +------------------------------+---------+---------+------------------+ 1325bd8deadSopenharmony_ci | | | Initial | Legal | 1335bd8deadSopenharmony_ci | Name | Type | Value | Values | 1345bd8deadSopenharmony_ci +------------------------------+---------+---------+------------------+ 1355bd8deadSopenharmony_ci | BUFFER_IMMUTABLE_STORAGE_EXT | boolean | FALSE | TRUE, FALSE | 1365bd8deadSopenharmony_ci | BUFFER_STORAGE_FLAGS_EXT | int | 0 | See section 6.2 | 1375bd8deadSopenharmony_ci +------------------------------+---------+---------+------------------+ 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci Modify Section 6.2, (Creating and Modifying Buffer Object Data Stores), 1415bd8deadSopenharmony_ci p. 57 as follows: 1425bd8deadSopenharmony_ci 1435bd8deadSopenharmony_ci The data store of a buffer object is created by calling 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ci void BufferStorageEXT(enum target, 1465bd8deadSopenharmony_ci sizeiptr size, 1475bd8deadSopenharmony_ci const void * data, 1485bd8deadSopenharmony_ci bitfield flags); 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci with <target> set to one of the targets listed in Table 6.1, <size> set to 1515bd8deadSopenharmony_ci the size of the data store in basic machine units and <flags> containing 1525bd8deadSopenharmony_ci a bitfield describing the intended usage of the data store. The data 1535bd8deadSopenharmony_ci store of the buffer object bound to <target> is allocated as a result of 1545bd8deadSopenharmony_ci a call to this function and cannot be de-allocated until the buffer is 1555bd8deadSopenharmony_ci deleted with a call to DeleteBuffers. Such a store may not be 1565bd8deadSopenharmony_ci re-allocated through further calls to BufferStorageEXT or BufferData. 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci <data> specifies the address in client memory of the data that should 1595bd8deadSopenharmony_ci be used to initialize the buffer's data store. If <data> is NULL, the 1605bd8deadSopenharmony_ci data store of the buffer is created, but contains undefined data. 1615bd8deadSopenharmony_ci Otherwise, <data> should point to an array of at least <size> basic 1625bd8deadSopenharmony_ci machine units. 1635bd8deadSopenharmony_ci 1645bd8deadSopenharmony_ci <flags> is the bitwise OR of flags describing the intended usage 1655bd8deadSopenharmony_ci of the buffer object's data store by the application. Valid flags and 1665bd8deadSopenharmony_ci their meanings are as follows: 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci DYNAMIC_STORAGE_BIT_EXT The contents of the data store may be 1695bd8deadSopenharmony_ci updated after creation through calls to BufferSubData. If this bit is not 1705bd8deadSopenharmony_ci set, the buffer content may not be directly updated by the client. The 1715bd8deadSopenharmony_ci <data> argument may be used to specify the initial content of the buffer's 1725bd8deadSopenharmony_ci data store regardless of the presence of the DYNAMIC_STORAGE_BIT_EXT. 1735bd8deadSopenharmony_ci Regardless of the presence of this bit, buffers may always be updated 1745bd8deadSopenharmony_ci with server-side calls such as CopyBufferSubData. 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci MAP_READ_BIT The data store may be mapped by the client for 1775bd8deadSopenharmony_ci read access and a pointer in the client's address space obtained that may 1785bd8deadSopenharmony_ci be read from. 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci MAP_WRITE_BIT The data store may be mapped by the client for 1815bd8deadSopenharmony_ci write access and a pointer in the client's address space obtained that may 1825bd8deadSopenharmony_ci be written to. 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ci MAP_PERSISTENT_BIT_EXT The client may request that the server read from 1855bd8deadSopenharmony_ci or write to the buffer while it is mapped. The client's pointer to the 1865bd8deadSopenharmony_ci data store remains valid so long as the data store is mapped, even during 1875bd8deadSopenharmony_ci execution of drawing or dispatch commands. 1885bd8deadSopenharmony_ci 1895bd8deadSopenharmony_ci MAP_COHERENT_BIT_EXT Shared access to buffers that are simultaneously 1905bd8deadSopenharmony_ci mapped for client access and are used by the server will be coherent, so 1915bd8deadSopenharmony_ci long as that mapping is performed using MapBufferRange. That is, data 1925bd8deadSopenharmony_ci written to the store by either the client or server will be visible to any 1935bd8deadSopenharmony_ci subsequently issued GL commands with no further action taken by the 1945bd8deadSopenharmony_ci application. In particular: 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci - If MAP_COHERENT_BIT_EXT is not set and the client performs a write 1975bd8deadSopenharmony_ci followed by a call to one of the FlushMapped*BufferRange commands 1985bd8deadSopenharmony_ci with a range including the written range, then in subsequent 1995bd8deadSopenharmony_ci commands the server will see the writes. 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci - If MAP_COHERENT_BIT_EXT is set and the client performs a write, then in 2025bd8deadSopenharmony_ci subsequent commands the server will see the writes. 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci - If MAP_COHERENT_BIT_EXT is not set and the server performs a write, the 2055bd8deadSopenharmony_ci application must call MemoryBarrier with the 2065bd8deadSopenharmony_ci CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT set and then call FenceSync with 2075bd8deadSopenharmony_ci SYNC_GPU_COMMANDS_COMPLETE (or Finish). Then the CPU will see the 2085bd8deadSopenharmony_ci writes after the sync is complete. 2095bd8deadSopenharmony_ci 2105bd8deadSopenharmony_ci - If MAP_COHERENT_BIT_EXT is set and the server does a write, the app must 2115bd8deadSopenharmony_ci call FenceSync with SYNC_GPU_COMMANDS_COMPLETE (or Finish). Then the 2125bd8deadSopenharmony_ci CPU will see the writes after the sync is complete. 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ci CLIENT_STORAGE_BIT_EXT When all other criteria for the buffer storage 2155bd8deadSopenharmony_ci allocation are met, this bit may be used by an implementation to determine 2165bd8deadSopenharmony_ci whether to use storage that is local to the server or to the client to 2175bd8deadSopenharmony_ci serve as the backing store for the buffer. 2185bd8deadSopenharmony_ci 2195bd8deadSopenharmony_ci If <flags> contains MAP_PERSISTENT_BIT_EXT, it must also contain at least one 2205bd8deadSopenharmony_ci of MAP_READ_BIT or MAP_WRITE_BIT. 2215bd8deadSopenharmony_ci 2225bd8deadSopenharmony_ci It is an error to specify MAP_COHERENT_BIT_EXT without also specifying 2235bd8deadSopenharmony_ci MAP_PERSISTENT_BIT_EXT. 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci BufferStorageEXT deletes any existing data store, and sets the values of 2265bd8deadSopenharmony_ci the buffer object's state variables as shown in table 6.3. 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci If any portion of the buffer object is mapped in the current context or 2295bd8deadSopenharmony_ci any context current to another thread, it is as though UnmapBuffer (see 2305bd8deadSopenharmony_ci section 6.3.1) is executed in each such context prior to deleting the 2315bd8deadSopenharmony_ci existing data store. 2325bd8deadSopenharmony_ci 2335bd8deadSopenharmony_ci Name | Value for | Value for 2345bd8deadSopenharmony_ci | BufferData | *BufferStorageEXT 2355bd8deadSopenharmony_ci -----------------------------+-------------------------+------------------ 2365bd8deadSopenharmony_ci BUFFER_SIZE | <size> | <size> 2375bd8deadSopenharmony_ci BUFFER_USAGE | <usage> | DYNAMIC_DRAW 2385bd8deadSopenharmony_ci BUFFER_ACCESS | READ_WRITE | READ_WRITE 2395bd8deadSopenharmony_ci BUFFER_ACCESS_FLAGS | 0 | 0 2405bd8deadSopenharmony_ci BUFFER_IMMUTABLE_STORAGE_EXT | FALSE | TRUE 2415bd8deadSopenharmony_ci BUFFER_MAPPED | FALSE | FALSE 2425bd8deadSopenharmony_ci BUFFER_MAP_POINTER | NULL | NULL 2435bd8deadSopenharmony_ci BUFFER_MAP_OFFSET | 0 | 0 2445bd8deadSopenharmony_ci BUFFER_MAP_LENGTH | 0 | 0 2455bd8deadSopenharmony_ci BUFFER_STORAGE_FLAGS_EXT | MAP_READ_BIT | | <flags> 2465bd8deadSopenharmony_ci | MAP_WRITE_BIT | | 2475bd8deadSopenharmony_ci | DYNAMIC_STORAGE_BIT_EXT | 2485bd8deadSopenharmony_ci Table 6.3: Buffer object state after calling BufferData, 2495bd8deadSopenharmony_ci BufferStorageEXT, or NamedBufferStorageEXT. 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci A mutable data store may be allocated for a buffer object by calling 2525bd8deadSopenharmony_ci 2535bd8deadSopenharmony_ci void BufferData(...) 2545bd8deadSopenharmony_ci 2555bd8deadSopenharmony_ci <include the remainder of Section 6.2 as written, and then append>. 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci Calling BufferData is equivalent to calling BufferStorageEXT with 2585bd8deadSopenharmony_ci <target>, <size> and <data> as specified, and <flags> set to the logical 2595bd8deadSopenharmony_ci OR of DYNAMIC_STORAGE_BIT_EXT, MAP_READ_BIT and MAP_WRITE_BIT. The GL will 2605bd8deadSopenharmony_ci use the value of <usage> parameter to BufferData as a hint to further 2615bd8deadSopenharmony_ci determine the intended use of the buffer. However, BufferStorageEXT 2625bd8deadSopenharmony_ci allocates immutable storage whereas BufferData allocates mutable storage. 2635bd8deadSopenharmony_ci Thus, when a buffer's data store is allocated through a call to BufferData, 2645bd8deadSopenharmony_ci the buffer's BUFFER_IMMUTABLE_STORAGE_EXT flags is set to FALSE. 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ci Add the following errors: 2675bd8deadSopenharmony_ci 2685bd8deadSopenharmony_ci An INVALID_OPERATION error is generated by BufferData and BufferStorageEXT 2695bd8deadSopenharmony_ci if the BUFFER_IMMUTABLE_STORAGE_EXT flag of the buffer bound to <target> is 2705bd8deadSopenharmony_ci set to TRUE. 2715bd8deadSopenharmony_ci 2725bd8deadSopenharmony_ci An INVALID_OPERATION error is generated by BufferSubData if the 2735bd8deadSopenharmony_ci BUFFER_IMMUTABLE_STORAGE_EXT flag of the buffer bound to <target> is TRUE 2745bd8deadSopenharmony_ci and the value of BUFFER_STORAGE_FLAGS_EXT for the buffer does not have 2755bd8deadSopenharmony_ci the DYNAMIC_STORAGE_BIT_EXT set. 2765bd8deadSopenharmony_ci 2775bd8deadSopenharmony_ci The command: 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci void NamedBufferStorageEXT(uint buffer, 2805bd8deadSopenharmony_ci sizeiptr size, 2815bd8deadSopenharmony_ci const void * data, 2825bd8deadSopenharmony_ci bitfield flags); 2835bd8deadSopenharmony_ci 2845bd8deadSopenharmony_ci behaves similarly to BufferStorageEXT, except that the buffer whose storage 2855bd8deadSopenharmony_ci is to be defined is specified by <buffer> rather than by the current 2865bd8deadSopenharmony_ci binding to <target>. 2875bd8deadSopenharmony_ci 2885bd8deadSopenharmony_ci Add the following error: 2895bd8deadSopenharmony_ci 2905bd8deadSopenharmony_ci An INVALID_OPERATION error is generated by NamedBufferStorageEXT if 2915bd8deadSopenharmony_ci the BUFFER_IMMUTABLE_STORAGE_EXT flag of <buffer> is set to TRUE. 2925bd8deadSopenharmony_ci 2935bd8deadSopenharmony_ci 2945bd8deadSopenharmony_ci Modify Section 6.3, (Mapping and Unmapping Buffer Data) 2955bd8deadSopenharmony_ci 2965bd8deadSopenharmony_ci Add to the bulleted list describing flags that modify buffer mappings, 2975bd8deadSopenharmony_ci p.54. 2985bd8deadSopenharmony_ci 2995bd8deadSopenharmony_ci * MAP_PERSISTENT_BIT_EXT indicates that it is not an error for the GL to 3005bd8deadSopenharmony_ci read data from or write data to the buffer while it is mapped (see 3015bd8deadSopenharmony_ci section 6.3.2). If this bit is set, the value of 3025bd8deadSopenharmony_ci BUFFER_STORAGE_FLAGS_EXT for the buffer being mapped must include 3035bd8deadSopenharmony_ci MAP_PERSISTENT_BIT_EXT. 3045bd8deadSopenharmony_ci 3055bd8deadSopenharmony_ci * MAP_COHERENT_BIT_EXT indicates that the mapping should be performed 3065bd8deadSopenharmony_ci coherently. That is, such a mapping follows the rules set forth in 3075bd8deadSopenharmony_ci section 6.2, "Creating and Modifying Buffer Object Data Stores". 3085bd8deadSopenharmony_ci If this bit is set, the value of BUFFER_STORAGE_FLAGS_EXT for the 3095bd8deadSopenharmony_ci buffer being mapped must include MAP_COHERENT_BIT. 3105bd8deadSopenharmony_ci 3115bd8deadSopenharmony_ci 3125bd8deadSopenharmony_ci Add the following to the description of FlushMappedBufferRange, p.56: 3135bd8deadSopenharmony_ci 3145bd8deadSopenharmony_ci If a buffer range is mapped with both the MAP_PERSISTENT_BIT_EXT and 3155bd8deadSopenharmony_ci MAP_FLUSH_EXPLICIT_BIT set, then FlushMappedBufferRange may be called to 3165bd8deadSopenharmony_ci ensure that data written by the client into the flushed region becomes 3175bd8deadSopenharmony_ci visible to the server. Data written to a coherent store will always 3185bd8deadSopenharmony_ci become visible to the server after an unspecified period of time. 3195bd8deadSopenharmony_ci 3205bd8deadSopenharmony_ci 3215bd8deadSopenharmony_ci Modify Section 6.3.2, "Effects of Mapping Buffers on Other GL Commands" 3225bd8deadSopenharmony_ci to read: 3235bd8deadSopenharmony_ci 3245bd8deadSopenharmony_ci Any GL command which attempts to read from, write to, or change the state 3255bd8deadSopenharmony_ci of a buffer object may generate an INVALID_OPERATION error if all or part 3265bd8deadSopenharmony_ci of the buffer object is mapped, unless it was allocated by a call to 3275bd8deadSopenharmony_ci *BufferStorageEXT with the MAP_PERSISTENT_BIT_EXT included in <flags>. 3285bd8deadSopenharmony_ci However, only commands which explicitly describe this error are required 3295bd8deadSopenharmony_ci to do so. If an error is not generated, using such commands to perform 3305bd8deadSopenharmony_ci invalid reads, writes, or state changes will have undefined results and 3315bd8deadSopenharmony_ci may result in GL interruption or termination. 3325bd8deadSopenharmony_ci 3335bd8deadSopenharmony_ci 3345bd8deadSopenharmony_ci Modify Section 6.7, (Buffer Object State), p. 62: 3355bd8deadSopenharmony_ci 3365bd8deadSopenharmony_ci Add the following required state to a buffer object: 3375bd8deadSopenharmony_ci 3385bd8deadSopenharmony_ci ..., a boolean indicating whether or not buffer storage is 3395bd8deadSopenharmony_ci immutable, an unsigned integer storing the flags with which it was 3405bd8deadSopenharmony_ci allocated, ... 3415bd8deadSopenharmony_ci 3425bd8deadSopenharmony_ciAdditions to Chapter 7 of the OpenGL ES 3.1 Specification, 3435bd8deadSopenharmony_ci(Programs and Shaders) 3445bd8deadSopenharmony_ci 3455bd8deadSopenharmony_ci Add to the list of flags accepted by the <barriers> parameter to 3465bd8deadSopenharmony_ci MemoryBarrier in Section 7.11.2, "Shader Memory Access Synchronization": 3475bd8deadSopenharmony_ci 3485bd8deadSopenharmony_ci * CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT: Access by the client to 3495bd8deadSopenharmony_ci persistent mapped regions of buffer objects will reflect data written 3505bd8deadSopenharmony_ci by shaders prior to the barrier. Note that this may cause additional 3515bd8deadSopenharmony_ci synchronization operations. 3525bd8deadSopenharmony_ci 3535bd8deadSopenharmony_ciNew State 3545bd8deadSopenharmony_ci 3555bd8deadSopenharmony_ci Append to Table 20.4, "Buffer Object State", p.355: 3565bd8deadSopenharmony_ci 3575bd8deadSopenharmony_ci +------------------------------+------+----------------------+---------------+---------------------------------+------------+ 3585bd8deadSopenharmony_ci | Get Value | Type | Get Command | Initial Value | Description | Sec. | 3595bd8deadSopenharmony_ci +------------------------------+------+----------------------+---------------+---------------------------------+------------+ 3605bd8deadSopenharmony_ci | BUFFER_IMMUTABLE_STORAGE_EXT | B | GetBufferParameteriv | FALSE | TRUE if buffer's data store is | 6 | 3615bd8deadSopenharmony_ci | | | | | immutable, FALSE otherwise | | 3625bd8deadSopenharmony_ci | BUFFER_STORAGE_FLAGS_EXT | Z+ | GetBufferParameteriv | 0 | The buffer object's storage | 6 | 3635bd8deadSopenharmony_ci | | | | | flags. | | 3645bd8deadSopenharmony_ci +------------------------------+------+----------------------+---------------+---------------------------------+------------+ 3655bd8deadSopenharmony_ci 3665bd8deadSopenharmony_ciNew Implementation Dependent State 3675bd8deadSopenharmony_ci 3685bd8deadSopenharmony_ci None. 3695bd8deadSopenharmony_ci 3705bd8deadSopenharmony_ciErrors 3715bd8deadSopenharmony_ci 3725bd8deadSopenharmony_ci INVALID_OPERATION is generated by BufferStorageEXT if zero is bound to 3735bd8deadSopenharmony_ci <target>. 3745bd8deadSopenharmony_ci 3755bd8deadSopenharmony_ci INVALID_OPERATION is generated by BufferStorageEXT, NamedBufferStorageEXT 3765bd8deadSopenharmony_ci and BufferData if the BUFFER_IMMUTABLE_STORAGE flag of the buffer bound to 3775bd8deadSopenharmony_ci <target> is TRUE. 3785bd8deadSopenharmony_ci 3795bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageEXT and NamedBufferStorageEXT 3805bd8deadSopenharmony_ci if <size> is less than or equal to zero. 3815bd8deadSopenharmony_ci 3825bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageEXT and NamedBufferStorageEXT 3835bd8deadSopenharmony_ci if <flags> has any bits set other than those defined above. 3845bd8deadSopenharmony_ci 3855bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageEXT and NamedBufferStorageEXT if 3865bd8deadSopenharmony_ci <flags> contains MAP_PERSISTENT_BIT_EXT but does not contain 3875bd8deadSopenharmony_ci at least one of MAP_READ_BIT or 3885bd8deadSopenharmony_ci MAP_WRITE_BIT. 3895bd8deadSopenharmony_ci 3905bd8deadSopenharmony_ci INVALID_VALUE is generated by BufferStorageEXT and NamedBufferStorageEXT if 3915bd8deadSopenharmony_ci <flags> contains MAP_COHERENT_BIT_EXT, but does not also 3925bd8deadSopenharmony_ci contain MAP_PERSISTENT_BIT_EXT. 3935bd8deadSopenharmony_ci 3945bd8deadSopenharmony_ci INVALID_OPERATION is generated by MapBufferRange if any of MAP_READ_BIT, 3955bd8deadSopenharmony_ci MAP_WRITE_BIT, MAP_PERSISTENT_BIT_EXT, or MAP_COHERENT_BIT_EXT are included in 3965bd8deadSopenharmony_ci <access>, but the same bit is not included in the buffer's storage 3975bd8deadSopenharmony_ci flags. 3985bd8deadSopenharmony_ci 3995bd8deadSopenharmony_ci OUT_OF_MEMORY is generated by BufferStorageEXT and NamedBufferStorageEXT if 4005bd8deadSopenharmony_ci the GL is not able to allocate a data store with the properties requested 4015bd8deadSopenharmony_ci in <flags>. 4025bd8deadSopenharmony_ci 4035bd8deadSopenharmony_ci *REMOVE* all errors generated by any command should they detect access to 4045bd8deadSopenharmony_ci a mapped buffer and replace with language such as: 4055bd8deadSopenharmony_ci 4065bd8deadSopenharmony_ci INVALID_OPERATION is generated by <command> if the buffer is currently 4075bd8deadSopenharmony_ci mapped by MapBufferRange unless it was mapped with the 4085bd8deadSopenharmony_ci MAP_PERSISTENT_BIT_EXT included in <access>. 4095bd8deadSopenharmony_ci 4105bd8deadSopenharmony_ci 4115bd8deadSopenharmony_ciDependencies on GL_EXT_direct_state_access 4125bd8deadSopenharmony_ci 4135bd8deadSopenharmony_ci If GL_EXT_direct_state_access is not supported, remove all references to 4145bd8deadSopenharmony_ci NamedBufferStorageEXT. 4155bd8deadSopenharmony_ci 4165bd8deadSopenharmony_ciConformance Tests 4175bd8deadSopenharmony_ci 4185bd8deadSopenharmony_ci TBD 4195bd8deadSopenharmony_ci 4205bd8deadSopenharmony_ciUsage Examples 4215bd8deadSopenharmony_ci 4225bd8deadSopenharmony_ci Example 1: Updating the content of a buffer which does not have the 4235bd8deadSopenharmony_ci DYNAMIC flag set: 4245bd8deadSopenharmony_ci 4255bd8deadSopenharmony_ci // Allocate two buffers, one of which will be our 'staging buffer'. 4265bd8deadSopenharmony_ci GLuint bufs[2]; 4275bd8deadSopenharmony_ci glGenBuffers(2, &bufs[0]); 4285bd8deadSopenharmony_ci 4295bd8deadSopenharmony_ci // Client can map this buffer for write. 4305bd8deadSopenharmony_ci // One could possibly make this mapping persistent. 4315bd8deadSopenharmony_ci glBindBuffer(GL_COPY_READ_BUFFER, bufs[0]); 4325bd8deadSopenharmony_ci glBufferStorageEXT(GL_COPY_READ_BUFFER, size, NULL, 4335bd8deadSopenharmony_ci GL_MAP_WRITE_BIT); 4345bd8deadSopenharmony_ci 4355bd8deadSopenharmony_ci // Client cannot read or write this buffer, server can do both. 4365bd8deadSopenharmony_ci glBindBuffer(GL_COPY_WRITE_BUFFER, bufs[1]); 4375bd8deadSopenharmony_ci glBufferStorageEXT(GL_COPY_WRITE_BUFFER, size, NULL, 0); 4385bd8deadSopenharmony_ci 4395bd8deadSopenharmony_ci // Now, map the staging buffer to put data into it. 4405bd8deadSopenharmony_ci void * data = glMapBufferRange(GL_COPY_READ_BUFFER, 0, size, 4415bd8deadSopenharmony_ci GL_MAP_WRITE_BIT | 4425bd8deadSopenharmony_ci GL_MAP_INVALIDATE_BUFFER_BIT); 4435bd8deadSopenharmony_ci memcpy(data, source_data, size); 4445bd8deadSopenharmony_ci glUnmapBuffer(GL_COPY_READ_BUFFER); 4455bd8deadSopenharmony_ci 4465bd8deadSopenharmony_ci // Copy from the staging buffer to the server-side buffer. 4475bd8deadSopenharmony_ci glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, size); 4485bd8deadSopenharmony_ci 4495bd8deadSopenharmony_ci Example 2: Read from framebuffer into a buffer mapped into client's 4505bd8deadSopenharmony_ci address space: 4515bd8deadSopenharmony_ci 4525bd8deadSopenharmony_ci // Create buffer, allocate storage, and create a persistent map. 4535bd8deadSopenharmony_ci GLuint pbo; 4545bd8deadSopenharmony_ci glGenBuffers(1, &pbo); 4555bd8deadSopenharmony_ci glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo); 4565bd8deadSopenharmony_ci glBufferStorageEXT(GL_PIXEL_PACK_BUFFER, size, NULL, 4575bd8deadSopenharmony_ci GL_MAP_READ_BIT | 4585bd8deadSopenharmony_ci GL_MAP_PERSISTENT_BIT_EXT); 4595bd8deadSopenharmony_ci 4605bd8deadSopenharmony_ci void * data = glMapBufferRange(GL_PIXEL_PACK_BUFFER, 4615bd8deadSopenharmony_ci GL_MAP_READ_BIT | 4625bd8deadSopenharmony_ci GL_MAP_PERSISTENT_BIT_EXT); 4635bd8deadSopenharmony_ci 4645bd8deadSopenharmony_ci glReadPixels(0, 0, width, height, format, type, NULL); 4655bd8deadSopenharmony_ci glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT); 4665bd8deadSopenharmony_ci GLsync fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); 4675bd8deadSopenharmony_ci 4685bd8deadSopenharmony_ci // Do stuff to use time... 4695bd8deadSopenharmony_ci ReallyExpensiveFunction(); 4705bd8deadSopenharmony_ci 4715bd8deadSopenharmony_ci glClientWaitSync(fence); 4725bd8deadSopenharmony_ci 4735bd8deadSopenharmony_ci // Use the data written to the buffer 4745bd8deadSopenharmony_ci UseDataInMemory(data); 4755bd8deadSopenharmony_ci 4765bd8deadSopenharmony_ci 4775bd8deadSopenharmony_ciIssues 4785bd8deadSopenharmony_ci 4795bd8deadSopenharmony_ci Note: These issues apply specifically to the definition of the 4805bd8deadSopenharmony_ci EXT_buffer_storage specification, which is based on the OpenGL 4815bd8deadSopenharmony_ci extension ARB_buffer_storage as updated in OpenGL 4.5. For the full 4825bd8deadSopenharmony_ci set of historical issues, see ARB_buffer_storage which can be found 4835bd8deadSopenharmony_ci in the OpenGL Registry. 4845bd8deadSopenharmony_ci 4855bd8deadSopenharmony_ci (1) What functionality was changed relative to ARB_buffer_storage? 4865bd8deadSopenharmony_ci 4875bd8deadSopenharmony_ci - added EXT suffixes 4885bd8deadSopenharmony_ci - rebased against ES 3.1 4895bd8deadSopenharmony_ci - removed passing reference to ClearBufferSubData which doesn't exist 4905bd8deadSopenharmony_ci in OpenGL ES yet. 4915bd8deadSopenharmony_ci 4925bd8deadSopenharmony_ci (2) What commands are affected by the relaxed errors for persistently 4935bd8deadSopenharmony_ci mapped buffers? 4945bd8deadSopenharmony_ci 4955bd8deadSopenharmony_ci RESOLVED: In GL 4.5 the following commands have the relaxed 4965bd8deadSopenharmony_ci language BufferSubData, ClearBufferSubData, CopyBufferSubData, 4975bd8deadSopenharmony_ci GetBufferSubData and InvalidateBufferSubData. Of these commands 4985bd8deadSopenharmony_ci the only ones that apply to ES 3.1 are BufferSubData and 4995bd8deadSopenharmony_ci CopyBufferSubData. However, if additional extensions add any of 5005bd8deadSopenharmony_ci the other commands and EXT_buffer_storage is supported, they 5015bd8deadSopenharmony_ci would have the same behavior in ES. 5025bd8deadSopenharmony_ci 5035bd8deadSopenharmony_ci (3) Should we keep interactions with the NamedBufferStorageEXT 5045bd8deadSopenharmony_ci DSA command and interactions with EXT_direct_state_access? 5055bd8deadSopenharmony_ci 5065bd8deadSopenharmony_ci UNRESOLVED. TBD if there is interest in a DSA extension 5075bd8deadSopenharmony_ci based on ARB_direct_state_access. 5085bd8deadSopenharmony_ci 5095bd8deadSopenharmony_ci 5105bd8deadSopenharmony_ciRevision History 5115bd8deadSopenharmony_ci 5125bd8deadSopenharmony_ci Rev. Date Author Changes 5135bd8deadSopenharmony_ci ---- -------- -------- ----------------------------------------- 5145bd8deadSopenharmony_ci 1 09/17/14 dkoch EXT version based on ARB_buffer_storage v.24 5155bd8deadSopenharmony_ci 5165bd8deadSopenharmony_ci 2 03/27/15 dkoch Update status, clarify dependencies and tokens 5175bd8deadSopenharmony_ci 5185bd8deadSopenharmony_ci 3 05/01/15 dkoch Change description of MAP_COHERENT_BIT for 5195bd8deadSopenharmony_ci buffer storage so that barriers with 5205bd8deadSopenharmony_ci CLIENT_MAPPED_BUFFER_BARRIER_BIT do not need 5215bd8deadSopenharmony_ci to make CPU writes visible to the GPU in 5225bd8deadSopenharmony_ci this case without an explicit flush (Bug 5235bd8deadSopenharmony_ci 13578, sync w/ ARB_buffer_storage v.25). 524