View Full Version : what kind of "wait" will glMapBuffer() do?

08-20-2009, 02:09 AM
when I use a PBO to upload image to a texture, I have to use glMapBuffer() to get a client address to copy the image, and then unmap the PBO and call glTexImage2D() to upload the image to a texture ( by DMA ).
My question is : if I use only one PBO object to do the work, I upload the first image as described before, then I use glMapBuffer() to copy the second image, this will cause openGL driver to wait until the previous upload has finished ( wait util the DMA finished), so what kind of "wait" the driver will do for me ? will it wait on an event and yield CPU resource until DMA finished or it just do a busy loop to query the upload status?

08-20-2009, 02:26 AM
My understanding is that it will "stall" the CPU until the GPU has released the resource.

Why not double buffer your PBOs, or do some kind of texture streaming..

08-20-2009, 05:35 PM
I know I can use two PBO objects to avoid waiting on GPU and make CPU and GPU work in parallel. But I just want to know the fact which kind of 'wait' will it do for me :-)

Thanks for your reply.

BTW, can you make some clarification on your reply, dose cpu "stall" mean waiting on an event?

08-20-2009, 06:51 PM
Yes, "stall" means it will wait (stop) until the GPU is finished with the contested resource.

A cheap way to avoid the "stall" is to bind the buffer to NULL, and then reallocate it. But this simply moves the double buffering to the GPU side.

08-21-2009, 02:26 AM