HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_TextureCache Class Reference

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...
 

Static Public Member Functions

static void init ()
 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 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, 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, 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_VKImageuncacheImage (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 installHDACallback (RV_TextureHDAResolverCB resolver_func)
 For resolving. 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_Vector3i *resolution)
 
RV_TextureCache::Image privGetTexture (exint id)
 
virtual ~RV_TextureCache ()
 
- Protected Member Functions inherited from UT_NonCopyableNS::UT_NonCopyable
 UT_NonCopyable ()=default
 
 ~UT_NonCopyable ()=default
 
 UT_NonCopyable (const UT_NonCopyable &)=delete
 
UT_NonCopyableoperator= (const UT_NonCopyable &)=delete
 

Static Protected Member Functions

static RV_TextureCache::Image getTexture (exint id)
 
static RV_VKImagegetPlaceholder (RV_Render *r, RV_ImageDim tex_type, PlaceholderType type=MISSING_WHITE_SOLID, const UT_Vector4F *fallbackcolor=nullptr)
 

Detailed Description

Global cache of vulkan textures sourced from files.

Definition at line 39 of file RV_TextureCache.h.

Member Enumeration Documentation

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 59 of file RV_TextureCache.h.

Constructor & Destructor Documentation

virtual RV_TextureCache::~RV_TextureCache ( )
protectedvirtual

Member Function Documentation

static bool RV_TextureCache::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

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 bool RV_TextureCache::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,
PlaceholderType  missing = MISSING_WHITE_SOLID,
UT_Vector4F fallback_color = nullptr 
)
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 bool RV_TextureCache::bindTextureRef ( RV_Render r,
RV_TextureRef ref,
RV_ShaderVariableSet set,
const UT_StringHolder sampler_name 
)
static

Binds an existing texture ref to the set at 'sampler_name'. It should not be a placeholder image (use bindPlaceholder instead).

static bool RV_TextureCache::cacheAsTexture ( RV_Render r,
RV_TextureRef map,
const PXL_Raster source_image,
const RV_TextureParms map_parms,
const UT_StringHolder map_name 
)
static

Cache an existing 2D Image. The name should be prefixed with exp: (explicitly cached).

static bool RV_TextureCache::cacheImage ( UT_UniquePtr< RV_VKImage image,
RV_TextureRef map,
const UT_StringHolder map_name,
UT_DimRect udim_bounds = nullptr 
)
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 exint RV_TextureCache::cacheRefresh ( )
static

The serial refresh count of the cache. Incremented when the user explicity updates the textures

static exint RV_TextureCache::cacheVersion ( )
static

The serial version of the cache. Incremented when a texture is added.

static void RV_TextureCache::checkTextureDirty ( RV_TextureRef map,
bool &  dirty 
)
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 void RV_TextureCache::checkTextureHasAlpha ( const RV_TextureRef ref,
bool &  has_alpha 
)
static

Check if the texture has an alpha channel.

static void RV_TextureCache::cleanup ( )
static

Destroy the cache (only used by the system during exit)

static void RV_TextureCache::clear ( )
static

Clear all images out of the cache.

static const char* RV_TextureCache::getFileSeparator ( )
inlinestatic

For resolving a bunch of files to a 2D array, this is the separator character between the filenames.

Definition at line 155 of file RV_TextureCache.h.

static RV_VKImage* RV_TextureCache::getPlaceholder ( RV_Render r,
RV_ImageDim  tex_type,
PlaceholderType  type = MISSING_WHITE_SOLID,
const UT_Vector4F fallbackcolor = nullptr 
)
staticprotected
static RV_TextureCache::Image RV_TextureCache::getTexture ( exint  id)
staticprotected
static void RV_TextureCache::init ( )
static

Initialize the cache (only used by the system during startup)

static void RV_TextureCache::installHDACallback ( RV_TextureHDAResolverCB  resolver_func)
static

For resolving.

static bool RV_TextureCache::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,
UT_Vector3i resolution = nullptr 
)
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.

RV_TextureCache::Image RV_TextureCache::privGetTexture ( exint  id)
protected
static bool RV_TextureCache::removeCachedTexture ( RV_TextureRef map)
static

Remove a cached 2D Image.

exint RV_TextureCache::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_Vector3i resolution 
)
protected
static UT_UniquePtr<RV_VKImage> RV_TextureCache::uncacheImage ( RV_TextureRef map,
UT_DimRect udim_bounds = nullptr 
)
static

Remove a cached image from the cache, taking ownership of it. If udim_bounds is not null, write the bounds to it.

static void RV_TextureCache::updateTextures ( )
static

Mark any textures as dirty if their file source has been modified.


The documentation for this class was generated from the following file: