29/01/2009 OpenGL 3.0 map buffer range and OpenGL 3.1 perspectives

Introduced by the GL_APPLE_vertex_array_range extension, OpenGL 3.0 introduces a very interesting feature called "mapped buffer range". It can lead to performance improvement and some software design changes.

OpenGL 1.5 included the concept of "buffer" from GL_ARB_vertex_buffer_object and a way to access to the buffer memory with glMapBuffer function. It leads to the possibility to load a buffer directly using the graphics driver memory with skip one buffer copy so that people were expected some speed up.

However, the results were no really convincing because even if a copy is skipped, the bottleneck isn't really in the copy but in the memory bandwise. By anyway the driver memory needs to be transfer to the graphics card which basically means that whether we use glMapBuffer or glBufferSubData, data are sent to the GPU memory when the software have finished to edit the whole buffer. This implies a serialization of the CPU and GPU works but to reach 100% efficiency we want the CPU and the GPU in parallel.

One solution used by a lot of graphics programmers is to limit the size of buffers. The idea is: Step 1: edit a buffer on CPU; Step 2: send the first buffer and edit a second buffer during this time. By this way, we introduce asynchrony work in our solution. A good side effect of buffer size limitation is the ability to use 16 bits element buffers.

A new solution is mapped buffer range. The idea is to edit a range of data instead of the whole buffer. This is now possible thanks to glMapBufferRange function of OpenGL 3.0. It doesn't really deprecate buffer size limitation because of advantages like 16 bits element buffers but it increases the modification granularity.

Direct3D 10 changed the balanced cost of the API so that all the checking is done an object creation and not during the rendering. One of these aspects was the creation of the common buffer which does something like grouping the uniform variables in one or several buffer object. This concept has been added to OpenGL through GL_EXT_bindable_uniform extension="" and uniform buffers which is expected to be improved and to become part of OpenGL 3.1 core.

A good use of these common/uniform buffers can imply some good performance improvements simply because in most shader oriented softwares, glUniform* called numbers is more than 50% of the overall function calls … However, common and uniform buffers need to be updated carefully because usually when updated, the whole buffer need to be send to the graphics card memory. A solution is to group the uniform data, per pass, per program, per object, etc. Mapped buffer ranged provides the ultimate solution because of the fine granularity it allows. A single variable can be updated; all per pass data (eg) can be changed and only then, they and only they will be sent.

For me, there is no doubt for me that this feature is going to be really useful in the feature and will find a lot of application beyond what I have just commented.

State of OpenGL 3.0 drivers >
< GPU base
Copyright © Christophe Riccio 2002-2016 all rights reserved
Designed for Chrome 9, Firefox 4, Opera 11 and Safari 5