VVISF & VVGL
VVGL::GLTexToCPUCopier Class Reference

Downloads texture-based GLBuffers (Type_Tex) to CPU memory. More...

#include <GLTexToCPUCopier.hpp>

Public Member Functions

void clearStream ()
 Clears all the queues, called when freed.
 
void setQueueSize (const int &inNewQueueSize)
 Sets the size of the queue used for streaming. Effectively, this is the number of calls it takes for the texture data to "finish downloading" and get returned as a pointer to non-GPU memory.
 
int queueSize ()
 Returns the size of the queue used for streaming.
 
GLBufferRef downloadTexToCPU (const GLBufferRef &inTexBuffer, const GLBufferRef &inCPUBuffer=nullptr, const bool &createInCurrentContext=false)
 Immediately downloads the passed texture into CPU memory- doesn't use the queues. Less efficient. Good for quick single-shot texture downloads. More...
 
GLBufferRef streamTexToCPU (const GLBufferRef &inTexBuffer, const GLBufferRef &inCPUBuffer=nullptr, const bool &createInCurrentContext=false)
 Begins downloading the passed texture-based buffer to CPU memory, but stashes it in a queue and will return the CPU-based GLBuffer when this function is called again at a later time (ping-pong/double-/triple-/n-buffering). Good for streaming texture download. More...
 
void setPrivatePool (const GLBufferPoolRef &n)
 Sets the receiver's private buffer pool (which should default to null). If non-null, this buffer pool will be used to generate any GL resources required by this scene. Handy if you have a variety of GL contexts that aren't shared and you have to switch between them rapidly on a per-frame basis.
 
GLBufferPoolRef privatePool ()
 Gets the receiver's private buffer pool- null by default, only non-null if something called setPrivatePool().
 

Related Functions

(Note that these are not member functions.)

using GLTexToCPUCopierRef = shared_ptr< GLTexToCPUCopier >
 A GLTexToCPUCopierRef is a shared pointer around a GLTexToCPUCopier.
 
GLTexToCPUCopierRef CreateGLTexToCPUCopierRef ()
 Creates and returns a GLTexToCPUCopier. The scene makes a new GL context which shares the context of the global buffer pool.
 
GLTexToCPUCopierRef CreateGLTexToCPUCopierRefUsing (const GLContextRef &inCtx)
 Creates and returns a GLTexToCPUCopier. The downloader uses the passed GL context to perform its GL operations.
 

Detailed Description

Downloads texture-based GLBuffers (Type_Tex) to CPU memory.

Offers both immediate download and n-buffered texture downloads for double-/triple-/n-buffering/ping-ponging. Uses PBOs for async DMA.

Member Function Documentation

◆ downloadTexToCPU()

GLBufferRef VVGL::GLTexToCPUCopier::downloadTexToCPU ( const GLBufferRef &  inTexBuffer,
const GLBufferRef &  inCPUBuffer = nullptr,
const bool &  createInCurrentContext = false 
)

Immediately downloads the passed texture into CPU memory- doesn't use the queues. Less efficient. Good for quick single-shot texture downloads.

Parameters
inTexBufferThe texture-type GLBuffer that you wish to download to memory. Must not be null.
inCPUBufferMay be null (null by default). If null, this function will return a PBO-type GLBuffer that has been mapped- you can access the pixels at its cpuBackingPtr ivar for analysis, encoding, etc. If you provide a non-null CPU-type GLBuffer for this param, this function will instead return the CPU-type buffer you provided, after populating it with the contents of the texture. This function downloads the texture immediately- it doesn't use the queue/doesn't do any double-/triple-/n-buffering. This function is generally less efficient than streamTexToCPU(), but it's still appropriate if you just want to download a texture immediately and aren't doing any extensive streaming.

◆ streamTexToCPU()

GLBufferRef VVGL::GLTexToCPUCopier::streamTexToCPU ( const GLBufferRef &  inTexBuffer,
const GLBufferRef &  inCPUBuffer = nullptr,
const bool &  createInCurrentContext = false 
)

Begins downloading the passed texture-based buffer to CPU memory, but stashes it in a queue and will return the CPU-based GLBuffer when this function is called again at a later time (ping-pong/double-/triple-/n-buffering). Good for streaming texture download.

Parameters
inTexBufferThis must be a texture-based GLBuffer. This may not be null.
inCPUBufferMay be null (null by default). If null, this function will eventually return a PBO-type GLBuffer that has been mapped for 'inTexBuffer'. You can access the pixels of this mapped PBO at its cpuBackingPtr ivar for analysis, encoding, etc. If you provide a non-null CPU-type GLBuffer for this param, this function will instead eventually return the CPU-type buffer you provided, after populating it with the contents of the texture. This function is more efficient than downloadTexToCPU()- CPU use will probably be lower and execution will return to the calling thread more rapidly, though the queue means that there's more latency (it won't start returning buffers until you submit one or two- depending on the size of the queue).

The documentation for this class was generated from the following files: