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?
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…
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?
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.