Blender V5.3
SVMCompiler Class Reference

#include <svm.h>

Classes

struct  Summary
struct  Stack
struct  CompilerState

Public Member Functions

 SVMCompiler (Scene *scene, Progress &progress)
void compile (Shader *shader, array< int > &svm_nodes, const int index, Summary *summary=nullptr)
SVMInputInt input_int (const char *name)
SVMInputFloat input_float (const char *name)
SVMInputFloat3 input_float3 (const char *name)
SVMInputFloat3 input_float3_from_offset (SVMStackOffset offset)
SVMStackOffset input_link (const char *name)
SVMStackOffset output (const char *name)
SVMStackOffset output (ShaderOutput *shader_output)
void add_node (ShaderNodeType type)
template<typename T>
requires (std::is_class_v<T> && sizeof(T) % sizeof(int) == 0 && alignof(T) <= sizeof(uint))
void add_node (ShaderNode *shader_node, const ShaderNodeType type, const T &node, const bool use_derivatives=false)
void add_value_node (ShaderNode *shader_node, const float value, const int stack_offset)
void add_value_node (ShaderNode *shader_node, const float3 &value, const int stack_offset)
template<typename T>
void add_bsdf_node (const SVMNodeClosureBsdf &node, const T &data)
template<typename T>
requires (std::is_class_v<T> && sizeof(T) % sizeof(int) == 0 && alignof(T) <= sizeof(uint))
void add_node_data (const T &data)
void add_node_data_float4 (const float4 &f)
void add_node_data_float (const float f)
SVMStackOffset stack_assign (ShaderInput *input)
SVMStackOffset stack_find_offset (const ShaderIO *io)
void stack_clear_offset (const ShaderIO *io, const SVMStackOffset offset)
void stack_link (ShaderInput *input, ShaderOutput *output)
uint attribute (ustring name)
uint attribute (AttributeStandard std)
uint attribute_standard (ustring name)
SVMStackOffset closure_mix_weight_offset ()
SVMStackOffset get_bump_state_offset ()
ShaderType output_type ()

Public Attributes

Scene * scene
Progress & progress
ShaderGraph * current_graph
ShaderNode * current_node
bool background

Protected Member Functions

ShaderNodeType node_type (const ShaderNode *shader_node, const ShaderNodeType type, const bool use_derivatives)
SVMStackOffset stack_assign (ShaderOutput *output)
SVMStackOffset stack_find_offset (const int size)
void stack_clear_temporary (ShaderNode *node)
int stack_size (SocketType::Type type)
int stack_size (const ShaderIO *io)
void stack_clear_users (ShaderNode *node, ShaderNodeSet &done)
bool is_sole_user (const ShaderNode *node, const ShaderOutput *output, const ShaderNodeSet &done)
void stack_zero_incomplete_derivatives (const ShaderNode *node)
int stack_node_output_size (const ShaderNode *node)
void find_dependencies (ShaderNodeSet &dependencies, const ShaderNodeSet &done, ShaderInput *input, ShaderNode *skip_node=nullptr)
void find_aov_nodes_and_dependencies (ShaderNodeSet &aov_nodes, ShaderGraph *graph, CompilerState *state)
void generate_node (ShaderNode *node, ShaderNodeSet &done)
void generate_aov_node (ShaderNode *node, CompilerState *state)
void generate_closure_node (ShaderNode *node, CompilerState *state)
void generated_shared_closure_nodes (ShaderNode *root_node, ShaderNode *node, CompilerState *state, const ShaderNodeSet &shared)
void generate_svm_nodes (const ShaderNodeSet &nodes, CompilerState *state)
void generate_multi_closure (ShaderNode *root_node, ShaderNode *node, CompilerState *state)
void compile_type (Shader *shader, ShaderGraph *graph, ShaderType type)

Protected Attributes

std::atomic_int * svm_node_types_used
array< int > current_svm_nodes
ShaderType current_type
Shader * current_shader
Stack active_stack
int max_stack_use
SVMStackOffset mix_weight_offset
SVMStackOffset bump_state_offset
bool compile_failed

Detailed Description

Definition at line 49 of file scene/svm.h.

Constructor & Destructor Documentation

◆ SVMCompiler()

Member Function Documentation

◆ add_bsdf_node()

template<typename T>
void SVMCompiler::add_bsdf_node ( const SVMNodeClosureBsdf & node,
const T & data )
inline

◆ add_node() [1/2]

template<typename T>
requires (std::is_class_v<T> && sizeof(T) % sizeof(int) == 0 && alignof(T) <= sizeof(uint))
void SVMCompiler::add_node ( ShaderNode * shader_node,
const ShaderNodeType type,
const T & node,
const bool use_derivatives = false )
inline

◆ add_node() [2/2]

◆ add_node_data()

template<typename T>
requires (std::is_class_v<T> && sizeof(T) % sizeof(int) == 0 && alignof(T) <= sizeof(uint))
void SVMCompiler::add_node_data ( const T & data)
inline

Definition at line 128 of file scene/svm.h.

References current_svm_nodes, array< T, alignment >::push_back_slow(), and T.

Referenced by add_bsdf_node().

◆ add_node_data_float()

void SVMCompiler::add_node_data_float ( const float f)

◆ add_node_data_float4()

void SVMCompiler::add_node_data_float4 ( const float4 & f)

◆ add_value_node() [1/2]

void SVMCompiler::add_value_node ( ShaderNode * shader_node,
const float value,
const int stack_offset )

Definition at line 480 of file svm.cpp.

References add_node().

Referenced by stack_assign(), and stack_zero_incomplete_derivatives().

◆ add_value_node() [2/2]

void SVMCompiler::add_value_node ( ShaderNode * shader_node,
const float3 & value,
const int stack_offset )

Definition at line 492 of file svm.cpp.

References add_node().

◆ attribute() [1/2]

uint SVMCompiler::attribute ( AttributeStandard std)

Definition at line 541 of file svm.cpp.

References scene, and Scene::shader_manager.

◆ attribute() [2/2]

uint SVMCompiler::attribute ( ustring name)

Definition at line 536 of file svm.cpp.

References scene, and Scene::shader_manager.

Referenced by attribute_standard().

◆ attribute_standard()

uint SVMCompiler::attribute_standard ( ustring name)

Definition at line 546 of file svm.cpp.

References attribute(), and Attribute::name_standard().

◆ closure_mix_weight_offset()

SVMStackOffset SVMCompiler::closure_mix_weight_offset ( )
inline

Definition at line 149 of file scene/svm.h.

References mix_weight_offset.

Referenced by VolumeNode::compile().

◆ compile()

◆ compile_type()

◆ find_aov_nodes_and_dependencies()

void SVMCompiler::find_aov_nodes_and_dependencies ( ShaderNodeSet & aov_nodes,
ShaderGraph * graph,
CompilerState * state )
protected

◆ find_dependencies()

void SVMCompiler::find_dependencies ( ShaderNodeSet & dependencies,
const ShaderNodeSet & done,
ShaderInput * input,
ShaderNode * skip_node = nullptr )
protected

◆ generate_aov_node()

void SVMCompiler::generate_aov_node ( ShaderNode * node,
CompilerState * state )
protected

◆ generate_closure_node()

◆ generate_multi_closure()

◆ generate_node()

◆ generate_svm_nodes()

void SVMCompiler::generate_svm_nodes ( const ShaderNodeSet & nodes,
CompilerState * state )
protected

◆ generated_shared_closure_nodes()

void SVMCompiler::generated_shared_closure_nodes ( ShaderNode * root_node,
ShaderNode * node,
CompilerState * state,
const ShaderNodeSet & shared )
protected

◆ get_bump_state_offset()

SVMStackOffset SVMCompiler::get_bump_state_offset ( )
inline

Definition at line 153 of file scene/svm.h.

References bump_state_offset.

◆ input_float()

◆ input_float3()

◆ input_float3_from_offset()

SVMInputFloat3 SVMCompiler::input_float3_from_offset ( SVMStackOffset offset)

Definition at line 343 of file svm.cpp.

References SVM_INPUT_STACK_OFFSET_MASK.

Referenced by TextureMapping::compile().

◆ input_int()

SVMInputInt SVMCompiler::input_int ( const char * name)

◆ input_link()

◆ is_sole_user()

bool SVMCompiler::is_sole_user ( const ShaderNode * node,
const ShaderOutput * output,
const ShaderNodeSet & done )
protected

Definition at line 386 of file svm.cpp.

References in, node, and output().

Referenced by stack_clear_users().

◆ node_type()

ShaderNodeType SVMCompiler::node_type ( const ShaderNode * shader_node,
const ShaderNodeType type,
const bool use_derivatives )
protected

◆ output() [1/2]

◆ output() [2/2]

SVMStackOffset SVMCompiler::output ( ShaderOutput * shader_output)

Definition at line 366 of file svm.cpp.

References ShaderOutput::links, stack_assign(), and SVM_STACK_INVALID.

◆ output_type()

ShaderType SVMCompiler::output_type ( )
inline

Definition at line 158 of file scene/svm.h.

References current_type.

◆ stack_assign() [1/2]

◆ stack_assign() [2/2]

SVMStackOffset SVMCompiler::stack_assign ( ShaderOutput * output)
protected

Definition at line 290 of file svm.cpp.

References output(), stack_find_offset(), and SVM_STACK_INVALID.

◆ stack_clear_offset()

void SVMCompiler::stack_clear_offset ( const ShaderIO * io,
const SVMStackOffset offset )

◆ stack_clear_temporary()

void SVMCompiler::stack_clear_temporary ( ShaderNode * node)
protected

Definition at line 424 of file svm.cpp.

References ShaderInput::link, node, stack_clear_offset(), ShaderIO::stack_offset, and SVM_STACK_INVALID.

Referenced by generate_node().

◆ stack_clear_users()

void SVMCompiler::stack_clear_users ( ShaderNode * node,
ShaderNodeSet & done )
protected

Definition at line 402 of file svm.cpp.

References in, is_sole_user(), ShaderInput::link, node, output(), stack_clear_offset(), and SVM_STACK_INVALID.

Referenced by generate_node().

◆ stack_find_offset() [1/2]

SVMStackOffset SVMCompiler::stack_find_offset ( const int size)
protected

◆ stack_find_offset() [2/2]

SVMStackOffset SVMCompiler::stack_find_offset ( const ShaderIO * io)

◆ stack_link()

void SVMCompiler::stack_link ( ShaderInput * input,
ShaderOutput * output )

◆ stack_node_output_size()

int SVMCompiler::stack_node_output_size ( const ShaderNode * node)
protected

Definition at line 594 of file svm.cpp.

References node, output(), stack_size(), and SVM_STACK_INVALID.

Referenced by generate_svm_nodes().

◆ stack_size() [1/2]

int SVMCompiler::stack_size ( const ShaderIO * io)
protected

◆ stack_size() [2/2]

◆ stack_zero_incomplete_derivatives()

void SVMCompiler::stack_zero_incomplete_derivatives ( const ShaderNode * node)
protected

Member Data Documentation

◆ active_stack

Stack SVMCompiler::active_stack
protected

Definition at line 285 of file scene/svm.h.

Referenced by compile_type(), stack_clear_offset(), stack_find_offset(), and stack_link().

◆ background

bool SVMCompiler::background

Definition at line 167 of file scene/svm.h.

Referenced by SVMShaderManager::device_update_shader(), and SVMCompiler().

◆ bump_state_offset

SVMStackOffset SVMCompiler::bump_state_offset
protected

Definition at line 288 of file scene/svm.h.

Referenced by compile_type(), get_bump_state_offset(), and SVMCompiler().

◆ compile_failed

bool SVMCompiler::compile_failed
protected

Definition at line 289 of file scene/svm.h.

Referenced by compile_type(), stack_find_offset(), and SVMCompiler().

◆ current_graph

ShaderGraph* SVMCompiler::current_graph

Definition at line 165 of file scene/svm.h.

Referenced by compile_type(), SVMCompiler(), and ImageTextureNode::update_images().

◆ current_node

ShaderNode* SVMCompiler::current_node

◆ current_shader

Shader* SVMCompiler::current_shader
protected

◆ current_svm_nodes

array<int> SVMCompiler::current_svm_nodes
protected

◆ current_type

ShaderType SVMCompiler::current_type
protected

◆ max_stack_use

int SVMCompiler::max_stack_use
protected

Definition at line 286 of file scene/svm.h.

Referenced by compile(), stack_find_offset(), and SVMCompiler().

◆ mix_weight_offset

SVMStackOffset SVMCompiler::mix_weight_offset
protected

Definition at line 287 of file scene/svm.h.

Referenced by closure_mix_weight_offset(), generate_closure_node(), and SVMCompiler().

◆ progress

Progress& SVMCompiler::progress

◆ scene

◆ svm_node_types_used

std::atomic_int* SVMCompiler::svm_node_types_used
protected

Definition at line 281 of file scene/svm.h.

Referenced by add_node(), add_node(), compile(), and SVMCompiler().


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