# PreparedGraphicsObjects

from pandac.PandaModules import PreparedGraphicsObjects

Class : PreparedGraphicsObjects
Description : A table of objects that are saved within the graphics context for reference by handle later. Generally, this represents things like OpenGL texture objects or display lists (or their equivalent on other platforms).
This object simply records the pointers to the context objects created by the individual GSG's; these context objects will contain enough information to reference or release the actual object stored within the graphics context.
These tables may potentially be shared between related graphics contexts, hence their storage here in a separate object rather than as a part of the GraphicsStateGuardian.

## Inheritance:

PreparedGraphicsObjects: ReferenceCount
ReferenceCount: MemoryBase
MemoryBase:

## Methods of PreparedGraphicsObjects:

dequeueGeom
dequeueIndexBuffer
dequeueShader
dequeueTexture
dequeueVertexBuffer
enqueueGeom
enqueueIndexBuffer
enqueueShader
enqueueTexture
enqueueVertexBuffer
getGraphicsMemoryLimit
getName
getNumPrepared
getNumPreparedGeoms
getNumPreparedIndexBuffers
getNumPreparedShaders
getNumPreparedTextures
getNumPreparedVertexBuffers
getNumQueued
getNumQueuedGeoms
getNumQueuedIndexBuffers
getNumQueuedShaders
getNumQueuedTextures
getNumQueuedVertexBuffers
isGeomPrepared
isGeomQueued
isIndexBufferPrepared
isIndexBufferQueued
isShaderPrepared
isShaderQueued
isTexturePrepared
isTextureQueued
isVertexBufferPrepared
isVertexBufferQueued
prepareGeomNow
prepareIndexBufferNow
prepareShaderNow
prepareTextureNow
prepareVertexBufferNow
releaseAll
releaseAllGeoms
releaseAllIndexBuffers
releaseAllShaders
releaseAllTextures
releaseAllVertexBuffers
releaseGeom
releaseIndexBuffer
releaseShader
releaseTexture
releaseVertexBuffer
setGraphicsMemoryLimit
showGraphicsMemoryLru
showResidencyTrackers

## Methods of ReferenceCount:

getClassType
getRefCount
ref
testRefCountIntegrity
testRefCountNonzero
unref

dequeueGeom bool PreparedGraphicsObjects::dequeue_geom(Geom *geom); Description: Removes a geom from the queued list of geoms to be prepared. Normally it is not necessary to call this, unless you change your mind about preparing it at the last minute, since the geom will automatically be dequeued and prepared at the next frame. The return value is true if the geom is successfully dequeued, false if it had not been queued.

dequeueIndexBuffer bool PreparedGraphicsObjects::dequeue_index_buffer(GeomPrimitive *data); Description: Removes a buffer from the queued list of data arrays to be prepared. Normally it is not necessary to call this, unless you change your mind about preparing it at the last minute, since the data will automatically be dequeued and prepared at the next frame. The return value is true if the buffer is successfully dequeued, false if it had not been queued.

dequeueShader bool PreparedGraphicsObjects::dequeue_shader(Shader *shader); Description: Removes a shader from the queued list of shaders to be prepared. Normally it is not necessary to call this, unless you change your mind about preparing it at the last minute, since the shader will automatically be dequeued and prepared at the next frame. The return value is true if the shader is successfully dequeued, false if it had not been queued.

dequeueTexture bool PreparedGraphicsObjects::dequeue_texture(Texture *tex); Description: Removes a texture from the queued list of textures to be prepared. Normally it is not necessary to call this, unless you change your mind about preparing it at the last minute, since the texture will automatically be dequeued and prepared at the next frame. The return value is true if the texture is successfully dequeued, false if it had not been queued.

dequeueVertexBuffer bool PreparedGraphicsObjects::dequeue_vertex_buffer(GeomVertexArrayData *data); Description: Removes a buffer from the queued list of data arrays to be prepared. Normally it is not necessary to call this, unless you change your mind about preparing it at the last minute, since the data will automatically be dequeued and prepared at the next frame. The return value is true if the buffer is successfully dequeued, false if it had not been queued.

enqueueGeom void PreparedGraphicsObjects::enqueue_geom(Geom *geom); Description: Indicates that a geom would like to be put on the list to be prepared when the GSG is next ready to do this (presumably at the next frame).

enqueueIndexBuffer void PreparedGraphicsObjects::enqueue_index_buffer(GeomPrimitive *data); Description: Indicates that a buffer would like to be put on the list to be prepared when the GSG is next ready to do this (presumably at the next frame).

enqueueShader void PreparedGraphicsObjects::enqueue_shader(Shader *shader); Description: Indicates that a shader would like to be put on the list to be prepared when the GSG is next ready to do this (presumably at the next frame).

enqueueTexture void PreparedGraphicsObjects::enqueue_texture(Texture *tex); Description: Indicates that a texture would like to be put on the list to be prepared when the GSG is next ready to do this (presumably at the next frame).

enqueueVertexBuffer void PreparedGraphicsObjects::enqueue_vertex_buffer(GeomVertexArrayData *data); Description: Indicates that a buffer would like to be put on the list to be prepared when the GSG is next ready to do this (presumably at the next frame).

getGraphicsMemoryLimit unsigned int PreparedGraphicsObjects::get_graphics_memory_limit(void) const; Description: Returns the artificial cap on graphics memory that will be imposed on this GSG. See set_graphics_memory_limit().

getName string const &PreparedGraphicsObjects::get_name(void) const; Description: Returns the name of the PreparedGraphicsObjects structure. This is an arbitrary name that serves mainly to uniquify the context for PStats reporting.

getNumPrepared int PreparedGraphicsObjects::get_num_prepared(void) const; Description: Returns the number of objects of any kind that have already been prepared on this GSG.

getNumPreparedGeoms int PreparedGraphicsObjects::get_num_prepared_geoms(void) const; Description: Returns the number of geoms that have already been prepared on this GSG.

getNumPreparedIndexBuffers int PreparedGraphicsObjects::get_num_prepared_index_buffers(void) const; Description: Returns the number of index buffers that have already been prepared on this GSG.

getNumPreparedShaders int PreparedGraphicsObjects::get_num_prepared_shaders(void) const; Description: Returns the number of shaders that have already been prepared on this GSG.

getNumPreparedTextures int PreparedGraphicsObjects::get_num_prepared_textures(void) const; Description: Returns the number of textures that have already been prepared on this GSG.

getNumPreparedVertexBuffers int PreparedGraphicsObjects::get_num_prepared_vertex_buffers(void) const; Description: Returns the number of vertex buffers that have already been prepared on this GSG.

getNumQueued int PreparedGraphicsObjects::get_num_queued(void) const; Description: Returns the number of objects of any kind that have been enqueued to be prepared on this GSG.

getNumQueuedGeoms int PreparedGraphicsObjects::get_num_queued_geoms(void) const; Description: Returns the number of geoms that have been enqueued to be prepared on this GSG.

getNumQueuedIndexBuffers int PreparedGraphicsObjects::get_num_queued_index_buffers(void) const; Description: Returns the number of index buffers that have been enqueued to be prepared on this GSG.

getNumQueuedShaders int PreparedGraphicsObjects::get_num_queued_shaders(void) const; Description: Returns the number of shaders that have been enqueued to be prepared on this GSG.

getNumQueuedTextures int PreparedGraphicsObjects::get_num_queued_textures(void) const; Description: Returns the number of textures that have been enqueued to be prepared on this GSG.

getNumQueuedVertexBuffers int PreparedGraphicsObjects::get_num_queued_vertex_buffers(void) const; Description: Returns the number of vertex buffers that have been enqueued to be prepared on this GSG.

isGeomPrepared bool PreparedGraphicsObjects::is_geom_prepared(Geom const *geom) const; Description: Returns true if the vertex buffer has been prepared on this GSG, false otherwise.

isGeomQueued bool PreparedGraphicsObjects::is_geom_queued(Geom const *geom) const; Description: Returns true if the geom has been queued on this GSG, false otherwise.

isIndexBufferPrepared bool PreparedGraphicsObjects::is_index_buffer_prepared(GeomPrimitive const *data) const; Description: Returns true if the index buffer has been prepared on this GSG, false otherwise.

isIndexBufferQueued bool PreparedGraphicsObjects::is_index_buffer_queued(GeomPrimitive const *data) const; Description: Returns true if the index buffer has been queued on this GSG, false otherwise.

isShaderPrepared bool PreparedGraphicsObjects::is_shader_prepared(Shader const *shader) const; Description: Returns true if the shader has been prepared on this GSG, false otherwise.

isShaderQueued bool PreparedGraphicsObjects::is_shader_queued(Shader const *shader) const; Description: Returns true if the shader has been queued on this GSG, false otherwise.

isTexturePrepared bool PreparedGraphicsObjects::is_texture_prepared(Texture const *tex) const; Description: Returns true if the texture has been prepared on this GSG, false otherwise.

isTextureQueued bool PreparedGraphicsObjects::is_texture_queued(Texture const *tex) const; Description: Returns true if the texture has been queued on this GSG, false otherwise.

isVertexBufferPrepared bool PreparedGraphicsObjects::is_vertex_buffer_prepared(GeomVertexArrayData const *data) const; Description: Returns true if the vertex buffer has been prepared on this GSG, false otherwise.

isVertexBufferQueued bool PreparedGraphicsObjects::is_vertex_buffer_queued(GeomVertexArrayData const *data) const; Description: Returns true if the vertex buffer has been queued on this GSG, false otherwise.

prepareGeomNow GeomContext *PreparedGraphicsObjects::prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg); Description: Immediately creates a new GeomContext for the indicated geom and returns it. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new geoms. If this is not necessarily the case, you should use enqueue_geom() instead. Normally, this function is not called directly. Call Geom::prepare_now() instead. The GeomContext contains all of the pertinent information needed by the GSG to keep track of this one particular geom, and will exist as long as the geom is ready to be rendered. When either the Geom or the PreparedGraphicsObjects object destructs, the GeomContext will be deleted.

prepareIndexBufferNow IndexBufferContext *PreparedGraphicsObjects::prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg); Description: Immediately creates a new IndexBufferContext for the indicated data and returns it. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new datas. If this is not necessarily the case, you should use enqueue_index_buffer() instead. Normally, this function is not called directly. Call Data::prepare_now() instead. The IndexBufferContext contains all of the pertinent information needed by the GSG to keep track of this one particular data, and will exist as long as the data is ready to be rendered. When either the Data or the PreparedGraphicsObjects object destructs, the IndexBufferContext will be deleted.

prepareShaderNow ShaderContext *PreparedGraphicsObjects::prepare_shader_now(Shader *shader, GraphicsStateGuardianBase *gsg); Description: Immediately creates a new ShaderContext for the indicated shader and returns it. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new shaders. If this is not necessarily the case, you should use enqueue_shader() instead. Normally, this function is not called directly. Call Shader::prepare_now() instead. The ShaderContext contains all of the pertinent information needed by the GSG to keep track of this one particular shader, and will exist as long as the shader is ready to be rendered. When either the Shader or the PreparedGraphicsObjects object destructs, the ShaderContext will be deleted.

prepareTextureNow TextureContext *PreparedGraphicsObjects::prepare_texture_now(Texture *tex, GraphicsStateGuardianBase *gsg); Description: Immediately creates a new TextureContext for the indicated texture and returns it. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new textures. If this is not necessarily the case, you should use enqueue_texture() instead. Normally, this function is not called directly. Call Texture::prepare_now() instead. The TextureContext contains all of the pertinent information needed by the GSG to keep track of this one particular texture, and will exist as long as the texture is ready to be rendered. When either the Texture or the PreparedGraphicsObjects object destructs, the TextureContext will be deleted.

prepareVertexBufferNow VertexBufferContext *PreparedGraphicsObjects::prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase *gsg); Description: Immediately creates a new VertexBufferContext for the indicated data and returns it. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new datas. If this is not necessarily the case, you should use enqueue_vertex_buffer() instead. Normally, this function is not called directly. Call Data::prepare_now() instead. The VertexBufferContext contains all of the pertinent information needed by the GSG to keep track of this one particular data, and will exist as long as the data is ready to be rendered. When either the Data or the PreparedGraphicsObjects object destructs, the VertexBufferContext will be deleted.

releaseAll void PreparedGraphicsObjects::release_all(void); Description: Releases all prepared objects of all kinds at once.

releaseAllGeoms int PreparedGraphicsObjects::release_all_geoms(void); Description: Releases all geoms at once. This will force them to be reloaded into geom memory for all GSG's that share this object. Returns the number of geoms released.

releaseAllIndexBuffers int PreparedGraphicsObjects::release_all_index_buffers(void); Description: Releases all datas at once. This will force them to be reloaded into data memory for all GSG's that share this object. Returns the number of datas released.

releaseAllShaders int PreparedGraphicsObjects::release_all_shaders(void); Description: Releases all shaders at once. This will force them to be reloaded into shader memory for all GSG's that share this object. Returns the number of shaders released.

