I'm wondering if it is possible to use a PBO for unpacking (upload to GPU) and then later bind it as packing (download) and vice versa. An example scenario may be
Code :gen buffer bind as unpack buffer allocate space map buffer for write set data in sys mem unmap buffer TexImage2D then later... bind as pack buffer glReadPixels map buffer for read do stuff with data unmap buffer
My reason for asking is that I want to create a pool of PBOs for upload/download to/from the GPU. If a PBO can be used for both, this is fine otherwise I'll need a separate pool for upload and download PBOs. In the example above, I omit all the stuff I would be doing whilst waiting for the DMA transfer etc. I have a few other questions too, as I'm not very experienced with PBOs:
1) Will glMapBuffer block until any current transfer is complete for that PBO ?
2) I read that calling a NULL glBufferData on a PBO will allocate it new memory and cause glMapBuffer to then not block. Will this cancel a previous transfer in the middle of it's progress?
3) My bottom-line question is, "is one certain that PBO transfers will complete?" eg. If a glTexImage2D is reading from a PBO and something then calls glBufferData to re-alloc and then glMapBuffer, can we be certain that glTexImage2D will complete its transfer or will it result in a half-loaded texture. Are there any cases when transfer is not guaranteed?
Thanks very much to anyone can enlighten me