Async PBO Texture upload with Mipmapping

Hello friends! I’m currently use PBO in two different ways: Sync Texture Upload (works very well but it “feezes” the scene) and/or as Async Texture Upload (with “n+1 Frame” method). Now I’ve implemented LOD for textures and I would like to use Async PBO upload either for mipmaps. I’ve already done DDS (DXT1, DXT3, DXT5 compressions) texture’s file import with Alpha and Mipmaps, but at the moment I upload textures just with SYNC method. Async method requires 2 PBO (in “N+1 frame” way) for upload but I can’t create 2 PBO for each texture!! No any example founded surfing the web…Please, someone have an idea how to do this? Thanks!

http://www.songho.ca/opengl/gl_pbo.html

Yes, this was the first page I’ve found two years ago. I’ve already done Async Texture Upload using two PBOs, but all examples I’ve found refers just to one single texture upload at time…but I need many (random number) uploads based on how many 3D models I need to load. Using only two PBOs (for single upload, as explained in your link) I need to wait one upload before go to next one, and this is similar to SYNC mode which I want to avoid to use. Example: consider the need to upload 5 mipmap levels for each 3D model and I’ve got 5 models, in summary I have 5*5=25 textures to upload. With my Async PBO method (using “N+1 frame delay”) I need 2 PBOs for each upload, so I would need 50 simultaneous PBOs!!! Otherwise I can use just two fixed PBOs (same “N+1 frame dalay” method) but I would need to wait each mipmap level upload before go ahead with the next level…and this is not so much ASYNC method…

Instead of using multiple PBOs you can try making use of ‘buffer orphaning’. I.e. use the same PBO over and over again, but before each texture upload use glBufferData() to tell the driver that you’re fine with discarding the data in the PBO (by replacing it with the new texture data) as soon as any dependent texture uploads are finished. This allows the driver to queue up multiple operations on the PBO and still execute them asynchronously.

Thanks for the help! I didn’t know the existence of “buffer orphaning”. If someone need more info I’ve founded this useful link to explain how it works: http://www.opengl.org/wiki/Buffer_Object_Streaming. I’ll try ahead in this way, thanks!