IResourceCache
Description
- Derived from
- Extended by
-
ResourceCache sealed
A cache for GPU resources.
GPU resources are referenced via IResourceHandle objects, from which GPU resource objects (see IResource) can be created using the following methods:
-
GetNull
Optional GPU resources; these resources are created on-demand and are fed into the graphics API by the calling code. Usually, the calling code does not keep references to these resources. Ownership is held by the resource cache. -
OwnNull
Mandatory GPU resources that will be shared between all callers for a graphics context; these resources are created once and then kept by the calling code. Ownership is held by the calling code.
These method may be called repeatedly in arbitrary order for the same resource handle.
Public / Methods
DisposeAll
Disposes all resource objects that are owned by this resource cache and removes their resource handle mappings from the cache.
When this method is called, all cached resources that have been obtained via GetNull will be disposed.
Cached resources that have been obtained via OwnNull will remain in the cache.
FindNull
Returns an existing object in the resource cache.
The IResourceHandle.CreateResource will never be called when this method is used, only existing resource objects will be returned.
GetNull
Returns a cached resource object.
The returned resource object will be disposed automatically. Implementing classes may choose any kind of disposal strategy, as long as it adheres to the following requirements:
-
The resource object will be disposed at the latest when the resource cache is disposed.
-
The resource object will be disposed at the earliest when one of the following occurs:
-
The DisposeAll method is called.
-
The Evict method is called, passing handle in resp. preload opt.
-
The GetNull method is called and IResource.Binding1 returns
false
. -
The OwnNull method is called and IResource.Binding1 returns
false
.
-
Public / Attributes
CacheMemoryUtilization
The memory amount of cached resource objects that are owned by the resource cache.
Resources obtained via OwnNull are owned by the caller and are not counted in this value.
- See also
Extensions
Find
Returns an existing object in the resource cache.
This method delegates to IResourceCache.FindNull.
- RenderException
-
If the resulting resource object would be
null
.
- See also
Get
Returns a cached resource object.
This method delegates to IResourceCache.GetNull.
- RenderException
-
If the resulting resource object would be
null
.
- See also
Own
Returns a cached resource object.
This method delegates to IResourceCache.OwnNull.
- RenderException
-
If the resulting resource object would be
null
.
- See also
OwnPixelFont
Helper that delegates to IResourceCache.OwnNull and returns a default font (see PixelFont.HandleDefault) if it returns null
.