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

#include <VOP_CodeGenerator.h>

Public Member Functions

 VOP_CodeGenerator (OP_Network *owner, VOP_LanguageContextTypeList *context_type, int mininputs, int maxinputs)
 
virtual ~VOP_CodeGenerator (void)
 
OP_OperatorFiltergetOperatorFilter ()
 
UT_ErrorManagergetErrorManager ()
 
VOP_ExportedParmsManagerexportedParmsManager () const
 Return the exported parameters manager. More...
 
virtual bool hasShaderParameter (const char *parm_name)
 
void beforeAddNode (OP_Node *node)
 
void afterAddNode (OP_Node *node)
 
void resetTables (VOP_Node *node)
 
void ownerChanged (OP_EventType reason, void *data)
 
void ownerFinishedLoadingNetwork ()
 
void generateVopErrors ()
 
bool getVariableString (int index, UT_String &value)
 
const char * getEnglishName ()
 
const char * getFunctionPath (UT_String &name) const
 The function path is the leading path to the shader. More...
 
int getMinimumInputs () const
 
int getMaximumInputs () const
 
void getInternalOperatorInfo (OP_OTLDefinition &info)
 
bool canGenerateCode (VOP_Type shader_type) const
 Returns ture if the generator can generate code for the given type. More...
 
void getAutoShaderTypes (VOP_ShaderTypeList &types) const
 Returns a list of shader types that can be auto-generated for the owner. More...
 
void setVexCodeDirty ()
 
bool outputVexCode (std::ostream &os, const char *shadername, VEX_CodeGenFlags flags=VEX_CG_DEFAULT, VOP_ContextType ctx_type=VOP_CONTEXT_TYPE_INVALID, bool *is_pure_compiled=nullptr, VOP_ShaderSpaceInfo *shader_space=nullptr)
 
bool isVexCodeCached (VOP_ContextType context_type) const
 Determines if the giving context has already been cached. More...
 
virtual bool outputVflCode (std::ostream &os, const char *shadername, VEX_CodeGenFlags flags=VEX_CG_DEFAULT, VOP_ContextType ctx_type=VOP_CONTEXT_TYPE_INVALID, bool skipheader=false, const char *output_node_name=nullptr, VCC_Diagnostics *diag=nullptr, VOP_ShaderSpaceInfo *shader_space=nullptr)
 
bool outputEncapsulatedVflCode (std::ostream &os, VOP_Node *subnet, const char *function_name, VEX_CodeGenFlags flags, VOP_ContextType context_type, bool generate_outer_code)
 Generates a VFL code for a vex function defined by a vop subnet node. More...
 
void getDependencies (VOP_ContextType context_type, UT_StringArray &shader_deps)
 
void addCodeDependency (DEP_MicroNode *target)
 
int getCachedCodeTimeStamp (VOP_ContextType context_type) const
 
bool hasCachedCode () const
 Return true if this code generator has any cached code. More...
 
void generateRslObject (UT_String &ofile, const char *cache_directory, const char *renderer, int major_version, int minor_version, const char *shaderpath, const char *shadername, VOP_ContextType context_type, bool ignore_dirty_flag, UT_String *error_return)
 
void generateOslObject (UT_String &ofile, const char *cache_directory, const char *shaderpath, const char *shadername, VOP_ContextType context_type, bool ignore_dirty_flag, UT_String *error_return)
 
void getClassMethodInfos (UT_Array< VOP_MemberMethodInfo > &infos)
 
void getClassShaderParameterNodes (VOP_NodeList &parms)
 
void getOutputNodes (VOP_NodeList &outputs, VOP_ShaderTypeList *types=nullptr) const
 
VOP_CollectgetCollectNode () const
 Return the collection VOP (or NULL if there is no collection) More...
 
VOP_NodegetEncapsulatedShader (VOP_ContextType context) const
 
const char * getCompiler (UT_String &compiler, fpreal now, const char *defcompiler)
 
const char * getCompiler (UT_WorkBuffer &wbuf, fpreal now, const char *defcompiler)
 
const VOP_LanguagegetLanguage () const
 Get the VOP language generated by this code generator. More...
 
const VOP_LanguageContextTypeListgetLanguageContextTypeList () const
 
VOP_LanguageType getLanguageType () const
 Returs a language for which this generator produces code. More...
 
bool needsToGenerateAutoShader () const
 
bool isSingleContextType () const
 
bool isClassBasedShader () const
 Returns true if this generator produces a class-based shader. More...
 
bool isClassBasedShader (const VOP_CodeGenContext &codegen_ctx) const
 Returns true if the given shader type is class-based. More...
 
void getVopnetTypes (const VOP_ContextTypeList &ctxts, UT_StringArray &vopnet_types)
 Returns a list of vopnet type masks for a given context list. More...
 
bool getOwnerHasParameters () const
 
VOP_ContextType getVopContextType () const
 
VEX_ContextType getVexContextType () const
 
RSL_ContextType getRslContextType () const
 
OSL_ContextType getOslContextType () const
 
VOP_CodeCompilerArgsgetCompilerArgs ()
 Returns the compiler arguments. More...
 
void setLockedCompiledCode (const char *code, VOP_ContextType context_type, bool is_source_code)
 
VEX_ContextType pickVexContextType (VOP_ContextType context_type) const
 
RSL_ContextType pickRslContextType (VOP_ContextType context_type) const
 
OSL_ContextType pickOslContextType (VOP_ContextType context_type) const
 
VOP_ContextType pickContextType (VOP_ContextType context_type) const
 
VOP_NodegetProcedural (VOP_Type interpret_type) const
 
void getVopFunctionArgInfosFromExports (UT_Array< VOP_FunctionArgInfo > &arg_infos, VOP_Type shader_type)
 Obtains the export variables that don't have explicit output connectors. More...
 
void getPropertiesNodes (VOP_NodeList &properties)
 Gathers all the rendering properties nodes. More...
 
OP_NetworkownerNetwork () const
 
VOP_ErrorMicroNodeerrorMicroNode ()
 
bool getNodesForContextOrNodeFunctionVflCode (VOP_NodeList &nodes, VOP_Node *&output_node, const VOP_CodeGenContext &codegen_ctx, VOP_CodeVarMapperContext &varmap_context, const char *output_node_name, bool check_errors, VCC_Diagnostics *diagnostics)
 
bool getNodesForSubnetFunctionVflCode (VOP_NodeList &nodes, const VOP_CodeGenContext &codegen_ctx, VOP_CodeVarMapperContext &varmap_context, VOP_Node *vop_subnet, bool require_context_check)
 
void cleanupNodesForVflCode (VOP_NodeList &nodes)
 
bool needsAutoConvertCleanup () const
 
void setUseIfdefVex (bool flag)
 Controls whether the source code is laced with #ifdef __vex. More...
 
void setOmitPragmas (bool flag)
 Controls whether the source code contains pragmas. More...
 
UT_StringHolder getShaderContextName (VOP_ContextType ctx_type) const
 Obtains the name of the shading context as is used in the language. More...
 
UT_StringHolder getShaderContextFullName (VOP_ContextType ctx_t) const
 
int beginUpdate ()
 
void endUpdate (int update_level)
 
void clearAllUpdateFlags ()
 
void setNeedsCodeUpdate ()
 
const char * getFunctionName (UT_String &name) const
 
const char * getInternalFunctionName (UT_String &name) const
 
bool getGeneratorErrors (UT_String &errors) const
 
bool getGeneratorErrors (UT_String &errors, VOP_ContextType context_type) const
 
bool getGeneratorErrorsAndWarnings (UT_String &msgs) const
 
bool getGeneratorErrorsAndWarnings (UT_String &msgs, VOP_ContextType context_type) const
 
bool getDiagnosticsForNode (VOP_Node *node, VCC_DiagnosticList &list) const
 
void setIsAutoGenerator (bool is_auto)
 
bool isAutoGenerator () const
 
void setIsChangingAutoShader (bool flag)
 
bool getIsChangingAutoShader () const
 

Static Public Member Functions

static VOP_CodeGeneratorfindCodeGenerator (const OP_Node *node)
 
static void installCommands ()
 
static bool convertVopOpToVopOpType (OP_Node *node, UT_String &err)
 
static const char * getDefaultVEXMask ()
 Returns the default VOP mask for VEX. More...
 
static bool forceCompile (OP_Node *node)
 
static int forceCompile (void *data, int, fpreal, const PRM_Template *)
 
static void formatDiagnostic (const VCC_DiagnosticInfo &info, UT_WorkBuffer &str)
 
static UT_StringHolder getShaderContextName (VOP_ContextType ctx_type, VOP_LanguageType lang_type)
 

Static Public Attributes

static CH_LocalVariable theLocalVariables []
 
static PRM_Name theVopCompilerName
 
static PRM_Default theVopCompilerVexDefault
 
static PRM_Default theVopCompilerRslDefault
 
static PRM_Default theVopCompilerOslDefault
 
static PRM_ChoiceList theVopCompilerChoices
 
static PRM_Name theVopForceCompileName
 

Detailed Description

Examples:
SOP/SOP_PrimVOP.C, and SOP/SOP_PrimVOP.h.

Definition at line 99 of file VOP_CodeGenerator.h.

Constructor & Destructor Documentation

VOP_CodeGenerator::VOP_CodeGenerator ( OP_Network owner,
VOP_LanguageContextTypeList context_type,
int  mininputs,
int  maxinputs 
)

Constructor

Parameters
ownerThe network based on which the code is generated (whose outupt node is used during code generation, etc)
context_typeA list of context type for a specific language, which the generator will generate code for. For single-context shaders, the list will have a single entry, while multi-context shaders will have several. The code generator will take ownership of that context type list object and will delete it in the destructor.
mininputsMinimum number of inputs to the owner
maxinputsMaximum number of input to the owner
virtual VOP_CodeGenerator::~VOP_CodeGenerator ( void  )
virtual

Member Function Documentation

void VOP_CodeGenerator::addCodeDependency ( DEP_MicroNode target)
inline

On the given micronode, add an extra input to our code micro node so it gets reset everytime we are dirtied.

Definition at line 251 of file VOP_CodeGenerator.h.

void VOP_CodeGenerator::afterAddNode ( OP_Node node)
Examples:
SOP/SOP_PrimVOP.C.
void VOP_CodeGenerator::beforeAddNode ( OP_Node node)
Examples:
SOP/SOP_PrimVOP.C.
int VOP_CodeGenerator::beginUpdate ( )

Functions for controlling when a code generator is updated. The code pattern is something like this: int update_id = codegenerator->beginUpdate(); ... if (code_needs_to_update) codegenerator->setNeedsCodeUpdate(); ... codegenerator->endUpdate(update_id);

Examples:
SOP/SOP_PrimVOP.C.
bool VOP_CodeGenerator::canGenerateCode ( VOP_Type  shader_type) const

Returns ture if the generator can generate code for the given type.

void VOP_CodeGenerator::cleanupNodesForVflCode ( VOP_NodeList nodes)

Clean up the list obtained with getNodesForShaderVflCode() or getNodesForSubnetFunctionVflCode()

void VOP_CodeGenerator::clearAllUpdateFlags ( )
inline

Functions for controlling when a code generator is updated. The code pattern is something like this: int update_id = codegenerator->beginUpdate(); ... if (code_needs_to_update) codegenerator->setNeedsCodeUpdate(); ... codegenerator->endUpdate(update_id);

Definition at line 147 of file VOP_CodeGenerator.h.

static bool VOP_CodeGenerator::convertVopOpToVopOpType ( OP_Node node,
UT_String err 
)
static
void VOP_CodeGenerator::endUpdate ( int  update_level)

Functions for controlling when a code generator is updated. The code pattern is something like this: int update_id = codegenerator->beginUpdate(); ... if (code_needs_to_update) codegenerator->setNeedsCodeUpdate(); ... codegenerator->endUpdate(update_id);

Examples:
SOP/SOP_PrimVOP.C.
VOP_ErrorMicroNode& VOP_CodeGenerator::errorMicroNode ( )
inline

Return the micro-node representing the error state. The micro-node will signal if we transition from clean -> error, error -> error, and error -> clean.

Definition at line 461 of file VOP_CodeGenerator.h.

VOP_ExportedParmsManager* VOP_CodeGenerator::exportedParmsManager ( ) const
inline

Return the exported parameters manager.

Examples:
SOP/SOP_PrimVOP.h.

Definition at line 124 of file VOP_CodeGenerator.h.

static VOP_CodeGenerator* VOP_CodeGenerator::findCodeGenerator ( const OP_Node node)
static

Utility function to get a code generator corresponding to the node. Returns own code generator if it exists, or creator's code generator.

