Vuo  2.1.0
Classes | Macros | Typedefs | Functions | Variables
VuoGlPool.cc File Reference

Description

VuoGlPool implementation.

Definition in file VuoGlPool.cc.

Go to the source code of this file.

Classes

class  VuoGlTextureDescriptor
 An entry in the GL Texture pool. More...
 
struct  VuoGlTexture
 Reference-counting information for an OpenGL texture. More...
 
struct  VuoIoSurfacePoolEntryType
 An entry in the IOSurface pool. More...
 

Macros

#define RETURN_STRING_IF_EQUAL(value)   if (constant == value) return strdup(#value)
 Helper for VuoGl_stringForConstant. More...
 

Typedefs

typedef map< GLuint, unsigned int > VuoGlPoolReferenceCounts
 The number of times each OpenGL Buffer Object is retained. More...
 
typedef pair< queue< GLuint >, double > VuoGlTextureLastUsed
 A queue of textures of a given format and size, including the last time any of the textures were used. More...
 
typedef map< VuoGlTextureDescriptor, VuoGlTextureLastUsedVuoGlTexturePoolType
 Type for VuoGlTexturePool. More...
 
typedef map< GLuint, VuoGlTextureVuoGlTextureReferenceCounts
 The number of times each glTextureName is retained.. More...
 
typedef pair< unsigned short, unsigned short > VuoGlTextureDimensionsType
 Texture width and height. More...
 
typedef map< VuoGlTextureDimensionsType, deque< VuoIoSurfacePoolEntryType > > VuoIoSurfacePoolType
 VuoIoSurfacePoolType[size] gives a list of IOSurfaces. More...
 
typedef pair< GLuint, pair< GLuint, pair< GLuint, pair< VuoMesh_ElementAssemblyMethod, unsigned int > > > > VuoGlProgramDescriptorType
 An entry in the GL Program pool: vertexShaderName, geometryShaderName, fragmentShaderName, assemblyMethod, expectedOutputPrimitiveCount. More...
 
typedef map< VuoGlProgramDescriptorType, VuoGlProgramVuoGlProgramPoolType
 Type for VuoGlProgramPool. More...
 
typedef std::map< long, GLuint > VuoGlUniformMap
 A quick way to look up a uniform location given a hash of its name. More...
 

Functions

GLuint VuoGlPool_use (VuoGlContext glContext, VuoGlPoolType type, unsigned long size)
 Returns an OpenGL Buffer Object of type type. More...
 
void VuoGlPool_disuse (VuoGlPoolType type, unsigned long size, GLuint name)
 Indicates that the caller is done using the OpenGL object name of type type. More...
 
void VuoGlPool_retainF (GLuint glBufferName, const char *file, unsigned int linenumber, const char *func)
 Helper for VuoGlPool_retain. More...
 
void VuoGlPool_releaseF (VuoGlPoolType type, unsigned long size, GLuint glBufferName, const char *file, unsigned int linenumber, const char *func)
 Helper for VuoGlPool_release. More...
 
GLuint VuoGlTexture_getType (GLuint format)
 Returns the OpenGL texture data type corresponding with OpenGL texture format. More...
 
unsigned char VuoGlTexture_getChannelCount (GLuint format)
 Returns the number of color+alpha channels in the specified OpenGL texture format. More...
 
unsigned char VuoGlTexture_getBytesPerPixel (GLuint internalformat, GLuint format)
 Returns the number of bytes required to store each pixel of the specified OpenGL texture format. More...
 
unsigned char VuoGlTexture_getBytesPerPixelForInternalFormat (GLuint internalformat)
 Returns the number of bytes required to store each pixel of the specified OpenGL texture format. More...
 
bool VuoGlTexture_formatHasAlphaChannel (GLuint format)
 Returns true if the specified OpenGL texture format has an alpha channel. More...
 
unsigned long VuoGlTexture_getMaximumTextureBytes (VuoGlContext glContext)
 Returns the maximum number of bytes in Video RAM that a texture can occupy. More...
 
GLint VuoGlTexture_getMaximumTextureDimension (VuoGlContext glContext)
 Returns the maximum dimension (in pixels) a texture can have. More...
 
static const char * VuoGlTexturePool_stringForAllocation (VuoGlTexturePoolAllocation allocation)
 Returns a summary of allocation. More...
 
GLuint VuoGlTexturePool_use (VuoGlContext glContext, VuoGlTexturePoolAllocation allocation, GLenum target, GLenum internalformat, unsigned short width, unsigned short height, GLenum format, void *ioSurfaceRef)
 Returns an OpenGL texture. More...
 
void VuoGlTexturePool_disuse (VuoGlTexturePoolAllocation allocation, GLenum target, GLenum internalformat, unsigned short width, unsigned short height, GLuint name)
 Indicates that the caller is done using the OpenGL texture name. More...
 
void VuoGlTexture_retain (GLuint glTextureName, VuoImage_freeCallback freeCallback, void *freeCallbackContext)
 Increments the reference count for glTextureName. More...
 
void VuoGlTexture_release (VuoGlTexturePoolAllocation allocation, GLuint glTextureTarget, GLenum internalformat, unsigned short width, unsigned short height, GLuint glTextureName)
 Decrements the reference count for glTextureName. More...
 
void VuoGlTexture_disown (GLuint glTextureName)
 Removes glTextureName from Vuo's reference count table (without deleting it like VuoGlTexture_release does). More...
 
void VuoGlPool_logVRAMAllocated (unsigned long bytesAllocated)
 Updates the process-wide VRAM count to include bytesAllocated. More...
 
void VuoGlPool_logVRAMFreed (unsigned long bytesFreed)
 Updates the process-wide VRAM count to no longer include bytesAllocated. More...
 
static void VuoGlPool_cleanup (void *blah)
 Periodically cleans up the texture and IOSurface pools. More...
 
VuoIoSurface VuoIoSurfacePool_use (VuoGlContext glContext, unsigned short pixelsWide, unsigned short pixelsHigh, GLuint *outputTexture)
 Returns an IOSurface (backed by outputTexture) with the specified dimensions. More...
 
uint32_t VuoIoSurfacePool_getId (VuoIoSurface vis)
 Returns the IOSurface's interprocess ID. More...
 
void * VuoIoSurfacePool_getIOSurfaceRef (VuoIoSurface vis)
 Returns the IOSurface. More...
 
unsigned short VuoIoSurfacePool_getWidth (VuoIoSurface vis)
 Returns the IOSurface's width in pixels. More...
 
unsigned short VuoIoSurfacePool_getHeight (VuoIoSurface vis)
 Returns the IOSurface's height in pixels. More...
 
GLuint VuoIoSurfacePool_getTexture (VuoIoSurface vis)
 Returns the IOSurface's OpenGL texture name. More...
 
void VuoIoSurfacePool_disuse (VuoIoSurface vis, bool quarantine)
 Called by the sending end of an IOSurface texture transfer to indicate that it is finished using the IOSurface's texture. More...
 
void VuoIoSurfacePool_signal (void *ios)
 Called by the receiving end of an IOSurface texture transfer to indicate that it is finished using the IOSurface's texture. More...
 
void VuoGlShader_parseShaderInfoLog (CGLContextObj cgl_ctx, GLenum type, GLuint obj, const GLchar *source, VuoShaderFile::Stage stage, VuoShaderIssues *outIssues)
 Parses GLSL debug information into outIssues. More...
 
static bool VuoGlShader_resolveIncludes (string &source, VuoShaderFile::Stage stage, VuoShaderIssues *outIssues)
 Replaces #include statements with their contents. More...
 
GLuint VuoGlShader_use (VuoGlContext glContext, GLenum type, const char *source, void *outIssues)
 Returns an OpenGL Shader Object representing the specified source, or 0 if the shader couldn't be compiled. More...
 
VuoGlProgram VuoGlProgram_use (VuoGlContext glContext, const char *description, GLuint vertexShaderName, GLuint geometryShaderName, GLuint fragmentShaderName, VuoMesh_ElementAssemblyMethod assemblyMethod, unsigned int expectedOutputPrimitiveCount, void *outIssues)
 Links shaders together into a program (or finds an existing program if one already exists for the given shaders, element assembly method, and output primitive count), and returns the GL Program Object. More...
 
int VuoGlProgram_getUniformLocation (VuoGlProgram program, const char *uniformIdentifier)
 Returns the location (suitable for use with glUniform*()) for a given uniform identifier, or -1 if the uniform isn't found. More...
 
char * VuoGl_stringForConstant (GLenum constant)
 Returns a string for the specified OpenGL constant. More...
 

Variables

static dispatch_semaphore_t VuoGlPool_semaphore
 Serializes access to VuoGlPool. More...
 
static dispatch_semaphore_t VuoGlPool_referenceCountsSemaphore = NULL
 Synchronizes access to VuoGlPool_referenceCounts. More...
 
static VuoGlTexturePoolTypeVuoGlTexturePool
 A pool of GL Textures. More...
 
static dispatch_semaphore_t VuoGlTexturePool_semaphore
 Serializes access to VuoGlTexturePool. More...
 
static VuoGlTextureReferenceCountsVuoGlTexture_referenceCounts
 The reference count for each OpenGL Texture Object. More...
 
static dispatch_semaphore_t VuoGlTexture_referenceCountsSemaphore = NULL
 Synchronizes access to VuoGlTexture_referenceCounts. More...
 
static VuoIoSurfacePoolTypeVuoIoSurfacePool
 Unused IOSurfaces. More...
 
static VuoIoSurfacePoolTypeVuoIoSurfaceQuarantine
 IOSurfaces which might still be in use by the receiver. More...
 
static dispatch_semaphore_t VuoIoSurfacePool_semaphore
 Serializes access to the IOSurface pool. More...
 
static CFStringRef receiverFinishedWithIoSurfaceKey = CFSTR("VuoReceiverFinished")
 Signals from the receiver to the sender, when the receiver is finished using the IOSurface. More...
 
const double VuoGlPool_cleanupInterval = 0.1
 Interval (in seconds) to flush the texture and IOSurface pools. More...
 
static dispatch_source_t VuoGlPool_timer
 Periodically cleans up the IOSurface pool. More...
 
static dispatch_semaphore_t VuoGlPool_canceledAndCompleted
 Signals when the final cleanup has completed. More...
 
static unsigned long VuoGlPool_allocatedBytes = 0
 The approximate current amount of VRAM allocated by this process. More...
 
static unsigned long VuoGlPool_allocatedBytesMax = 0
 The approximate maximum amount of VRAM allocated by this process. More...
 
dispatch_semaphore_t VuoGlShaderPool_semaphore = NULL
 Synchronizes access to VuoGlShaderPool. More...
 
static const std::locale VuoGlPool_locale
 For hashing strings. More...
 
static const std::collate< char > & VuoGlPool_collate = std::use_facet<std::collate<char> >(VuoGlPool_locale)
 For hashing strings. More...
 
static VuoGlProgramPoolType VuoGlProgramPool
 All the GL Programs. More...
 
static dispatch_semaphore_t VuoGlProgramPool_semaphore
 Serializes access to VuoGlProgramPool. More...
 

Class Documentation

◆ VuoGlTexture

struct VuoGlTexture
Class Members
VuoImage_freeCallback freeCallback
void * freeCallbackContext
unsigned int referenceCount

◆ VuoIoSurfacePoolEntryType

struct VuoIoSurfacePoolEntryType
Class Members
IOSurfaceRef ioSurface
double lastUsedTime
unsigned short pixelsHigh
unsigned short pixelsWide
GLuint texture

Macro Definition Documentation

◆ RETURN_STRING_IF_EQUAL

#define RETURN_STRING_IF_EQUAL (   value)    if (constant == value) return strdup(#value)

Helper for VuoGl_stringForConstant.

Definition at line 1598 of file VuoGlPool.cc.

Typedef Documentation

◆ VuoGlPoolReferenceCounts

typedef map<GLuint, unsigned int> VuoGlPoolReferenceCounts

The number of times each OpenGL Buffer Object is retained.

Definition at line 109 of file VuoGlPool.cc.

◆ VuoGlProgramDescriptorType

typedef pair<GLuint, pair<GLuint, pair<GLuint, pair<VuoMesh_ElementAssemblyMethod, unsigned int> > > > VuoGlProgramDescriptorType

An entry in the GL Program pool: vertexShaderName, geometryShaderName, fragmentShaderName, assemblyMethod, expectedOutputPrimitiveCount.

Definition at line 1394 of file VuoGlPool.cc.

◆ VuoGlProgramPoolType

Type for VuoGlProgramPool.

Definition at line 1395 of file VuoGlPool.cc.

◆ VuoGlTextureDimensionsType

typedef pair<unsigned short,unsigned short> VuoGlTextureDimensionsType

Texture width and height.

Definition at line 751 of file VuoGlPool.cc.

◆ VuoGlTextureLastUsed

typedef pair<queue<GLuint>,double> VuoGlTextureLastUsed

A queue of textures of a given format and size, including the last time any of the textures were used.

Definition at line 210 of file VuoGlPool.cc.

◆ VuoGlTexturePoolType

Type for VuoGlTexturePool.

Definition at line 211 of file VuoGlPool.cc.

◆ VuoGlTextureReferenceCounts

The number of times each glTextureName is retained..

Definition at line 630 of file VuoGlPool.cc.

◆ VuoGlUniformMap

typedef std::map<long, GLuint> VuoGlUniformMap

A quick way to look up a uniform location given a hash of its name.

Definition at line 1403 of file VuoGlPool.cc.

◆ VuoIoSurfacePoolType

VuoIoSurfacePoolType[size] gives a list of IOSurfaces.

Definition at line 752 of file VuoGlPool.cc.

Function Documentation

◆ VuoGl_stringForConstant()

char* VuoGl_stringForConstant ( GLenum  constant)

Returns a string for the specified OpenGL constant.

The caller is responsible for freeing the string returned by this function.

Definition at line 1605 of file VuoGlPool.cc.

◆ VuoGlPool_cleanup()

static void VuoGlPool_cleanup ( void *  blah)
static

Periodically cleans up the texture and IOSurface pools.

Definition at line 804 of file VuoGlPool.cc.

◆ VuoGlPool_disuse()

void VuoGlPool_disuse ( VuoGlPoolType  type,
unsigned long  size,
GLuint  name 
)

Indicates that the caller is done using the OpenGL object name of type type.

The object is returned to the pool, so other callers can use it (which is more efficient than deleting and re-generating objects).

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

Definition at line 97 of file VuoGlPool.cc.

◆ VuoGlPool_logVRAMAllocated()

void VuoGlPool_logVRAMAllocated ( unsigned long  bytesAllocated)

Updates the process-wide VRAM count to include bytesAllocated.

This function is automatically called by other VuoGlPool functions, so you should only call this if you're directly making OpenGL calls that allocate VRAM.

This function may be called from any thread.

Changed in Vuo 2.0.0:
New.

Definition at line 774 of file VuoGlPool.cc.

◆ VuoGlPool_logVRAMFreed()

void VuoGlPool_logVRAMFreed ( unsigned long  bytesFreed)

Updates the process-wide VRAM count to no longer include bytesAllocated.

This function is automatically called by other VuoGlPool functions, so you should only call this if you're directly making OpenGL calls that deallocate VRAM.

This function may be called from any thread.

Changed in Vuo 2.0.0:
New.

Definition at line 795 of file VuoGlPool.cc.

◆ VuoGlPool_releaseF()

void VuoGlPool_releaseF ( VuoGlPoolType  type,
unsigned long  size,
GLuint  glBufferName,
const char *  file,
unsigned int  linenumber,
const char *  func 
)

Helper for VuoGlPool_release.

Definition at line 140 of file VuoGlPool.cc.

◆ VuoGlPool_retainF()

void VuoGlPool_retainF ( GLuint  glBufferName,
const char *  file,
unsigned int  linenumber,
const char *  func 
)

Helper for VuoGlPool_retain.

Definition at line 120 of file VuoGlPool.cc.

◆ VuoGlPool_use()

