Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: glBufferStorage without GL_MAP_COHERENT_BIT

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    28

    glBufferStorage syncronization

    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):
    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?
    Last edited by rodrigoloc; 06-02-2014 at 05:59 PM.

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    28

    glSyncFence leak

    I'm currently using this:
    Code :
    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.
    Last edited by rodrigoloc; 06-03-2014 at 08:50 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •