class CrShader::VariantCache

Overview

============================================================================= VariantCache - Thread-Safe O(1) Shader Permutation & Specialization Cache

Maps (source, target, strip_debug_inspects, optimize_names, sorted features) via 64-bit FNV-1a hashing to compiled shader source code (and live Godot::Shader resources when loaded in the Godot / Lapis runtime).

Defined in:

crshader/runtime/variant_cache.cr
crshader_resource.cr

Constant Summary

FNV_OFFSET_BASIS = 14695981039346656037_u64
FNV_PRIME = 1099511628211_u64

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.global : VariantCache #

def self.new(max_entries : Int32 = 256) #

Class Method Detail

def self.canonical_feature_signature(features : Hash(String, FeatureValue) | Nil) : String #

def self.compute_key(source : String, target : ShaderTarget | Nil, features : Hash(String, FeatureValue) | Nil = nil, strip_debug_inspects : Bool = false, optimize_names : Bool = false) : Tuple(UInt64, String) #

def self.normalize_feature_val(val : FeatureValue) : String #

Instance Method Detail

def clear! : Void #

def get_or_compile(source : String, target : ShaderTarget | Nil = nil, features : Hash(String, FeatureValue) | Nil = nil, strip_debug_inspects : Bool = false, optimize_names : Bool = false, filename : String | Nil = nil) : CachedVariant #

def get_or_create_godot_shader(source : String, features : Hash(String, FeatureValue) | Nil = nil, strip_debug_inspects : Bool = false, optimize_names : Bool = false, filename : String | Nil = nil) : Godot::Shader | Nil #

def hits : Int64 #

def max_entries : Int32 #

def max_entries=(max_entries : Int32) #

def misses : Int64 #

def stats : CacheStats #