GLuint VuoGlPool_use ( VuoGlContext  glContext,
VuoGlPoolType  type,
unsigned long  size 
)

Returns an OpenGL Buffer Object of type type.

If an existing, unused buffer of the specified type and size is available, it is returned. Otherwise, a new buffer is created.

The returned buffer's storage is will be preallocated (so the caller can efficiently upload data using glBufferSubData).

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

Definition at line 54 of file VuoGlPool.cc.

◆ VuoGlProgram_getUniformLocation()

int VuoGlProgram_getUniformLocation ( VuoGlProgram  program,
const char *  uniformIdentifier 
)

Returns the location (suitable for use with glUniform*()) for a given uniform identifier, or -1 if the uniform isn't found.

Definition at line 1584 of file VuoGlPool.cc.

◆ VuoGlProgram_use()

VuoGlProgram VuoGlProgram_use ( VuoGlContext  glContext,
const char *  description,
GLuint  vertexShaderName,
GLuint  geometryShaderName,
GLuint  fragmentShaderName,
VuoMesh_ElementAssemblyMethod  assemblyMethod,
unsigned int  expectedOutputPrimitiveCount,
void *  outIssues 
)

Links shaders together into a program (or finds an existing program if one already exists for the given shaders, element assembly method, and output primitive count), and returns the GL Program Object.

vertexShaderName must be nonzero, but it's OK for geometryShaderName and/or fragmentShaderName to be 0 (same rules as VuoShader_addSource).

description is used just to print errors/warnings; it is not used for cache matching.

Do not call glDeleteShaders() on the returned program; it's expected to persist throughout the lifetime of the process.

If outIssues is non-NULL, it is expected to be a VuoShaderIssues instance, and compilation warnings/errors will be added to it. In this case, the cache is not used.

Changed in Vuo 2.0.0:
Added outIssues argument.

Definition at line 1422 of file VuoGlPool.cc.

◆ VuoGlShader_parseShaderInfoLog()

void VuoGlShader_parseShaderInfoLog ( CGLContextObj  cgl_ctx,
GLenum  type,
GLuint  obj,
const GLchar *  source,
VuoShaderFile::Stage  stage,
VuoShaderIssues outIssues 
)

Parses GLSL debug information into outIssues.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

Definition at line 1145 of file VuoGlPool.cc.

◆ VuoGlShader_resolveIncludes()

static bool VuoGlShader_resolveIncludes ( string &  source,
VuoShaderFile::Stage  stage,
VuoShaderIssues outIssues 
)
static

Replaces #include statements with their contents.

Returns true if successful.

Definition at line 1207 of file VuoGlPool.cc.

◆ VuoGlShader_use()

GLuint VuoGlShader_use ( VuoGlContext  glContext,
GLenum  type,
const char *  source,
void *  outIssues 
)

Returns an OpenGL Shader Object representing the specified source, or 0 if the shader couldn't be compiled.

To improve performance, this function keeps a cache of precompiled shaders. If a precompiled shader exists for the specified source, that shader is returned. Otherwise, source is passed off to OpenGL to be compiled.

Do not call glDeleteShaders() on the returned shader; it's expected to persist throughout the lifetime of the process.

If outIssues is non-NULL, it is expected to be a VuoShaderIssues instance, and compilation warnings/errors will be added to it. In this case, the cache is not used.

Changed in Vuo 2.0.0:
Added outIssues argument.

Definition at line 1336 of file VuoGlPool.cc.

◆ VuoGlTexture_disown()

void VuoGlTexture_disown ( GLuint  glTextureName)

Removes glTextureName from Vuo's reference count table (without deleting it like VuoGlTexture_release does).

glTextureName must have a reference count of exactly 1 (i.e., a texture being used in multiple places throughout Vuo cannot be disowned).

After Vuo disowns the texture, the caller is responsible for eventually deleting it.

This function may be called from any thread.

Definition at line 715 of file VuoGlPool.cc.

◆ VuoGlTexture_formatHasAlphaChannel()

bool VuoGlTexture_formatHasAlphaChannel ( GLuint  format)

Returns true if the specified OpenGL texture format has an alpha channel.

Changed in Vuo 2.0.0:
New.

Definition at line 361 of file VuoGlPool.cc.

◆ VuoGlTexture_getBytesPerPixel()

unsigned char VuoGlTexture_getBytesPerPixel ( GLuint  internalformat,
GLuint  format 
)

Returns the number of bytes required to store each pixel of the specified OpenGL texture format.

Definition at line 282 of file VuoGlPool.cc.

◆ VuoGlTexture_getBytesPerPixelForInternalFormat()

unsigned char VuoGlTexture_getBytesPerPixelForInternalFormat ( GLuint  internalformat)

Returns the number of bytes required to store each pixel of the specified OpenGL texture format.

Changed in Vuo 2.0.0:
New.

Definition at line 318 of file VuoGlPool.cc.

◆ VuoGlTexture_getChannelCount()

unsigned char VuoGlTexture_getChannelCount ( GLuint  format)

Returns the number of color+alpha channels in the specified OpenGL texture format.

Definition at line 247 of file VuoGlPool.cc.

◆ VuoGlTexture_getMaximumTextureBytes()

unsigned long VuoGlTexture_getMaximumTextureBytes ( VuoGlContext  glContext)

Returns the maximum number of bytes in Video RAM that a texture can occupy.

Definition at line 381 of file VuoGlPool.cc.

◆ VuoGlTexture_getMaximumTextureDimension()

GLint VuoGlTexture_getMaximumTextureDimension ( VuoGlContext  glContext)

Returns the maximum dimension (in pixels) a texture can have.

Definition at line 428 of file VuoGlPool.cc.

◆ VuoGlTexture_getType()

GLuint VuoGlTexture_getType ( GLuint  format)

Returns the OpenGL texture data type corresponding with OpenGL texture format.

Definition at line 219 of file VuoGlPool.cc.

◆ VuoGlTexture_release()

void VuoGlTexture_release ( VuoGlTexturePoolAllocation  allocation,
GLuint  glTextureTarget,
GLenum  internalformat,
unsigned short  width,
unsigned short  height,
GLuint  glTextureName 
)

Decrements the reference count for glTextureName.

This function may be called from any thread.

Changed in Vuo 2.0.0:
Added allocation argument; reordered glTextureTarget argument.

Definition at line 670 of file VuoGlPool.cc.

◆ VuoGlTexture_retain()

void VuoGlTexture_retain ( GLuint  glTextureName,
VuoImage_freeCallback  freeCallback,
void *  freeCallbackContext 
)

Increments the reference count for glTextureName.

This function may be called from any thread.

Definition at line 647 of file VuoGlPool.cc.

◆ VuoGlTexturePool_disuse()

void VuoGlTexturePool_disuse ( VuoGlTexturePoolAllocation  allocation,
GLenum  target,
GLenum  internalformat,
unsigned short  width,
unsigned short  height,
GLuint  name 
)

Indicates that the caller is done using the OpenGL texture name.

The texture is returned to the pool, so other callers can use it (which is more efficient than deleting and re-generating textures).

Typically you should use VuoGlTexture_retain and VuoGlTexture_retain instead.

This function may be called from any thread.

Definition at line 583 of file VuoGlPool.cc.

◆ VuoGlTexturePool_stringForAllocation()

static const char* VuoGlTexturePool_stringForAllocation ( VuoGlTexturePoolAllocation  allocation)
static

Returns a summary of allocation.

Definition at line 444 of file VuoGlPool.cc.

◆ VuoGlTexturePool_use()

GLuint VuoGlTexturePool_use ( VuoGlContext  glContext,
VuoGlTexturePoolAllocation  allocation,
GLenum  target,
GLenum  internalformat,
unsigned short  width,
unsigned short  height,
GLenum  format,
void *  ioSurfaceRef 
)

Returns an OpenGL texture.

If an existing, unused texture matching the specified target, internalformat, width, and height is available, it is returned. Otherwise, a new texture is created.

The texturing properties are set to the defaults:

  • wrapping: clamp to border
  • filtering: linear

See glTexImage2D for information about internalformat and format.

If allocation is VuoGlTexturePool_Allocate, the returned texture's storage is preallocated (so the caller can efficiently upload data using glTexSubImage2D). If VuoGlTexturePool_AllocateIOSurface, the returned texture is backed by the specified ioSurfaceRef. In any case, this function calls VuoGlPool_logVRAMAllocated, so you doesn't need to.

ioSurfaceRef should be NULL unless allocation is VuoGlTexturePool_AllocateIOSurface.

Returns 0 if the texture would be too large to fit in Video RAM.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

Changed in Vuo 2.0.0:
Added allocation, target, ioSurfaceRef arguments.

Definition at line 476 of file VuoGlPool.cc.

◆ VuoIoSurfacePool_disuse()

void VuoIoSurfacePool_disuse ( VuoIoSurface  vis,
bool  quarantine 
)

Called by the sending end of an IOSurface texture transfer to indicate that it is finished using the IOSurface's texture.

This enables the IOSurface to be reused for another texture transfer (once the receiving end indicates it is done with it, via VuoIoSurfacePool_signal()).

quarantine should typically be true — this indicates that the IOSurface should be placed in the quarantine, meaning that it will not be reused until the receiver signals it. If you're sure both sides are immediately finished using the IOSurface (e.g., during texture transfer within a process), you can set quarantine to false, which will allow reusing it sooner (saving some VRAM). You still need to call VuoIoSurfacePool_signal though (since the IOSurface might be recycled and later require quarantine).

Changed in Vuo 2.0.0:
Added quarantine argument.

Definition at line 1109 of file VuoGlPool.cc.

◆ VuoIoSurfacePool_getHeight()

unsigned short VuoIoSurfacePool_getHeight ( VuoIoSurface  vis)

Returns the IOSurface's height in pixels.

Definition at line 1082 of file VuoGlPool.cc.

◆ VuoIoSurfacePool_getId()

uint32_t VuoIoSurfacePool_getId ( VuoIoSurface  vis)

Returns the IOSurface's interprocess ID.

Definition at line 1055 of file VuoGlPool.cc.

◆ VuoIoSurfacePool_getIOSurfaceRef()

void* VuoIoSurfacePool_getIOSurfaceRef ( VuoIoSurface  vis)

Returns the IOSurface.

Definition at line 1064 of file VuoGlPool.cc.

◆ VuoIoSurfacePool_getTexture()

GLuint VuoIoSurfacePool_getTexture ( VuoIoSurface  vis)

Returns the IOSurface's OpenGL texture name.

Definition at line 1091 of file VuoGlPool.cc.

◆ VuoIoSurfacePool_getWidth()

unsigned short VuoIoSurfacePool_getWidth ( VuoIoSurface  vis)

Returns the IOSurface's width in pixels.

Definition at line 1073 of file VuoGlPool.cc.

◆ VuoIoSurfacePool_signal()

void VuoIoSurfacePool_signal ( void *  ios)

Called by the receiving end of an IOSurface texture transfer to indicate that it is finished using the IOSurface's texture.

This enables the sender to reuse the IOSurface for another texture transfer.

Definition at line 1132 of file VuoGlPool.cc.

◆ VuoIoSurfacePool_use()

VuoIoSurface VuoIoSurfacePool_use ( VuoGlContext  glContext,
unsigned short  pixelsWide,
unsigned short  pixelsHigh,
GLuint *  outputTexture 
)

Returns an IOSurface (backed by outputTexture) with the specified dimensions.

Uses an IOSurface from the pool, if possible. If not, creates a new IOSurface.

Definition at line 991 of file VuoGlPool.cc.

Variable Documentation

◆ receiverFinishedWithIoSurfaceKey

CFStringRef receiverFinishedWithIoSurfaceKey = CFSTR("VuoReceiverFinished")
static

Signals from the receiver to the sender, when the receiver is finished using the IOSurface.

Definition at line 756 of file VuoGlPool.cc.

◆ VuoGlPool_allocatedBytes

unsigned long VuoGlPool_allocatedBytes = 0
static

The approximate current amount of VRAM allocated by this process.

