|
HDK
|
Global cache of vulkan textures sourced from files. More...
#include <RV_TextureCache.h>
Inheritance diagram for RV_TextureCache:Classes | |
| class | Image |
| class | ImageInfo |
Public Types | |
| enum | PlaceholderType { MISSING_BLACK_CLEAR, MISSING_BLACK_SOLID, MISSING_WHITE_SOLID, MISSING_RED_SOLID, MISSING_NORMAL_MAP, MISSING_FALLBACK, MAX_PLACEHOLDER } |
| If the texture is missing, one of these generic placeholders is used. More... | |
| enum | TexturePriority { PRIORITY_UNUSED, PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_CRITICAL } |
Static Public Member Functions | |
| static void | init (const UT_StringHolder &device_name) |
| Initialize the cache (only used by the system during startup) More... | |
| static void | cleanup () |
| Destroy the cache (only used by the system during exit) More... | |
| static void | clear () |
| Clear all images out of the cache. More... | |
| static void | updateTextures () |
| Mark any textures as dirty if their file source has been modified. More... | |
| static exint | cacheVersion () |
| The serial version of the cache. Incremented when a texture is added. More... | |
| static exint | cacheRefresh () |
| static exint | currentSizeBytes () |
| static exint | totalTextureCount () |
| static exint | freeSomeMem (exint mem_in_bytes) |
| static bool | bindTexture (RV_Render *r, RV_TextureRef &map, const RV_TextureParms &map_parms, const UT_StringHolder &map_name, const UT_StringHolder &relative_to_node, RV_ImageDim tex_type, RV_ShaderVariableSet *set, const UT_StringHolder &sampler_name, bool deferred_load, bool &deferred_loaded, int &op_id, TexturePriority priority=PRIORITY_NORMAL, PlaceholderType missing=MISSING_WHITE_SOLID, UT_Vector4F *fallback_color=nullptr) |
| static bool | bindTextureRef (RV_Render *r, RV_TextureRef &ref, RV_ShaderVariableSet *set, const UT_StringHolder &sampler_name) |
| static bool | bindPlaceholder (RV_Render *r, RV_ImageDim tex_type, RV_ShaderVariableSet *set, const UT_StringHolder &sampler_name, PlaceholderType placeholder_type, const UT_Vector4F *fallbackcolor=nullptr) |
| static bool | loadTextureRef (RV_Render *r, RV_TextureRef &map, const RV_TextureParms &map_parms, const UT_StringHolder &map_name, const UT_StringHolder &relative_to_node, RV_ImageDim tex_type, bool allow_deferred_load, bool &defer_load_finished, int &op_id, TexturePriority priority=PRIORITY_NORMAL, UT_Vector3i *resolution=nullptr) |
| static bool | cacheAsTexture (RV_Render *r, RV_TextureRef &map, const PXL_Raster *source_image, const RV_TextureParms &map_parms, const UT_StringHolder &map_name) |
| static bool | removeCachedTexture (RV_TextureRef &map) |
| Remove a cached 2D Image. More... | |
| static bool | cacheImage (UT_UniquePtr< RV_VKImage > image, RV_TextureRef &map, const UT_StringHolder &map_name, UT_DimRect *udim_bounds=nullptr) |
| static UT_UniquePtr< RV_VKImage > | uncacheImage (RV_TextureRef &map, UT_DimRect *udim_bounds=nullptr) |
| static void | checkTextureDirty (RV_TextureRef &map, bool &dirty) |
| static void | checkTextureHasAlpha (const RV_TextureRef &ref, bool &has_alpha) |
| Check if the texture has an alpha channel. More... | |
| static const char * | getFileSeparator () |
| static void | setSingleTexMemLimitMB (exint mem_in_mb) |
| static exint | singleTexMemLimitMB () |
| static void | setCacheSize (exint mem_in_bytes) |
| static void | setReductionFactor (fpreal reduce) |
| Reduce all textures in the cache by at least this amount. More... | |
| static void | installHDACallback (RV_TextureHDAResolverCB resolver_func) |
| For resolving. More... | |
Static Public Member Functions inherited from UT_Cache | |
| static const UT_ValArray < UT_Cache * > & | utGetCacheList () |
| get the list of caches More... | |
| static void | setCacheAddRemoveCB (void(*callback)(void *), void *data) |
| callback to be called when a cache is added or deleted. More... | |
| static int64 | utClearSpaceFromCaches (int64 amount) |
| this method attempts to free up 'amount' bytes from all the caches. More... | |
Protected Member Functions | |
| exint | resolveTexture (RV_Render *r, const UT_StringHolder &map_name, const UT_StringHolder &relative_to_node, const RV_TextureParms &tex_parms, RV_ImageDim tex_type, bool force_update, bool deferred_load, bool &defer_loaded, int &op_id, bool &missing_texture, UT_SharedPtr< RV_TextureRef::CacheData > &ref, TexturePriority priority, UT_Vector3i *resolution) |
| RV_TextureCache::Image | privGetTexture (exint id) |
| RV_TextureCache (const UT_StringHolder &name) | |
| ~RV_TextureCache () override | |
| const char * | utGetCacheName () const override |
| required - return the english name for this cache. More... | |
| int64 | utGetCurrentSize () const override |
| required - return the current cache size, in bytes More... | |
| int64 | utReduceCacheSizeBy (int64 amount) override |
| bool | utHasMaxSize () const override |
| optional - override if the cache has a well defined maximum size More... | |
| int64 | utGetMaxSize () const override |
| void | utSetMaxSize (int64) override |
Static Protected Member Functions | |
| static RV_TextureCache::Image | getTexture (exint id) |
| static RV_VKImage * | getPlaceholder (RV_Render *r, RV_ImageDim tex_type, PlaceholderType type=MISSING_WHITE_SOLID, const UT_Vector4F *fallbackcolor=nullptr) |
Additional Inherited Members | |
Public Member Functions inherited from UT_Cache | |
| UT_Cache () | |
| virtual | ~UT_Cache () |
| UT_Cache (const UT_Cache &)=delete | |
| UT_Cache & | operator= (const UT_Cache &)=delete |
| void | utClearCache () |
| virtual bool | utIsEnabled () const |
| optional - is this cache currently operational. More... | |
| virtual bool | utHasMinSize () const |
| virtual int64 | utGetMinSize () const |
| virtual void | utSetMinSize (int64) |
| virtual bool | utUpdateCacheInfo () |
Global cache of vulkan textures sourced from files.
Definition at line 46 of file RV_TextureCache.h.
If the texture is missing, one of these generic placeholders is used.
| Enumerator | |
|---|---|
| MISSING_BLACK_CLEAR | |
| MISSING_BLACK_SOLID | |
| MISSING_WHITE_SOLID | |
| MISSING_RED_SOLID | |
| MISSING_NORMAL_MAP | |
| MISSING_FALLBACK | |
| MAX_PLACEHOLDER | |
Definition at line 72 of file RV_TextureCache.h.
| Enumerator | |
|---|---|
| PRIORITY_UNUSED | |
| PRIORITY_LOW | |
| PRIORITY_NORMAL | |
| PRIORITY_HIGH | |
| PRIORITY_CRITICAL | |
Definition at line 84 of file RV_TextureCache.h.
|
protected |
|
overrideprotected |
|
static |
Bind a small placeholder texture (1x1) to 'sampler_name' in 'set'. The RGBA texture color is defined by the placeholder_type, or can be a custom/ color if the type is FALLBACK. The texture is 8b unorm RGBA.
|
static |
Load the map (if needed) and bind the resulting texture to 'sampler_name' in 'set'. If it cannot be loaded, bind a placeholder texture instead. This method is equivalent to calling loadTextureRef() and then bindTextureRef() or bindPlaceholder(). If the map is a reference to a mofr with op:, op_id will contain its unique ID.
|
static |
Binds an existing texture ref to the set at 'sampler_name'. It should not be a placeholder image (use bindPlaceholder instead).
|
static |
Cache an existing 2D Image. The name should be prefixed with exp: (explicitly cached).
|
static |
Cache an existing image. The cache takes ownership (use std::move for the image). If the image is a UDIM, you can optionally pass the bounds. The map name should be prefixed with exp: (explicitly cached).
|
static |
The serial refresh count of the cache. Incremented when the user explicity updates the textures
|
static |
The serial version of the cache. Incremented when a texture is added.
|
static |
Check if the texture is out of date. Flag the ref and set dirty if so. doesn't touch either if it's current.
|
static |
Check if the texture has an alpha channel.
|
static |
Destroy the cache (only used by the system during exit)
|
static |
Clear all images out of the cache.
|
static |
|
inlinestatic |
For resolving a bunch of files to a 2D array, this is the separator character between the filenames.
Definition at line 179 of file RV_TextureCache.h.
|
staticprotected |
|
staticprotected |
|
static |
Initialize the cache (only used by the system during startup)
|
static |
For resolving.
|
static |
Load the map info a texture ref without binding it to a shader. If the map could not be loaded, map.isPlaceholder() will be true. If allow_deferred_load is true, background load the texture. Keep calling this in subsequent redraws until defer_load_finished is true.
|
protected |
|
static |
Remove a cached 2D Image.
|
protected |
Reduce all textures in the cache by at least this amount.
|
static |
|
static |
|
static |
Remove a cached image from the cache, taking ownership of it. If udim_bounds is not null, write the bounds to it.
|
static |
Mark any textures as dirty if their file source has been modified.
|
inlineoverrideprotectedvirtual |
required - return the english name for this cache.
Implements UT_Cache.
Definition at line 264 of file RV_TextureCache.h.
|
inlineoverrideprotectedvirtual |
required - return the current cache size, in bytes
Implements UT_Cache.
Definition at line 266 of file RV_TextureCache.h.
|
inlineoverrideprotectedvirtual |
optional - override if the cache has a well defined maximum size
Reimplemented from UT_Cache.
Definition at line 270 of file RV_TextureCache.h.
required - free contents of the cache by amount bytes. Returns the amount of memory (in bytes) actually freed. This does not change the cache size
Implements UT_Cache.
Definition at line 268 of file RV_TextureCache.h.
Reimplemented from UT_Cache.
Definition at line 272 of file RV_TextureCache.h.