static bool VOP_CodeGenerator::forceCompile ( OP_Node node)
static
Examples:
SOP/SOP_PrimVOP.C.
static int VOP_CodeGenerator::forceCompile ( void data,
int  ,
fpreal  ,
const PRM_Template  
)
static
static void VOP_CodeGenerator::formatDiagnostic ( const VCC_DiagnosticInfo &  info,
UT_WorkBuffer str 
)
static
void VOP_CodeGenerator::generateOslObject ( UT_String ofile,
const char *  cache_directory,
const char *  shaderpath,
const char *  shadername,
VOP_ContextType  context_type,
bool  ignore_dirty_flag,
UT_String error_return 
)
void VOP_CodeGenerator::generateRslObject ( UT_String ofile,
const char *  cache_directory,
const char *  renderer,
int  major_version,
int  minor_version,
const char *  shaderpath,
const char *  shadername,
VOP_ContextType  context_type,
bool  ignore_dirty_flag,
UT_String error_return 
)
void VOP_CodeGenerator::generateVopErrors ( )
void VOP_CodeGenerator::getAutoShaderTypes ( VOP_ShaderTypeList types) const

Returns a list of shader types that can be auto-generated for the owner.

int VOP_CodeGenerator::getCachedCodeTimeStamp ( VOP_ContextType  context_type) const

Return the time stamp from when VEX code was last generated or -1 if no cached code exists

void VOP_CodeGenerator::getClassMethodInfos ( UT_Array< VOP_MemberMethodInfo > &  infos)
void VOP_CodeGenerator::getClassShaderParameterNodes ( VOP_NodeList parms)
VOP_Collect* VOP_CodeGenerator::getCollectNode ( ) const

Return the collection VOP (or NULL if there is no collection)

const char* VOP_CodeGenerator::getCompiler ( UT_String compiler,
fpreal  now,
const char *  defcompiler 
)
const char* VOP_CodeGenerator::getCompiler ( UT_WorkBuffer wbuf,
fpreal  now,
const char *  defcompiler 
)
VOP_CodeCompilerArgs* VOP_CodeGenerator::getCompilerArgs ( )
inline

Returns the compiler arguments.

Definition at line 388 of file VOP_CodeGenerator.h.

static const char* VOP_CodeGenerator::getDefaultVEXMask ( )
static

Returns the default VOP mask for VEX.

void VOP_CodeGenerator::getDependencies ( VOP_ContextType  context_type,
UT_StringArray shader_deps 
)

Returns a list of dependencies, if the shader handled by this code generator is an encapsulated shader (cached code).

bool VOP_CodeGenerator::getDiagnosticsForNode ( VOP_Node node,
VCC_DiagnosticList list 
) const

Get a string containing the errors or warnings from our last vex code generation (including source code generation and compilation). Returns true if there were any errors.

VOP_Node* VOP_CodeGenerator::getEncapsulatedShader ( VOP_ContextType  context) const

Return the code generating encapsulated shader for the given context (or NULL).

const char* VOP_CodeGenerator::getEnglishName ( )
UT_ErrorManager& VOP_CodeGenerator::getErrorManager ( )
const char* VOP_CodeGenerator::getFunctionName ( UT_String name) const

The function name is mangled for some renderers (i.e. RSL) since basing the function name on the node name is not safe. However, some places require the node name – unmangled (i.e. dialog scripts).

const char* VOP_CodeGenerator::getFunctionPath ( UT_String name) const

The function path is the leading path to the shader.

bool VOP_CodeGenerator::getGeneratorErrors ( UT_String errors) const

Get a string containing the errors or warnings from our last vex code generation (including source code generation and compilation). Returns true if there were any errors.

bool VOP_CodeGenerator::getGeneratorErrors ( UT_String errors,
VOP_ContextType  context_type 
) const

Get a string containing the errors or warnings from our last vex code generation (including source code generation and compilation). Returns true if there were any errors.

bool VOP_CodeGenerator::getGeneratorErrorsAndWarnings ( UT_String msgs) const

Get a string containing the errors or warnings from our last vex code generation (including source code generation and compilation). Returns true if there were any errors.

bool VOP_CodeGenerator::getGeneratorErrorsAndWarnings ( UT_String msgs,
VOP_ContextType  context_type 
) const

Get a string containing the errors or warnings from our last vex code generation (including source code generation and compilation). Returns true if there were any errors.

const char* VOP_CodeGenerator::getInternalFunctionName ( UT_String name) const

The function name is mangled for some renderers (i.e. RSL) since basing the function name on the node name is not safe. However, some places require the node name – unmangled (i.e. dialog scripts).

void VOP_CodeGenerator::getInternalOperatorInfo ( OP_OTLDefinition info)
bool VOP_CodeGenerator::getIsChangingAutoShader ( ) const
inline

Methods for marking code path related to adding and deleting temporary nodes in auto-shader wrappers.

Definition at line 524 of file VOP_CodeGenerator.h.

const VOP_Language* VOP_CodeGenerator::getLanguage ( ) const
inline

Get the VOP language generated by this code generator.

Definition at line 321 of file VOP_CodeGenerator.h.

const VOP_LanguageContextTypeList* VOP_CodeGenerator::getLanguageContextTypeList ( ) const
inline

Get the object representing the list of shader contexts (surface, displacement, etc) supported by this generator. The returned object also describes the language type supported by this generator.

Definition at line 327 of file VOP_CodeGenerator.h.

VOP_LanguageType VOP_CodeGenerator::getLanguageType ( ) const

Returs a language for which this generator produces code.

int VOP_CodeGenerator::getMaximumInputs ( ) const
int VOP_CodeGenerator::getMinimumInputs ( ) const
bool VOP_CodeGenerator::getNodesForContextOrNodeFunctionVflCode ( VOP_NodeList nodes,
VOP_Node *&  output_node,
const VOP_CodeGenContext codegen_ctx,
VOP_CodeVarMapperContext varmap_context,
const char *  output_node_name,
bool  check_errors,
VCC_Diagnostics *  diagnostics 
)

Get a list of all vop nodes participating in the shader. The list is sorted according to order in which the vfl code should be generated. If 'check_errors' is true, node error checking is performed and if any error is encountered, the method will return false (and the node list may be incomplete). If this argument is false, the method does not check errors and always returns true and the list of nodes is complete. NB: when nodes a no longer needed, use cleanupNodesForShaderOutput() to clean up the list of temporary nodes this method may create.

bool VOP_CodeGenerator::getNodesForSubnetFunctionVflCode ( VOP_NodeList nodes,
const VOP_CodeGenContext codegen_ctx,
VOP_CodeVarMapperContext varmap_context,
VOP_Node vop_subnet,
bool  require_context_check 
)

Get a list of all vop nodes participating in the function code defined by a vop subnet. The list is sorted according to order in which the vfl code should be generated. NB: when nodes a no longer needed, use cleanupNodesForShaderOutput() to clean up the list of temporary nodes this method may create.

OP_OperatorFilter* VOP_CodeGenerator::getOperatorFilter ( )
Examples:
SOP/SOP_PrimVOP.C.
OSL_ContextType VOP_CodeGenerator::getOslContextType ( ) const
void VOP_CodeGenerator::getOutputNodes ( VOP_NodeList outputs,
VOP_ShaderTypeList types = nullptr 
) const
bool VOP_CodeGenerator::getOwnerHasParameters ( ) const
inline

Returns true if the owner of the code generator displays parameters. This is currently true for VOPNET_Nodes.

Definition at line 370 of file VOP_CodeGenerator.h.

VOP_Node* VOP_CodeGenerator::getProcedural ( VOP_Type  interpret_type) const
void VOP_CodeGenerator::getPropertiesNodes ( VOP_NodeList properties)

Gathers all the rendering properties nodes.

RSL_ContextType VOP_CodeGenerator::getRslContextType ( ) const
UT_StringHolder VOP_CodeGenerator::getShaderContextFullName ( VOP_ContextType  ctx_t) const

Obtains the name of the shading context, which includes node path prefix if it's an auto shader.

UT_StringHolder VOP_CodeGenerator::getShaderContextName ( VOP_ContextType  ctx_type) const

Obtains the name of the shading context as is used in the language.

static UT_StringHolder VOP_CodeGenerator::getShaderContextName ( VOP_ContextType  ctx_type,
VOP_LanguageType  lang_type 
)
static
bool VOP_CodeGenerator::getVariableString ( int  index,
UT_String value 
)
Examples:
SOP/SOP_PrimVOP.C.
VEX_ContextType VOP_CodeGenerator::getVexContextType ( ) const

Determine the VEX context type for single-context type vopnet generator. For generator of a multi-context vopnet (or for RSL vopnet) returns VEX_INVALID_CONTEXT, because the specific VEX context cannot be reliably and unambiguously determined.

VOP_ContextType VOP_CodeGenerator::getVopContextType ( ) const

Determine the VOP context type for single-context type vopnet generator. For generator of a multi-context vopnet returns VOP_CONTEXT_TYPE_INVALID, because the specific VOP context cannot be reliably and unambiguously determined.

void VOP_CodeGenerator::getVopFunctionArgInfosFromExports ( UT_Array< VOP_FunctionArgInfo > &  arg_infos,
VOP_Type  shader_type 
)

Obtains the export variables that don't have explicit output connectors.

void VOP_CodeGenerator::getVopnetTypes ( const VOP_ContextTypeList ctxts,
UT_StringArray vopnet_types 
)

Returns a list of vopnet type masks for a given context list.

bool VOP_CodeGenerator::hasCachedCode ( ) const

Return true if this code generator has any cached code.

virtual bool VOP_CodeGenerator::hasShaderParameter ( const char *  parm_name)
virtual
Examples:
SOP/SOP_PrimVOP.C.
static void VOP_CodeGenerator::installCommands ( )
static
bool VOP_CodeGenerator::isAutoGenerator ( ) const
inline

An automatic code generator is created by default for a VOP, when a VOP is created in a Shader Network container. The automatic generator provides a code for a temporary shader consisting of that VOP and any of its input chains.

Definition at line 340 of file VOP_CodeGenerator.h.

bool VOP_CodeGenerator::isClassBasedShader ( ) const

Returns true if this generator produces a class-based shader.

bool VOP_CodeGenerator::isClassBasedShader ( const VOP_CodeGenContext codegen_ctx) const

Returns true if the given shader type is class-based.

bool VOP_CodeGenerator::isSingleContextType ( ) const

Returns true if it is a single-context vopnet that this generator produces code for. Otherwise (ie, multi-context) returns false.

bool VOP_CodeGenerator::isVexCodeCached ( VOP_ContextType  context_type) const
inline

Determines if the giving context has already been cached.

Definition at line 203 of file VOP_CodeGenerator.h.

bool VOP_CodeGenerator::needsAutoConvertCleanup ( ) const
inline

Definition at line 500 of file VOP_CodeGenerator.h.

bool VOP_CodeGenerator::needsToGenerateAutoShader ( ) const

Returns true if the generator should generate temporary, automatic, adhoc shader for the owner node, when that node is assigned as a shader. Such code is needed for VOPs directly inside a Shader Network container, when they are not true shaders themselves, or when a connected input implies a composite shder generation. In other cases (eg an unconnected VOP that represents an external shader, or a RIS shader), there is no need for temp shader code gen.

bool VOP_CodeGenerator::outputEncapsulatedVflCode ( std::ostream &  os,
VOP_Node subnet,
const char *  function_name,
VEX_CodeGenFlags  flags,
VOP_ContextType  context_type,
bool  generate_outer_code 
)

Generates a VFL code for a vex function defined by a vop subnet node.

bool VOP_CodeGenerator::outputVexCode ( std::ostream &  os,
const char *  shadername,
VEX_CodeGenFlags  flags = VEX_CG_DEFAULT,
VOP_ContextType  ctx_type = VOP_CONTEXT_TYPE_INVALID,
bool *  is_pure_compiled = nullptr,
VOP_ShaderSpaceInfo shader_space = nullptr 
)

Outputs vex code.

Parameters
[out]osStream to write the vex code to.
[in]shadernameSpecifies the name that should be used for the generated vex code.
[in]context_typeSpecifies the shading context for which to generate vex code; relevant only for multi-context vopnets.
[out]is_pure_compiledSet to true if the vex code comes from a locked code source (i.e., a CPIO packet for the node saved in the hip file), which indicates the node has been compiled out.
virtual bool VOP_CodeGenerator::outputVflCode ( std::ostream &  os,
const char *  shadername,
VEX_CodeGenFlags  flags = VEX_CG_DEFAULT,
VOP_ContextType  ctx_type = VOP_CONTEXT_TYPE_INVALID,
bool  skipheader = false,
const char *  output_node_name = nullptr,
VCC_Diagnostics *  diag = nullptr,
VOP_ShaderSpaceInfo shader_space = nullptr 
)
virtual

Generates a VFL code and writes it to the os.

