[osg-users] OpenGL 4.4 and ARB_buffer_storage

Trajce Nikolov NICK trajce.nikolov.nick at gmail.com
Tue Nov 5 09:11:30 PST 2019


Hi Community,

I am trying to implement 4.4 Persistent Mapping Streaming, within the
context  of OSG. Bellow is from the spec. I am struggling at the moment
with making the buffer object sections, with the current OSG implementation
and not sure if it is possible so I am asking here for hints if any of you
have done something similar. Thanks a bunch as always!

Persistent mapped streaming

Given the availability of OpenGL 4.4 or ARB_buffer_storage
<http://www.opengl.org/registry/specs/ARB/buffer_storage.txt>, the use of
persistent mapping of buffers becomes a possibility.

The idea here is to allocate an immutable buffer 2-3x the size you need,
and while you're executing operations from one region of the buffer while
you are writing to a different region. The difference between the prior
mapping scheme is that you are not frequently mapping and unmapping the
buffer. You map it persistently when you create the buffer, and keep it
mapped until it's time to delete the buffer.

This requires using glBufferStorage
<https://www.khronos.org/opengl/wiki/GLAPI/glBufferStorage> with the
GL_MAP_WRITE and GL_PERSISTENT_BITs. It also requires using glMapBufferRange
<https://www.khronos.org/opengl/wiki/GLAPI/glMapBufferRange> with those
same bits when mapping it.

The general algorithm is as follows. The buffer is logically divided into 3
sections: the section you're writing to, and two sections that could
currently be in use.

The first step is to write to section 1 of the buffer. Once you have
finished writing, you must make this range of data visible to OpenGL by
flushing it (if you aren't mapping coherently). Then, you do whatever you
need to in order to ensure that this data is visible to OpenGL
<https://www.khronos.org/opengl/wiki/Buffer_Object_Streaming#Persistent_visibility>.
Once the data is visible, you issue some number of Rendering Commands
<https://www.khronos.org/opengl/wiki/Rendering_Command> that read from that
section of the buffer. After issuing all of the commands that read from the
buffer, you create a fence sync object
<https://www.khronos.org/opengl/wiki/Sync_Object>.

Next frame, you start writing to buffer section 2. You do all of the above,
and create a new fence sync object. Keep each buffer section's sync objects
separate.

You do the same with buffer section 3 on the next frame.

On the fourth frame, you want to start using section 1 again. However, you
need to check section 1's sync object to see if it has completed *before* you
can start. You can only start writing to a section if that section's sync
object has completed.

-- 
trajce nikolov nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20191105/3d587ef9/attachment.html>


More information about the osg-users mailing list