-
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
-
Member
Regular Contributor
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?
-
Member
Regular Contributor
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/
-
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
-
Forum Rules