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 4 of 4

Thread: How to readback PBO to main memory fast?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2010
    Posts
    12

    How to readback PBO to main memory fast?

    Hi everyone:
    I've created a pixel buffer object(PBO) and modified it with CUDA. Now I want to readback the PBO result to main memory for transfering to other nodes. Is there an efficient method to readback PBO?
    I mapped PBO and copy the contents to an array like this:
    glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
    GLubyte* ptr = (GLubyte*)glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_AR B, GL_READ_ONLY_ARB);
    int count=0;
    for (int i=0 ; i<width; i++)
    {
    for (int j=0 ; j<height; j++)
    {
    cpumem[count] = ptr[count];
    cpumem[count+1] = ptr[count+1];
    cpumem[count+2] = ptr[count+2];
    cpumem[count+3] = ptr[count+3];
    count += 4;
    }
    }
    glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);

    I found the map operation was too heavy. Is there another more efficient method to readback PBO? Thanks

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    513

    Re: How to readback PBO to main memory fast?

    Is the mapping the problem or the actual copying? Why are you copying the individual bytes "by hand" instead of just calling memcpy or something like it?

  3. #3
    Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Czech Republic
    Posts
    318

    Re: How to readback PBO to main memory fast?

    Using aligned memory and special SSE instruction helps a lot. See this: http://williamchan.ca/portfolio/assembly/ssememcpy/

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2010
    Posts
    12

    Re: How to readback PBO to main memory fast?

    Thanks a lot, I will try it.

Posting Permissions

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