Parameters
shadernameThe name of the shader function.
flagsThe code generation flags.
context_typeFor multi-context materials, this is the shader context for which to generate code.
skipheaderIf true the file comment will be skpped; the file comment contains info about original node, file name, and generation time stamp.
output_node_nameOptional, this is a hint that specifies the name of the output node for which to generate the code. If the node by this name is found and it supports the context type (if given), then it is used for gathering nodes that participate in VFL code generation. If the node by this name cannot be used, then a Collect VOP node will be used. And if there is no collect node a (arbitrary) output node supporting the context type will be used.
void VOP_CodeGenerator::ownerChanged ( OP_EventType  reason,
void data 
)
Examples:
SOP/SOP_PrimVOP.C.
void VOP_CodeGenerator::ownerFinishedLoadingNetwork ( )
Examples:
SOP/SOP_PrimVOP.C.
OP_Network* VOP_CodeGenerator::ownerNetwork ( ) const
inline

Definition at line 455 of file VOP_CodeGenerator.h.

VOP_ContextType VOP_CodeGenerator::pickContextType ( VOP_ContextType  context_type) const

Determines the vop context (ie encode vex or rsl context type). In single-context vop, returns a vex/rsl context type (encoded as vop type) intrinsic to that vop. In multi-context vop, returns the vop type based passed as an argument.

OSL_ContextType VOP_CodeGenerator::pickOslContextType ( VOP_ContextType  context_type) const
RSL_ContextType VOP_CodeGenerator::pickRslContextType ( VOP_ContextType  context_type) const
VEX_ContextType VOP_CodeGenerator::pickVexContextType ( VOP_ContextType  context_type) const

Determines the vex context. In single-context vop, returns a vex type intrinsic to that vop. In multi-context vop, returns the vex type based on context_type passed as an argument.

void VOP_CodeGenerator::resetTables ( VOP_Node node)

Sometimes a VOP needs to change its variable tables (i.e. an encapsulated shader)

void VOP_CodeGenerator::setIsAutoGenerator ( bool  is_auto)
inline

An automatic code generator is created by default for a VOP, when a VOP is created in a Shader Network container. The automatic generator provides a code for a temporary shader consisting of that VOP and any of its input chains.

Definition at line 338 of file VOP_CodeGenerator.h.

void VOP_CodeGenerator::setIsChangingAutoShader ( bool  flag)
inline

Methods for marking code path related to adding and deleting temporary nodes in auto-shader wrappers.

Definition at line 522 of file VOP_CodeGenerator.h.

void VOP_CodeGenerator::setLockedCompiledCode ( const char *  code,
VOP_ContextType  context_type,
bool  is_source_code 
)

Set the locked compiled code. When set, the locked code causes the code generator to ignore the VOP nodes in the owner network and always return the locked value.

void VOP_CodeGenerator::setNeedsCodeUpdate ( )

Functions for controlling when a code generator is updated. The code pattern is something like this: int update_id = codegenerator->beginUpdate(); ... if (code_needs_to_update) codegenerator->setNeedsCodeUpdate(); ... codegenerator->endUpdate(update_id);

void VOP_CodeGenerator::setOmitPragmas ( bool  flag)
inline

Controls whether the source code contains pragmas.

Definition at line 508 of file VOP_CodeGenerator.h.

void VOP_CodeGenerator::setUseIfdefVex ( bool  flag)
inline

Controls whether the source code is laced with #ifdef __vex.

Definition at line 504 of file VOP_CodeGenerator.h.

void VOP_CodeGenerator::setVexCodeDirty ( )

Member Data Documentation

CH_LocalVariable VOP_CodeGenerator::theLocalVariables[]
static
Examples:
SOP/SOP_PrimVOP.C.

Definition at line 404 of file VOP_CodeGenerator.h.

PRM_ChoiceList VOP_CodeGenerator::theVopCompilerChoices
static

Definition at line 423 of file VOP_CodeGenerator.h.

PRM_Name VOP_CodeGenerator::theVopCompilerName
static
Examples:
SOP/SOP_PrimVOP.C.

Definition at line 419 of file VOP_CodeGenerator.h.

PRM_Default VOP_CodeGenerator::theVopCompilerOslDefault
static

Definition at line 422 of file VOP_CodeGenerator.h.

PRM_Default VOP_CodeGenerator::theVopCompilerRslDefault
static

Definition at line 421 of file VOP_CodeGenerator.h.

PRM_Default VOP_CodeGenerator::theVopCompilerVexDefault
static
Examples:
SOP/SOP_PrimVOP.C.

Definition at line 420 of file VOP_CodeGenerator.h.

PRM_Name VOP_CodeGenerator::theVopForceCompileName
static
Examples:
SOP/SOP_PrimVOP.C.

Definition at line 424 of file VOP_CodeGenerator.h.


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