See also
VuoGlPool_logVRAMAllocation

Definition at line 762 of file VuoGlPool.cc.

◆ VuoGlPool_allocatedBytesMax

unsigned long VuoGlPool_allocatedBytesMax = 0
static

The approximate maximum amount of VRAM allocated by this process.

See also
VuoGlPool_logVRAMAllocation

Definition at line 763 of file VuoGlPool.cc.

◆ VuoGlPool_canceledAndCompleted

dispatch_semaphore_t VuoGlPool_canceledAndCompleted
static

Signals when the final cleanup has completed.

Definition at line 760 of file VuoGlPool.cc.

◆ VuoGlPool_cleanupInterval

const double VuoGlPool_cleanupInterval = 0.1

Interval (in seconds) to flush the texture and IOSurface pools.

Definition at line 758 of file VuoGlPool.cc.

◆ VuoGlPool_collate

const std::collate<char>& VuoGlPool_collate = std::use_facet<std::collate<char> >(VuoGlPool_locale)
static

For hashing strings.

Definition at line 1317 of file VuoGlPool.cc.

◆ VuoGlPool_locale

const std::locale VuoGlPool_locale
static

For hashing strings.

Definition at line 1316 of file VuoGlPool.cc.

◆ VuoGlPool_referenceCountsSemaphore

dispatch_semaphore_t VuoGlPool_referenceCountsSemaphore = NULL
static

Synchronizes access to VuoGlPool_referenceCounts.

Definition at line 111 of file VuoGlPool.cc.

◆ VuoGlPool_semaphore

dispatch_semaphore_t VuoGlPool_semaphore
static

Serializes access to VuoGlPool.

Definition at line 42 of file VuoGlPool.cc.

◆ VuoGlPool_timer

dispatch_source_t VuoGlPool_timer
static

Periodically cleans up the IOSurface pool.

Definition at line 759 of file VuoGlPool.cc.

◆ VuoGlProgramPool

VuoGlProgramPoolType VuoGlProgramPool
static

All the GL Programs.

Definition at line 1396 of file VuoGlPool.cc.

◆ VuoGlProgramPool_semaphore

dispatch_semaphore_t VuoGlProgramPool_semaphore
static

Serializes access to VuoGlProgramPool.

Definition at line 1397 of file VuoGlPool.cc.

◆ VuoGlShaderPool_semaphore

dispatch_semaphore_t VuoGlShaderPool_semaphore = NULL

Synchronizes access to VuoGlShaderPool.

Definition at line 1192 of file VuoGlPool.cc.

◆ VuoGlTexture_referenceCounts

VuoGlTextureReferenceCounts* VuoGlTexture_referenceCounts
static

The reference count for each OpenGL Texture Object.

Definition at line 631 of file VuoGlPool.cc.

◆ VuoGlTexture_referenceCountsSemaphore

dispatch_semaphore_t VuoGlTexture_referenceCountsSemaphore = NULL
static

Synchronizes access to VuoGlTexture_referenceCounts.

Definition at line 632 of file VuoGlPool.cc.

◆ VuoGlTexturePool

VuoGlTexturePoolType* VuoGlTexturePool
static

A pool of GL Textures.

Definition at line 212 of file VuoGlPool.cc.

◆ VuoGlTexturePool_semaphore

dispatch_semaphore_t VuoGlTexturePool_semaphore
static

Serializes access to VuoGlTexturePool.

Definition at line 213 of file VuoGlPool.cc.

◆ VuoIoSurfacePool

VuoIoSurfacePoolType* VuoIoSurfacePool
static

Unused IOSurfaces.

Definition at line 753 of file VuoGlPool.cc.

◆ VuoIoSurfacePool_semaphore

dispatch_semaphore_t VuoIoSurfacePool_semaphore
static

Serializes access to the IOSurface pool.

Definition at line 755 of file VuoGlPool.cc.

◆ VuoIoSurfaceQuarantine

VuoIoSurfacePoolType* VuoIoSurfaceQuarantine
static

IOSurfaces which might still be in use by the receiver.

Definition at line 754 of file VuoGlPool.cc.