1Name
2
3    NV_uniform_buffer_unified_memory
4
5Name Strings
6
7    GL_NV_uniform_buffer_unified_memory
8
9Contact
10
11    Markus Tavenrath, NVIDIA Corporation (matavenrath 'at' nvidia.com)
12
13Contributors
14
15    Markus Tavenrath, NVIDIA
16    Christoph Kubisch, NVIDIA
17
18Status
19
20    SHIPPING 
21
22Version
23
24    Last Modified Date: August 28, 2014
25    Revision: 1
26
27Number
28
29    OpenGL Extension #459
30
31Dependencies
32
33    Written based on the wording of the OpenGL 4.4 Specification, Core Profile.
34    
35    This extension interacts with ARB_uniform_buffer_object. 
36    
37    This extension interacts with NV_vertex_buffer_unified_memory. 
38
39    This extension interacts with NV_shader_buffer_load. 
40
41Overview
42
43    This extension provides a mechanism to specify uniform buffers
44    using GPU addresses.
45
46    Binding uniform buffers is one of the most frequent and expensive
47    operations in many GL applications, due to the cost of chasing 
48    pointers and binding objects described in the overview of 
49    NV_shader_buffer_load. The intent of this extension is to enable a 
50    way for the application to specify uniform buffer state that alleviates
51    the overhead of object binds and driver memory management.
52
53New Procedures and Functions
54
55New Tokens
56
57    Accepted by the <cap> parameter of DisableClientState, 
58    EnableClientState, IsEnabled:
59
60        UNIFORM_BUFFER_UNIFIED_NV                      0x936E
61
62    Accepted by the <pname> parameter of BufferAddressRangeNV 
63    and the <value> parameter of GetIntegerui64i_vNV: 
64
65        UNIFORM_BUFFER_ADDRESS_NV                      0x936F
66
67    Accepted by the <target> parameter of GetIntegeri_vNV:    
68
69        UNIFORM_BUFFER_LENGTH_NV                       0x9370
70
71
72Additions to Chapter 7 of the OpenGL 4.4 (Core) Specification (Programs and Shaders)
73
74    Section 7.6.3 Uniform Buffer Object Bindings (p. 132)
75    
76    Add to second paragraph:
77    
78    If UNIFORM_BUFFER_UNIFIED_NV is enabled these bindings are overridden
79    by the bindings specified by the command 
80
81    void BufferAddressRangeNV(enum pname, uint index, uint64EXT address,
82                                   sizeiptr length);
83
84    where <pname> is UNIFORM_BUFFER_ADDRESS_NV and <index> identifies 
85    the uniform buffer binding whose address is being specified. 
86    
87    <address> specifies the GPU address from which arrays will be sourced,
88    and addresses beyond and including (<address> + <length>) will return 
89    undefined values. If the address range of the used uniform buffer
90    does not belong to a buffer object that is resident at the time of 
91    the Draw or Dispatch, undefined results, possibly 
92    including program termination, may occur.
93
94
95Additions to the AGL/EGL/GLX/WGL Specifications
96
97    None.
98
99Errors
100
101    The error INVALID_VALUE is generated by BufferAddressRange if <length>
102    is negative.
103
104    The error INVALID_VALUE is generated by BufferAddressRange if <pname>
105    is UNIFORM_BUFFER_UNIFIED_NV and <index> is equal or greater than
106    MAX_UNIFORM_BUFFER_BINDINGS.
107
108    The error INVALID_VALUE is generated by BufferAddressRange if <address>
109    is not aligned to UNIFORM_BUFFER_OFFSET_ALIGNMENT.
110
111    New State
112
113    Add to Table 23.49  p. 574 (Uniform Buffer Binding State)
114
115    Get Value                            Type    Get Command     Initial Value   Sec     Attribute
116    ---------                            ----    -----------     -------------   ---     ---------
117    UNIFORM_BUFFER_UNIFIED_NV             B      IsEnabled           FALSE       7.6.3   none
118    UNIFORM_BUFFER_ADDRESS_NV      MAX_UBO*Z64+  GetIntegerui64i_vNV   0         7.6.3   none
119    UNIFORM_BUFFER_LENGTH_NV       MAX_UBO*Z+    GetIntegeri_v         0         7.6.3   none
120
121Dependencies on ARB_uniform_buffer_object:
122
123    This extension relies on the availability of uniform buffer objects.
124
125Dependencies on NV_vertex_buffer_unified_memory:
126
127    This extension relies on the mechanisms to provide buffer addresses
128    that NV_vertex_buffer_unified_memory provides, but does not
129    rely on other changes.
130    
131Dependencies on NV_shader_buffer_load:
132
133    This extension relies on the mechanisms to get addresses and make
134    buffers resident that NV_shader_buffer_load provides, but does not
135    rely on either the LOAD instruction or the changes to the Shading 
136    Language.
137
138Examples
139
140    In a bindless driven pipeline, high frequency bindings such
141    as vertex buffers and uniform buffers can now be achieved
142    efficiently.
143    
144    // initialization of UBOs
145    
146    GenBuffers(3, ubos);
147    GLuint64 uboAddrs[3];
148
149    for (i = 0; i < 3; ++i) {
150        BindBuffer(UNIFORM_BUFFER, ubos[i]);
151        BufferStorage(UNIFORM_BUFFER, uboSizes[i], uboData[i], DYNAMIC_STORAGE_BIT);
152    }
153    
154    // example rendering loop
155    // vertex format / attrib binding setup, data transfers...
156    
157    
158    // enable buffer unified memory usage,
159    // which globally overrides all bindings via BufferAddressRange
160    
161    // for this extension
162    EnableClientState(UNIFORM_BUFFER_UNIFIED_NV);
163    // for NV_vertex_buffer_unified_memory
164    EnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV);
165    
166    // unextended: 
167    // BindBufferRange(UNIFORM_BUFFER, 0, ubos[0], 0, sizeof(View));
168        
169    BufferAddressRangeNV(UNIFORM_BUFFER_ADDRESS_NV, 0, uboAddrs[0], sizeof(View));
170    
171    for (object in scene) {
172    
173      if (object.vbo != lastvbo){
174        // unextended: 
175        // BindVertexBuffer(0, object.vbo, 0, sizeof(Vertex));
176        
177        // from NV_vertex_buffer_unified_memory
178        BufferAddressRangeNV(VERTEX_ATTRIB_ARRAY_ADDRESS_NV, 0, object.vboAddr, object.numVertices * sizeof(Vertex));
179      }
180      
181      if (object.material != lastmaterial){
182        // unextended: BindBufferRange(UNIFORM_BUFFER, 1, ubos[1], sizeof(Material) * object.material, sizeof(Material));
183        
184        BufferAddressRangeNV(UNIFORM_BUFFER_ADDRESS_NV, 1, uboAddrs[1] + sizeof(Material) * object.material, sizeof(Material));
185      }
186      
187      if (object.node != lastnode){
188        // unextended: BindBufferRange(UNIFORM_BUFFER, 2, ubos[2], sizeof(Node) * object.node, sizeof(Node));
189        
190        BufferAddressRangeNV(UNIFORM_BUFFER_ADDRESS_NV, 2, uboAddrs[2] + sizeof(Node) * object.node, sizeof(Node));
191      }
192      
193      MultiDrawArrays(..)
194    }
195    
196    
197Issues
198
199
200Revision History
201
202    Rev.    Date    Author      Changes
203    ----  --------  --------    -----------------------------------------
204     1              ckubisch    Internal revisions.
205
206