4 // Keeps a pool of persistently mapped PBOs around that can be used as staging
5 // buffers for texture uploads. (Uploading from a PBO is asynchronous and done
6 // by the GPU, so assuming we don't need an extra copy into the PBO, this is a
7 // significant win over uploading from regular malloc-ed RAM.)
9 // Unlike Nageru's PBOFrameAllocator, these are not connected to
10 // a given frame, since we can have thousands of frames in the cache
11 // at any given time. Thus, we need to have separate fences for each PBO
12 // to know that the upload is done.
19 #include "shared/ref_counted_gl_sync.h"
23 uint8_t *ptr; // Mapped memory.
24 RefCountedGLsync upload_done;
29 PBOPool(size_t pbo_size = 8 << 20, // 8 MB, large enough for 1080p 4:2:2.
31 GLenum permissions = GL_MAP_WRITE_BIT,
32 GLenum map_bits = GL_MAP_FLUSH_EXPLICIT_BIT);
35 void release_pbo(PBO pbo); // Set a fence on upload_done if the PBO may still be in use.
40 std::mutex freelist_mutex;
41 std::queue<PBO> freelist;
44 GLenum permissions, map_bits;
47 extern PBOPool *global_pbo_pool;
48 void init_pbo_pool(); // Idempotent.
50 #endif // !defined(_PBO_POOL_H)