Global Shader Variables
Typedefs
-
using ManagedTex = resptr_detail::ManagedRes<BaseTexture>
-
using ManagedBuf = resptr_detail::ManagedRes<Sbuffer>
-
namespace resptr_detail
-
namespace VariableMap
Functions
-
const char *getVariableName(int var_id, bool sec_dump_for_exp = false)
Get variable name by ID.
- Returns:
NULL when var_id is out of range.
-
int getVariableId(const char *variable_name, bool sec_dump_for_exp = false)
Get varID by for nam.
- Returns:
BAD_ID if fail (but generally will always return valid ID, so isVariablePresent() should also be used).
-
int getVariableArraySize(const char *name)
- Returns:
The size of an array for a variable name.
-
int getVariablesCount(bool sec_dump_for_exp = false)
- Returns:
Total number of variable identifiers (var_id will be valid from 0 to count-1).
-
int getGlobalVariablesCount()
- Returns:
Total number of global variables.
-
const char *getGlobalVariableName(int globvar_idx)
- Returns:
Name of global variable specified by ordinal index.
-
bool isVariablePresent(int var_id)
- Returns:
true when variable for specified var_id is present in shaders dump.
-
bool isVariablePresent(const ShaderVariableInfo &var_id)
- Returns:
true when variable for specified var_id is present in shaders dump.
-
bool isGlobVariablePresent(int var_id)
- Returns:
true when global variable for specified var_id is present in shaders dump.
-
bool isGlobVariablePresent(const ShaderVariableInfo &var_id)
- Returns:
true when global variable for specified var_id is present in shaders dump.
-
dag::Vector<String> getPresentedGlobalVariableNames()
Note
Consider that some shadervars are present in dump but never used by ShaderGlobal:: or VariableMap:: public API. To iterate over all used variables you can use raw IDs from 0 to getGlobalVariablesCount()
- Returns:
List of all global shader variables names which are presented in current shaders dump.
-
uint32_t generation()
- Returns:
generation (i.e. is shader dump was reloaded).
Variables
-
static constexpr int BAD_ID = -1
-
const char *getVariableName(int var_id, bool sec_dump_for_exp = false)
-
namespace ShaderGlobal
Typedefs
-
using Interval = detail::StringToHash<true>
-
using Subinterval = detail::StringToHash<false>
-
using Variant = eastl::pair<Interval, Subinterval>
Functions
-
void set_variant(Interval interv, Subinterval subinterv)
-
Subinterval get_variant(Interval interv)
-
int get_var_type(int variable_id)
- Returns:
SHVT_INT, SHVT_REAL, SHVT_COLOR4 or SHVT_TEXTURE.
-
bool is_var_assumed(int variable_id)
-
int get_interval_assumed_value(int variable_id)
-
int get_interval_current_value(int variable_id)
-
bool has_associated_interval(int variable_id)
-
dag::ConstSpan<float> get_interval_ranges(int variable_id)
-
bool set_int(int variable_id, int v)
-
bool set_real(int variable_id, float v)
-
bool set_color4(int variable_id, const Point2 &rg, const Point2 &ba = Point2(0, 0))
-
bool set_color4(int variable_id, const Point3 &rgb, float a = 0.f)
-
bool set_color4(int variable_id, const Point4 &v)
-
bool set_color4(int variable_id, const Color4 &v)
-
bool set_color4(int variable_id, const Color3 &rgb, float a = 0.f)
-
bool set_color4(int variable_id, float r, float g, float b = 0.f, float a = 0.f)
-
bool set_color4_array(int variable_id, const Color4 *data, int count)
-
bool set_color4_array(int variable_id, const Point4 *data, int count)
-
bool set_color4(int variable_id, E3DCOLOR c)
-
bool set_color4(int variable_id, const XMFLOAT2 &rg, const XMFLOAT2 &ba)
-
bool set_color4(int variable_id, const XMFLOAT3 &rgb, float a = 0.f)
-
bool set_color4(int variable_id, const XMFLOAT4 &v)
-
bool set_color4(int variable_id, FXMVECTOR v)
-
bool set_float4x4(int variable_id, const TMatrix4 &mat)
-
bool set_float4x4(int variable_id, const XMFLOAT4X4 &mat)
-
bool set_float4x4(int variable_id, FXMMATRIX mat)
-
bool set_int4(int variable_id, const IPoint4 &v)
-
bool set_int4_array(int variable_id, const IPoint4 *data, int count)
-
bool set_texture(int variable_id, const ManagedTex &texture)
-
bool set_buffer(int variable_id, const ManagedBuf &buffer)
-
bool set_texture(const ShaderVariableInfo&, const ManagedTex &texture)
-
bool set_buffer(const ShaderVariableInfo&, const ManagedBuf &buffer)
-
bool set_tlas(int variable_id, RaytraceTopAccelerationStructure *ptr)
-
void reset_textures(bool removed_tex_only = false)
Set all texture global vars to BAD_TEXTUREID and issue release_managed_tex() on them.
-
void reset_stale_vars()
Reset all var types, that are not valid after reset.
-
inline void reset_from_vars_and_release_managed_tex(TEXTUREID &id)
Reset references to texture from all global shader vars and than calls release_managed_tex(id) and clears id.
-
template<class T>
inline void reset_from_vars_and_release_managed_tex_verified(TEXTUREID &id, T &check_tex)
-
int get_int_fast(int glob_var_id)
- Returns:
Global shader variables using glob_var_id; tolerant to glob_var_id=-1 (return 0); with DAGOR_DBGLEVEL>0 uses G_ASSERT to check that glob_var_id is in range and to check type.
-
float get_real_fast(int glob_var_id)
-
Color4 get_color4_fast(int glob_var_id)
-
inline bool get_int_by_name(const char *name, int &val)
-
inline bool get_real_by_name(const char *name, float &val)
-
bool get_color4_by_name(const char *name, Color4 &val)
-
void set_vars_from_blk(const DataBlock &blk, bool loadTexures = false, bool allowAddTextures = false)
Read list of global var values from DataBlock and sets them to shadr global variables.
-
void set_vars_from_blk(const RoDataBlock &blk)
-
void reset_vars_from_blk()
Reset variables set by the set_vars_from_blk to their initial value (before setting any block, except textures).
-
inline int get_glob_var_id(int var_id)
-
inline void set_int_fast(int glob_var_id, int v)
-
inline void set_real_fast(int glob_var_id, float v)
-
inline void set_color4_fast(int glob_var_id, const Color4 &v)
-
inline void set_color4_fast(int glob_var_id, float r, float g, float b, float a)
-
inline int get_int(int glob_var_id)
-
inline float get_real(int glob_var_id)
-
Color4 get_color4(int glob_var_id)
-
TMatrix4 get_float4x4(int glob_var_id)
-
IPoint4 get_int4(int glob_var_id)
-
inline bool is_var_assumed(const ShaderVariableInfo &v)
-
inline int get_interval_assumed_value(const ShaderVariableInfo &v)
-
inline int get_interval_current_value(const ShaderVariableInfo &v)
-
inline bool has_associated_interval(const ShaderVariableInfo &v)
-
inline int get_slot_by_name(const char *name)
Variables
-
template<uint32_t h>
static constexpr Subinterval subinterval = Subinterval(h)
-
template<uint32_t interv_h, uint32_t subinterv_h>
static constexpr Variant variant = Variant(interval<interv_h>, subinterval<subinterv_h>)
-
namespace detail
-
template<bool is_interval>
struct StringToHash Public Functions
-
inline explicit constexpr StringToHash(uint32_t h)
-
StringToHash(const char *name, size_t len)
-
inline bool operator==(const StringToHash &rhs) const
-
inline bool operator!=(const StringToHash &rhs) const
Public Members
-
uint32_t hash
-
inline explicit constexpr StringToHash(uint32_t h)
-
template<bool is_interval>
-
using Interval = detail::StringToHash<true>