The WSGLBufferObjectCache is a cache which manages the allocation and storage of WSGLBufferObjectCacheItem (cache items).
More...
#include <Rendering/OpenGL/wsglbufferobjectcache.h>
The cache keeps track of each cache item, making sure that unused items are placed onto an expiry queue, ready for deletion. Items that are still in use will never be placed on the queue.
The only way that WSGLBufferObjectCacheItems should be created is via the getCacheItem function. This will return a reference-counted pointer (WSGLBufferObjectCacheItemPtr) to the cache item.
- See also
- WSGLBufferObjectCacheItem
-
WSGLBufferObjectCacheItemPtr
◆ ContentDiagnostics
◆ WSGLBufferObjectCache() [1/3]
Create a cache with no size limit.
◆ WSGLBufferObjectCache() [2/3]
Create a cache with the specified size limit.
◆ ~WSGLBufferObjectCache()
Must ensure the cache is emptied before deleting it. We must not hold onto any OpenGL buffer objects.
◆ WSGLBufferObjectCache() [3/3]
◆ discardUnused()
Purges any expired items in the cache. The items themselves will manage their own deletion.
◆ getBytesInUse()
Returns the number of bytes that are currently in use (i.e. not on the expiry queue). This can be used to determine whether or not pointers are being held between frames for debug purposes.
- Returns
- size of the number of items currently held by pointers, in bytes.
◆ getCacheItem()
Publically accessible function to get an item from the cache. If one does not exist, a new item will be created and added to the cache. In certain situations, the cache item may fail to be created (usually due to an invalid GL context, or no buffer support). If this occurs, an invalid (empty) WSGLBufferObjectCacheItemPtr will be returned.
- Parameters
-
id | The unique identifier of the item to retrieve / create. |
type | The GL buffer type of the item. Not used if retrieving an item. Only used when creating. |
- Returns
- pointer object to the Cache Item which will automatically manage the ref counting
◆ getCapacity()
Returns the capacity of the cache in bytes, AKA its size limit. If the cache is of unlimited capacity, it will return 0.
- Returns
- the capacity of the cache, in bytes (or 0 of capacity is unlimited)
◆ getContentDiagnostics()
- Returns
- A collection of diagnostics; one for each item in the cache.
◆ getSize()
Returns the current size of the cache in bytes, i.e. the total size of all the items that have been added to the cache.
- Returns
- size of the cache in bytes.
◆ hasCacheItem()
bool hasCacheItem |
( |
const QString & |
id | ) |
const |
Function to check whether or not an item with the specified ID is in the cache.
- Parameters
-
- Returns
- true if an item with the specified id exists in the cache, false otherwise.
◆ operator=()
◆ setCapacity()
void setCapacity |
( |
size_t |
capacity | ) |
|
- Parameters
-
capacity | The desired capacity of the buffer object cache. |
Sets the capacity of the WSGLBufferObjectCache. Note that if the specified capacity is lower than the existing capacity, unused items in the cache will be discarded up-until the size is less than or equal to the new capacity.