1Name 2 3 NV_vertex_buffer_unified_memory 4 5Name Strings 6 7 GL_NV_vertex_buffer_unified_memory 8 9Contact 10 11 Jeff Bolz, NVIDIA Corporation (jbolz 'at' nvidia.com) 12 13Contributors 14 15 Mark Kilgard, NVIDIA 16 Jason Sams, NVIDIA 17 Eric Werness, NVIDIA 18 Christoph Kubisch, NVIDIA 19 20Status 21 22 Complete 23 24Version 25 26 Last Modified Date: July 8, 2015 27 Author Revision: 4 28 29Number 30 31 380 32 33Dependencies 34 35 Written based on the wording of the OpenGL 3.0 specification. 36 37 This extension interacts with NV_shader_buffer_load. 38 39 This extension interacts with EXT_direct_state_access. 40 41 This extension interacts with ARB_compatibility. 42 43 This extension interacts with OpenGL 3.2 44 45Overview 46 47 This extension provides a mechanism to specify vertex attrib and 48 element array locations using GPU addresses. 49 50 Binding vertex buffers is one of the most frequent and expensive 51 operations in many GL applications, due to the cost of chasing 52 pointers and binding objects described in the Overview of 53 NV_shader_buffer_load. The intent of this extension is to enable a 54 way for the application to specify vertex attrib state that alleviates 55 the overhead of object binds and driver memory management. 56 57New Procedures and Functions 58 59 void BufferAddressRangeNV(enum pname, uint index, uint64EXT address, 60 sizeiptr length); 61 62 void VertexFormatNV(int size, enum type, sizei stride); 63 void NormalFormatNV(enum type, sizei stride); 64 void ColorFormatNV(int size, enum type, sizei stride); 65 void IndexFormatNV(enum type, sizei stride); 66 void TexCoordFormatNV(int size, enum type, sizei stride); 67 void EdgeFlagFormatNV(sizei stride); 68 void SecondaryColorFormatNV(int size, enum type, sizei stride); 69 void FogCoordFormatNV(enum type, sizei stride); 70 void VertexAttribFormatNV(uint index, int size, enum type, 71 boolean normalized, sizei stride); 72 void VertexAttribIFormatNV(uint index, int size, enum type, 73 sizei stride); 74 75 void GetIntegerui64i_vNV(enum value, uint index, uint64EXT result[]); 76 77New Tokens 78 79 Accepted by the <cap> parameter of DisableClientState, 80 EnableClientState, IsEnabled: 81 82 VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E 83 ELEMENT_ARRAY_UNIFIED_NV 0x8F1F 84 85 Accepted by the <pname> parameter of BufferAddressRangeNV 86 and the <value> parameter of GetIntegerui64i_vNV: 87 88 VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 89 TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 90 91 Accepted by the <pname> parameter of BufferAddressRangeNV 92 and the <value> parameter of GetIntegerui64vNV: 93 94 VERTEX_ARRAY_ADDRESS_NV 0x8F21 95 NORMAL_ARRAY_ADDRESS_NV 0x8F22 96 COLOR_ARRAY_ADDRESS_NV 0x8F23 97 INDEX_ARRAY_ADDRESS_NV 0x8F24 98 EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 99 SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 100 FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 101 ELEMENT_ARRAY_ADDRESS_NV 0x8F29 102 103 Accepted by the <target> parameter of GetIntegeri_vNV or 104 GetIntegerui64i_vNV: 105 106 VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A 107 TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F 108 109 Accepted by the <value> parameter of GetIntegerv or 110 GetIntegerui64vNV: 111 112 VERTEX_ARRAY_LENGTH_NV 0x8F2B 113 NORMAL_ARRAY_LENGTH_NV 0x8F2C 114 COLOR_ARRAY_LENGTH_NV 0x8F2D 115 INDEX_ARRAY_LENGTH_NV 0x8F2E 116 EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 117 SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 118 FOG_COORD_ARRAY_LENGTH_NV 0x8F32 119 ELEMENT_ARRAY_LENGTH_NV 0x8F33 120 121 122Additions to Chapter 2 of the OpenGL 3.0 Specification (OpenGL Operation) 123 124 Add to Section 2.9 (end of p. 29) 125 126 The commands: 127 128 void VertexFormatNV(int size, enum type, sizei stride); 129 void NormalFormatNV(enum type, sizei stride); 130 void ColorFormatNV(int size, enum type, sizei stride); 131 void IndexFormatNV(enum type, sizei stride); 132 void TexCoordFormatNV(int size, enum type, sizei stride); 133 void EdgeFlagFormatNV(sizei stride); 134 void SecondaryColorFormatNV(int size, enum type, sizei stride); 135 void FogCoordFormatNV(enum type, sizei stride); 136 void VertexAttribFormatNV(uint index, int size, enum type, boolean normalized, sizei stride); 137 void VertexAttribIFormatNV(uint index, int size, enum type, sizei stride); 138 139 set the same vertex array format state as the corresponding command 140 where "Format" is changed to "Pointer" (and extension suffixes are 141 dropped or updated appropriately). They do not inspect the current 142 ARRAY_BUFFER binding for any error checks, nor do they modify the 143 pointer state or vertex attribute buffer bindings. The parameters are 144 interpreted as they are in the corresponding functions. 145 146 Add to Section 2.9.1 (p. 46) 147 148 While VERTEX_ATTRIB_ARRAY_UNIFIED_NV is enabled, the rendering 149 commands ArrayElement, DrawArrays, DrawElements, DrawRangeElements, 150 MultiDrawArrays, DrawArraysInstanced, and DrawElementsInstanced 151 operate as previously defined, except that data for enabled vertex and 152 attrib arrays are sourced from GPU addresses specified by the command: 153 154 void BufferAddressRangeNV(enum pname, uint index, uint64EXT address, 155 sizeiptr length); 156 157 where <pname> is VERTEX_ARRAY_ADDRESS_NV, NORMAL_ARRAY_ADDRESS_NV, 158 COLOR_ARRAY_ADDRESS_NV, INDEX_ARRAY_ADDRESS_NV, 159 EDGE_FLAG_ARRAY_ADDRESS_NV, SECONDARY_COLOR_ARRAY_ADDRESS_NV, 160 or FOG_COORD_ARRAY_ADDRESS_NV and <index> is ignored, or <pname> is 161 TEXTURE_COORD_ARRAY_ADDRESS_NV and <index> is the texture unit, 162 or <pname> is VERTEX_ATTRIB_ARRAY_ADDRESS_NV and <index> identifies 163 the generic vertex attribute whose address is being specified. 164 <address> specifies the GPU address from which arrays will be sourced, 165 and addresses beyond and including (<address> + <length>) will return 166 undefined values. If the address range of an enabled vertex attrib 167 does not belong to a buffer object that is resident at the time of 168 the Draw, undefined results, possibly including program termination, 169 may occur. 170 171 It is not possible to mix vertex or attrib arrays sourced from GPU 172 addresses with either vertex or attrib arrays in client memory or 173 specified with classic VBO bindings. 174 175 Add to Section 2.9.2 (p. 47) 176 177 While ELEMENT_ARRAY_UNIFIED_NV is enabled, DrawElements, 178 DrawElementsRange, MultiDrawElements, and DrawElementsInstanced source 179 their indices from the address specified by the command 180 BufferAddressRange where <pname> is ELEMENT_ARRAY_ADDRESS_NV and 181 <index> is zero, added to the <indices> parameter. If a Draw command 182 sources indices beyond and including (<address> + <length>), the index 183 values will be undefined. If the element array address range does not 184 belong to a buffer object that is resident at the time of the Draw, 185 undefined results, possibly including program termination, may occur. 186 187 Modify the language of NV_shader_buffer_load, replacing 188 "made (in)accessible to the GL via shader buffer loads" with "made 189 (in)accessible to the GL via shader buffer loads or via vertex attrib 190 and/or element array reads". 191 192Additions to Chapter 5 of the OpenGL 3.0 Specification (Special Functions) 193 194 Add to Section 5.4, p. 310 (Display Lists) 195 196 Add to the list of excluded Vertex Array commands: 197 BufferAddressRangeNV, and all VertexFormat* entry points added by 198 this extension. 199 200Additions to Chapter 6 of the OpenGL 3.0 Specification (State and State Requests) 201 202 Add to Section 6.1.11, p. 314 (Pointer, String, and 64-bit Queries) 203 204 Indexed 64-bit state variables are queried with the command: 205 206 void GetIntegerui64i_vNV(enum value, uint index, uint64EXT *data); 207 208 Legal values of <value> are only those that specify 209 GetIntegerui64i_vNV in the state tables in Chapter 6. 210 211Additions to the AGL/EGL/GLX/WGL Specifications 212 213 None. 214 215Errors 216 217 The error INVALID_VALUE is generated by BufferAddressRange if <length> 218 is negative. 219 220 The error INVALID_VALUE is generated by BufferAddressRange if <pname> 221 is VERTEX_ATTRIB_ARRAY_ADDRESS_NV and <index> is greater than the 222 supported number of numbered vertex attribs, or if <pname> is 223 TEXTURE_COORD_ARRAY_ADDRESS_NV and <index> is greater than 224 MAX_TEXTURE_COORDS. 225 226New State 227 228 Update Table 6.9, p. 347 (Vertex Array Object State) 229 230 Get Value Type Get Command Initial Value Sec Attribute 231 --------- ---- ----------- ------------- --- --------- 232 VERTEX_ATTRIB_ARRAY_UNIFIED_NV B IsEnabled FALSE 2.9 none 233 ELEMENT_ARRAY_UNIFIED_NV B IsEnabled FALSE 2.9 none 234 VERTEX_ATTRIB_ARRAY_ADDRESS_NV 16*Z64+ GetIntegerui64i_vNV 0 2.9 none 235 VERTEX_ATTRIB_ARRAY_LENGTH_NV 16*Z64+ GetIntegeri_v 0 2.9 none 236 VERTEX_ARRAY_ADDRESS_NV Z64+ GetIntegerui64vNV 0 2.9 none 237 VERTEX_ARRAY_LENGTH_NV Z64+ GetIntegerv 0 2.9 none 238 NORMAL_ARRAY_ADDRESS_NV Z64+ GetIntegerui64vNV 0 2.9 none 239 NORMAL_ARRAY_LENGTH_NV Z64+ GetIntegerv 0 2.9 none 240 COLOR_ARRAY_ADDRESS_NV Z64+ GetIntegerui64vNV 0 2.9 none 241 COLOR_ARRAY_LENGTH_NV Z64+ GetIntegerv 0 2.9 none 242 INDEX_ARRAY_ADDRESS_NV Z64+ GetIntegerui64vNV 0 2.9 none 243 INDEX_ARRAY_LENGTH_NV Z64+ GetIntegerv 0 2.9 none 244 TEXTURE_COORD_ARRAY_ADDRESS_NV 8*Z64+ GetIntegerui64i_vNV 0 2.9 none 245 TEXTURE_COORD_ARRAY_LENGTH_NV 8*Z64+ GetIntegeri_v 0 2.9 none 246 EDGE_FLAG_ARRAY_ADDRESS_NV Z64+ GetIntegerui64vNV 0 2.9 none 247 EDGE_FLAG_ARRAY_LENGTH_NV Z64+ GetIntegerv 0 2.9 none 248 SECONDARY_COLOR_ARRAY_ADDRESS_NV Z64+ GetIntegerui64vNV 0 2.9 none 249 SECONDARY_COLOR_ARRAY_LENGTH_NV Z64+ GetIntegerv 0 2.9 none 250 FOG_COORD_ARRAY_ADDRESS_NV Z64+ GetIntegerui64vNV 0 2.9 none 251 FOG_COORD_ARRAY_LENGTH_NV Z64+ GetIntegerv 0 2.9 none 252 ELEMENT_ARRAY_ADDRESS_NV Z64+ GetIntegerui64vNV 0 2.9 none 253 ELEMENT_ARRAY_LENGTH_NV Z64+ GetIntegerv 0 2.9 none 254 255Interactions with OpenGL 3.2 256 257 If the context version is greater or equal version 3.2, querying 258 all *_LENGTH_NV values can be done via GetInteger64v 259 as well as GetInteger64i_v. 260 261Dependencies on NV_shader_buffer_load: 262 263 This extension relies on the mechanisms to get addresses and make 264 buffers resident that NV_shader_buffer_load provides, but does not 265 rely on either the LOAD instruction or the changes to the Shading 266 Language. 267 268Dependencies on ARB_compatibility 269 270 If the context version is greater than 3.0 and does not include 271 ARB_compatibility functionality, then EnableClientState and 272 DisableClientState have been deprecated and removed. This extension 273 adds back those commands, but only requires that they accept the 274 VERTEX_ATTRIB_ARRAY_UNIFIED_NV and ELEMENT_ARRAY_UNIFIED_NV tokens. 275 276Examples 277 278 Creating several interleaved vertex buffers of the same format and 279 switching between them efficiently. 280 281 GenBuffers(N, vbos); 282 283 // initialize buffers 284 GLuint64EXT gpuAddrs[N]; 285 for (i = 0; i < N; ++i) { 286 BindBuffer(target, vbos[i]); 287 BufferData(target, vboSizes[i], vboData[i], STATIC_DRAW); 288 289 // get the address of this buffer and make it resident. 290 GetBufferParameterui64vNV(target, BUFFER_GPU_ADDRESS_NV, &gpuAddrs[i]); 291 MakeBufferResidentNV(target, READ_ONLY); 292 } 293 294 // setup format - 4-ubyte color, 4-float position 295 EnableClientState(COLOR_ARRAY); 296 EnableClientState(VERTEX_ARRAY); 297 ColorFormatNV(4, UNSIGNED_BYTE, 20); 298 VertexFormatNV(4, FLOAT, 20); 299 // enable vertex address use 300 EnableClientState(VERTEX_ATTRIB_ARRAY_UNIFIED_NV); 301 302 for (i = 0; i < N; ++i) { 303 // point at buffer i 304 BufferAddressRangeNV(COLOR_ARRAY_ADDRESS_NV, 0, gpuAddrs[i], vboSizes[i]); 305 BufferAddressRangeNV(VERTEX_ARRAY_ADDRESS_NV, 0, gpuAddrs[i]+4, vboSizes[i]-4); 306 307 DrawArrays(POINTS, 0, vboSizes[i]/20); 308 } 309 310 311Issues 312 313 1) Should any of the new commands be compiled into display lists? 314 315 RESOLVED: NO. It should be straightforward to allow any of the vertex 316 format commands or BufferAddressRangeNV to be compiled, but as long 317 as DrawElements/DrawArrays are not compiled it's not clear that it's 318 useful. It's easier to relax the restriction later than to add a new 319 restriction later if deemed necessary, so they are not compiled. 320 321 2) What should be client state and what should be server state? 322 323 RESOLVED: The new enables should be client state as the client needs 324 to know them to determine whether to read from client vertex arrays. 325 For all the other new state, it's not clear that there's any reason 326 to make them client state. Vertex and attrib array formats remain 327 client state. 328 329 3) What about other buffer object uses (PBO, XFB, etc)? 330 331 RESOLVED: Deferred to separate extensions, if deemed necessary. 332 333 4) How should the use of GPU addresses be enabled and how should it 334 interact with classic VBO and client vertex arrays? 335 336 RESOLVED: A single enable for all vertex attribs (both named and 337 generic), and an enable for element array. This precludes mixing with 338 classic VBO and client vertex arrays, which is not particularly 339 desirable in the first place. Requiring implementations to mix with 340 classic VBO may re-introduce a significant amount of the CPU overhead 341 that this extension is intended to remove. 342 343 These enables are not problematic for middleware because the enables 344 are per-VAO and middleware libraries can/should use their own VAOs if 345 they need to avoid polluting the application's state. 346 347 5) Should ArrayElement be supported? 348 349 RESOLVED: YES. ArrayElement updates the current vertex state in the 350 context which is not naturally a "GPU" operation, so this may be 351 inefficient, but we should support it anyway. 352 353 6) Should there be a separate BindBufferAddressNV and 354 BindBufferAddressIndexedNV? 355 356 RESOLVED: NO. There's no particularly strong argument in either 357 direction. 358 359 7) What happens if an invalid address is fetched? 360 361 UNRESOLVED: If <address> and <length> correctly specify a range of a 362 resident buffer object, then the implementation *might* support 363 replacing reads from beyond <address> + <length> with undefined 364 results. However, a genuinely invalid address may cause system errors 365 including program termination. A "debug context" could potentially 366 check on each draw call whether all the address ranges are within 367 a resident buffer object. 368 369 8) Should this be limited to generic vertex attribs? 370 371 RESOLVED: NO. Named attribs are deprecated, and it would make the spec 372 and implementation shorter. But the interactions are clean and easy 373 to specify, and many legacy apps use the named attribs. The answer 374 may have to change to "yes" if this extension is ever promoted. 375 376 9) Should the <indices> parameter to DrawElements and friends be used? 377 378 RESOLVED: YES. This is required for MultiDrawElements to be useful 379 and hence to provide an easy porting path for existing applications. 380 This is unfortunately inconsistent with ignoring the vertex attrib 381 pointer state, but the vertex attrib pointers are "latched" state and 382 <indices> is "immediate" state so they're already semantically 383 different. 384 385 10) Are there alignment requirements on vertex attrib and element 386 array addresses? 387 388 RESOLVED: No more so than with existing VBO functionality. The spec has 389 the following vague language about using VBOs: 390 391 "Clients must align data elements consistent with the requirements 392 of the client platform, with an additional base-level requirement 393 that an offset within a buffer to a datum comprising N basic machine 394 units be a multiple of N." 395 396 However, the consequences of ignoring this advice aren't specified. 397 Since this extension still uses buffer objects, presumably it should 398 inherit the same restrictions. However, if we split out the Format API 399 from the Address API, then it becomes impossible to do an error check 400 to enforce this. But, our implementation has never had such an error 401 check in the first place... 402 403 Follow the quoted advice from the core spec, and this extension adds 404 no new error checks to enforce it. The GL should ensure that the base 405 address of a buffer is at least 16-byte aligned (see issue 16 of 406 NV_shader_buffer_load). 407 408 11) Does MAX_SHADER_BUFFER_ADDRESS_NV imply any restriction on vertex 409 attrib or element array addresses? 410 411 RESOLVED: No, it is only a restriction on shader loads. The entire 412 address space is available for vertex/element fetches. 413 414 12) How does the new vertex state interact with 415 EXT_direct_state_access's ClientAttribDefaultEXT? 416 417 RESOLVED: All the new state is reset to the initial values. 418 419Revision History 420 421 Rev. Date Author Changes 422 ---- -------- -------- ----------------------------------------- 423 1 jbolz Internal revisions. 424 2 06/30/09 jbolz Defined interaction with deprecated 425 client state commands. 426 3 09/09/09 mjk Assigned number + fixed typos 427 4 07/08/15 ckubisch 64-bit Gets for *_LENGTH_NV, interaction with 3.2