releaseAllTextures int PreparedGraphicsObjects::release_all_textures(void); Description: Releases all textures at once. This will force them to be reloaded into texture memory for all GSG's that share this object. Returns the number of textures released.

releaseAllVertexBuffers int PreparedGraphicsObjects::release_all_vertex_buffers(void); Description: Releases all datas at once. This will force them to be reloaded into data memory for all GSG's that share this object. Returns the number of datas released.

releaseGeom void PreparedGraphicsObjects::release_geom(GeomContext *gc); Description: Indicates that a geom context, created by a previous call to prepare_geom(), is no longer needed. The driver resources will not be freed until some GSG calls update(), indicating it is at a stage where it is ready to release geoms--this prevents conflicts from threading or multiple GSG's sharing geoms (we have no way of knowing which graphics context is currently active, or what state it's in, at the time release_geom is called).

releaseIndexBuffer void PreparedGraphicsObjects::release_index_buffer(IndexBufferContext *ibc); Description: Indicates that a data context, created by a previous call to prepare_index_buffer(), is no longer needed. The driver resources will not be freed until some GSG calls update(), indicating it is at a stage where it is ready to release datas--this prevents conflicts from threading or multiple GSG's sharing datas (we have no way of knowing which graphics context is currently active, or what state it's in, at the time release_index_buffer is called).

releaseShader void PreparedGraphicsObjects::release_shader(ShaderContext *sc); Description: Indicates that a shader context, created by a previous call to prepare_shader(), is no longer needed. The driver resources will not be freed until some GSG calls update(), indicating it is at a stage where it is ready to release shaders--this prevents conflicts from threading or multiple GSG's sharing shaders (we have no way of knowing which graphics context is currently active, or what state it's in, at the time release_shader is called).

releaseTexture void PreparedGraphicsObjects::release_texture(TextureContext *tc); Description: Indicates that a texture context, created by a previous call to prepare_texture(), is no longer needed. The driver resources will not be freed until some GSG calls update(), indicating it is at a stage where it is ready to release textures--this prevents conflicts from threading or multiple GSG's sharing textures (we have no way of knowing which graphics context is currently active, or what state it's in, at the time release_texture is called). Description: Releases a texture if it has already been prepared, or removes it from the preparation queue.

releaseVertexBuffer void PreparedGraphicsObjects::release_vertex_buffer(VertexBufferContext *vbc); Description: Indicates that a data context, created by a previous call to prepare_vertex_buffer(), is no longer needed. The driver resources will not be freed until some GSG calls update(), indicating it is at a stage where it is ready to release datas--this prevents conflicts from threading or multiple GSG's sharing datas (we have no way of knowing which graphics context is currently active, or what state it's in, at the time release_vertex_buffer is called).

setGraphicsMemoryLimit void PreparedGraphicsObjects::set_graphics_memory_limit(unsigned int limit); Description: Sets an artificial cap on graphics memory that will be imposed on this GSG. This limits the total amount of graphics memory, including texture memory and vertex buffer memory, that will be consumed by the GSG, regardless of whether the hardware claims to provide more graphics memory than this. It is useful to put a ceiling on graphics memory consumed, since some drivers seem to allow the application to consume more memory than the hardware can realistically support.

showGraphicsMemoryLru void PreparedGraphicsObjects::show_graphics_memory_lru(ostream &out) const; Description: Writes to the indicated ostream a report of how the various textures and vertex buffers are allocated in the LRU.

showResidencyTrackers void PreparedGraphicsObjects::show_residency_trackers(ostream &out) const; Description: Writes to the indicated ostream a report of how the various textures and vertex buffers are allocated in the LRU.

getClassType static TypeHandle ReferenceCount::get_class_type(void); Undocumented function.

getRefCount int ReferenceCount::get_ref_count(void) const; Description: Returns the current reference count.

ref void ReferenceCount::ref(void) const; Description: Explicitly increments the reference count. User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

testRefCountIntegrity bool ReferenceCount::test_ref_count_integrity(void) const; Description: Does some easy checks to make sure that the reference count isn't completely bogus. Returns true if ok, false otherwise.

testRefCountNonzero bool ReferenceCount::test_ref_count_nonzero(void) const; Description: Does some easy checks to make sure that the reference count isn't zero, or completely bogus. Returns true if ok, false otherwise.

unref bool ReferenceCount::unref(void) const; Description: Explicitly decrements the reference count. Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete(). User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it. The return value is true if the new reference count is nonzero, false if it is zero.