PDA

View Full Version : glBufferStorage without GL_MAP_COHERENT_BIT



rodrigoloc
06-01-2014, 09:06 PM
Hello,
I would like to know how to use glBufferStorage without GL_MAP_COHERENT_BIT flag. If I remember correctly with that flag I don't have to glMemoryBarrier the buffer before reading or writing it. The problem is that I don't know how use glMemoryBarrier with glBufferStorage.
For example (C code):


GLuint nUniformBuffer;
glGenBuffers(1, &nUniformBuffer);
glBindBuffer(GL_UNIFORM_BUFFER, nUniformBuffer);
glBufferStorage(GL_UNIFORM_BUFFER, <buffer size>, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_CLIENT_STORAGE_BIT);
GLvoid *pPointer = glMapBufferRange(GL_UNIFORM_BUFFER, 0, <buffer size>, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
glBindBuffer(GL_UNIFORM_BUFFER, 0);

// Do I have to glMemoryBarrier now?
DoSomethingWith(pPointer);

glDeleteBuffers(1, &nUniformBuffer);


How do I syncronize ARB_buffer_storage?

rodrigoloc
06-02-2014, 06:41 PM
I'm currently using this:


GLsync pSyncFence = NULL;
for each object
{
if (pSyncFence)
{
GLenum nReturnValue = glClientWaitSync(pSyncFence, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
if (GL_WAIT_FAILED == nReturnValue || GL_TIMEOUT_EXPIRED == nReturnValue)
{
// Something went wrong.
}

glDeleteSync(pSyncFence);
pSyncFence = NULL;

DoSomethingWithBufferStorageClientPointer();
glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BIT); // Don't know if right.

BindSomeData();
Draw();

pSyncFence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
}


Syncronization is working right (no strange things happen) but it's leaking memory. Why is this happening?
I'm using Catalyst 14.4 RC with Ubuntu 14.04 x86_64. I haven't tried it on Windows with Catalyst 14.4 (not RC) yet.



Edit:
Fixed. I've changed GL_SYNC_FLUSH_COMMANDS_BIT to GL_NONE (0x00) and no more memory leaks.