VOP_CodeGenerator Class Reference

#include <VOP_CodeGenerator.h>

List of all members.

Classes

struct  VOP_CodeCacheData

Public Member Functions

 VOP_CodeGenerator (OP_Network *owner, VOP_LanguageContextTypeList *context_type, int mininputs, int maxinputs)
virtual ~VOP_CodeGenerator (void)
OP_OperatorFiltergetOperatorFilter ()
UT_ErrorManagergetErrorManager ()
void beforeAddNode (OP_Node *node)
void afterAddNode (OP_Node *node)
void appendCompileErrors (OP_NodeInfoParms &info, bool addseparator) const
void resetTables (VOP_Node *node)
void ownerChanged (OP_EventType reason, void *data)
void ownerFinishedLoadingNetwork ()
void generateVopErrors ()
bool getVariableString (int index, UT_String &value)
void updateExportedParameters ()
void updateExportedParameterLayout (const PI_EditScriptedParms &new_parm_layout, const PI_OldParms &old_parms, bool apply_changes_to_parm_vops=false)
void getExportedParameterLayout (PI_EditScriptedParms &parm_layout, bool use_incoming_layout=false)
const char * getEnglishName ()
const char * getFunctionPath (UT_WorkBuffer &storage) const
int getMinimumInputs () const
int getMaximumInputs () const
void getInternalOperatorInfo (OP_OTLDefinition &info)
void getInternalScriptDefinition (UT_String &definition)
bool canGenerateCode (VOP_Type shader_type) const
 Returns ture if the generator can generate code for the given type.
void setVexCodeDirty ()
bool outputVexCode (ostream &os, const char *shadername, VOP_ContextType context_type=VOP_CONTEXT_TYPE_INVALID)
void outputVflCode (ostream &os, const char *shadername, VOP_ContextType context_type=VOP_CONTEXT_TYPE_INVALID, bool skipheader=false, const char *output_node_name=NULL)
int getCachedCodeTimeStamp (VOP_ContextType context_type) const
void outputExportedParameterLayout (ostream &os)
 Output the dialog script of the exported parameter layout.
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 getParameterNodes (VOP_CodeParmList &list, bool includeInvisible)
void getOutputNodes (VOP_NodeList &outputs) const
VOP_CollectgetCollectNode () const
 Return the collection VOP (or NULL if there is no collection).
VOP_NodegetEncapsulatedShader (VOP_ContextType context) const
bool hasParmNode (const char *parm_name) const
VOP_ParmGeneratorgetParmNode (const char *parm_name) const
const char * getParmName (int node_id) const
const char * getCompiler (UT_String &compiler, fpreal now, const char *defcompiler)
const char * getCompiler (UT_WorkBuffer &wbuf, fpreal now, const char *defcompiler)
bool getCompilerErrors (UT_String *errors) const
const VOP_LanguagegetLanguage () const
 Get the VOP language generated by this code generator.
const VOP_LanguageContextTypeListgetLanguageContextTypeList () const
VOP_LanguageType getLanguageType () const
 Returs a language for which this generator produces code.
bool isSingleContextType () const
bool getOwnerHasParameters () const
VOP_ContextType getVopContextType () const
VEX_ContextType getVexContextType () const
RSL_ContextType getRslContextType () const
VOP_CodeCompilerArgsgetCompilerArgs ()
 Returns the compiler arguments.
void setLockedCompiledCode (const char *code, VOP_ContextType context_type)
void setLockedCompiledDs (const char *ds)
VEX_ContextType pickVexContextType (VOP_ContextType context_type) const
RSL_ContextType pickRslContextType (VOP_ContextType context_type) const
VOP_ContextType pickContextType (VOP_ContextType context_type) const
VOP_NodegetProcedural (VOP_Type interpret_type) const
void getPropertiesNodes (VOP_NodeList &properties)
 Gathers all the rendering properties nodes.
const VOP_CodeParmListgetCodeParmList () const
bool isCompiled (VOP_ContextType context_type)
int beginUpdate ()
void endUpdate (int update_level)
void clearAllUpdateFlags ()
void setNeedsErrorUpdate ()
void setNeedsParmUpdate ()
void setNeedsCodeUpdate ()
void performFullUpdate ()
void setContextParmTagDirty ()
bool isContextParmTagDirty () const
const char * getFunctionName (UT_WorkBuffer &storage) const
const char * getInternalFunctionName (UT_WorkBuffer &storage) const

Static Public Member Functions

static VOP_CodeGeneratorfindCodeGenerator (const OP_Node *node)
static void getRegisteredRslContexts (UT_RefArray< RSL_ContextType > &context_types)
 Obtains a list of known RSL context types (surface, displacement, etc).
static const char * getRslContextName (RSL_ContextType context_type)
 Returns a name (token) for a given type.
static RSL_ContextType getRslContextTypeFromName (const char *name)
 Returns a context type based on context name (token).
static const char * getRslContextLabel (RSL_ContextType context_type)
 Returns a context label token for a given type.
static void installCommands ()
static bool convertVopOpToVopOpType (OP_Node *node, UT_String &err)
static bool forceCompile (OP_Node *node)
static int forceCompile (void *data, int, fpreal, const PRM_Template *)

Static Public Attributes

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


Detailed Description

Examples:

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

Definition at line 295 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:
owner The network based on which the code is generated (whose outupt node is used during code generation, etc)
context_type A 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.
mininputs Minimum number of inputs to the owner
maxinputs Maximum number of input to the owner

virtual VOP_CodeGenerator::~VOP_CodeGenerator ( void   )  [virtual]


Member Function Documentation

void VOP_CodeGenerator::afterAddNode ( OP_Node node  ) 

Examples:
SOP/SOP_PrimVOP.C.

void VOP_CodeGenerator::appendCompileErrors ( OP_NodeInfoParms info,
bool  addseparator 
) const

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 (errors_needs_to_update) codegenerator->setNeedsErrorUpdate(); ... if (parm_needs_to_update) codegenerator->setNeedsParmUpdate(); ... 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::clearAllUpdateFlags (  )  [inline]

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

Definition at line 346 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 (errors_needs_to_update) codegenerator->setNeedsErrorUpdate(); ... if (parm_needs_to_update) codegenerator->setNeedsParmUpdate(); ... if (code_needs_to_update) codegenerator->setNeedsCodeUpdate(); ... codegenerator->endUpdate(update_id);

Examples:
SOP/SOP_PrimVOP.C.

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 int VOP_CodeGenerator::forceCompile ( void *  data,
int  ,
fpreal  ,
const PRM_Template  
) [static]

static bool VOP_CodeGenerator::forceCompile ( OP_Node node  )  [static]

Examples:
SOP/SOP_PrimVOP.C.

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 (  ) 

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

const VOP_CodeParmList& VOP_CodeGenerator::getCodeParmList (  )  const [inline]

Definition at line 641 of file VOP_CodeGenerator.h.

VOP_Collect* VOP_CodeGenerator::getCollectNode (  )  const

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

const char* VOP_CodeGenerator::getCompiler ( UT_WorkBuffer wbuf,
fpreal  now,
const char *  defcompiler 
)

const char* VOP_CodeGenerator::getCompiler ( UT_String compiler,
fpreal  now,
const char *  defcompiler 
)

VOP_CodeCompilerArgs* VOP_CodeGenerator::getCompilerArgs (  )  [inline]

Returns the compiler arguments.

Definition at line 569 of file VOP_CodeGenerator.h.

bool VOP_CodeGenerator::getCompilerErrors ( UT_String errors  )  const

Get a string containing the errors from our last compile. 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 (  ) 

void VOP_CodeGenerator::getExportedParameterLayout ( PI_EditScriptedParms parm_layout,
bool  use_incoming_layout = false 
)

Return the definition and layout of the parameters that are exported by the VOP network. The layout can contain a mix of exported and regular parameters.

You can optionally set `use_incoming_layout` to true if you want to use the layout already defined by `parm_layout` instead of the parameter layout stored on the owner node. In that case, the exported parameter definitions are merged into the incoming layout with new parameters being added to the end.

const char* VOP_CodeGenerator::getFunctionName ( UT_WorkBuffer storage  )  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_WorkBuffer storage  )  const

The function path is the leading path to the shader

const char* VOP_CodeGenerator::getInternalFunctionName ( UT_WorkBuffer storage  )  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  ) 

void VOP_CodeGenerator::getInternalScriptDefinition ( UT_String definition  ) 

const VOP_Language* VOP_CodeGenerator::getLanguage (  )  const [inline]

Get the VOP language generated by this code generator.

Definition at line 529 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 535 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

OP_OperatorFilter* VOP_CodeGenerator::getOperatorFilter (  ) 

Examples:
SOP/SOP_PrimVOP.C.

void VOP_CodeGenerator::getOutputNodes ( VOP_NodeList outputs  )  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 547 of file VOP_CodeGenerator.h.

void VOP_CodeGenerator::getParameterNodes ( VOP_CodeParmList list,
bool  includeInvisible 
)

const char* VOP_CodeGenerator::getParmName ( int  node_id  )  const

Return the exported parameter name associated with the specified node. Return NULL if the given node is not a parameter generator VOP for this code generator.

VOP_ParmGenerator* VOP_CodeGenerator::getParmNode ( const char *  parm_name  )  const

Return a pointer to the Parameter VOP node that corresponds to the given parameter name. Return NULL if no such node exists.

VOP_Node* VOP_CodeGenerator::getProcedural ( VOP_Type  interpret_type  )  const

void VOP_CodeGenerator::getPropertiesNodes ( VOP_NodeList properties  ) 

Gathers all the rendering properties nodes.

static void VOP_CodeGenerator::getRegisteredRslContexts ( UT_RefArray< RSL_ContextType > &  context_types  )  [static]

Obtains a list of known RSL context types (surface, displacement, etc).

static const char* VOP_CodeGenerator::getRslContextLabel ( RSL_ContextType  context_type  )  [static]

Returns a context label token for a given type.

static const char* VOP_CodeGenerator::getRslContextName ( RSL_ContextType  context_type  )  [static]

Returns a name (token) for a given type.

RSL_ContextType VOP_CodeGenerator::getRslContextType (  )  const

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

static RSL_ContextType VOP_CodeGenerator::getRslContextTypeFromName ( const char *  name  )  [static]

Returns a context type based on context name (token).

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.

bool VOP_CodeGenerator::hasParmNode ( const char *  parm_name  )  const

Return true if the owner has a node which defines a parameter with the given name.

static void VOP_CodeGenerator::installCommands (  )  [static]

bool VOP_CodeGenerator::isCompiled ( VOP_ContextType  context_type  )  [inline]

Definition at line 644 of file VOP_CodeGenerator.h.

bool VOP_CodeGenerator::isContextParmTagDirty (  )  const [inline]

A flag to indicate if the cached parameters may have outdated parm tag that specifies parameter's shading contexts. Only shop clerk is interested in this tag and currently manages the updating itself.

Definition at line 385 of file VOP_CodeGenerator.h.

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.

void VOP_CodeGenerator::outputExportedParameterLayout ( ostream &  os  ) 

Output the dialog script of the exported parameter layout.

bool VOP_CodeGenerator::outputVexCode ( ostream &  os,
const char *  shadername,
VOP_ContextType  context_type = VOP_CONTEXT_TYPE_INVALID 
)

void VOP_CodeGenerator::outputVflCode ( ostream &  os,
const char *  shadername,
VOP_ContextType  context_type = VOP_CONTEXT_TYPE_INVALID,
bool  skipheader = false,
const char *  output_node_name = NULL 
)

Generates a VFL code and writes it to the os.

Parameters:
shadername The name of the shader function.
context_type For multi-context materials, this is the shader context for which to generate code.
skipheader If true the file comment will be skpped; the file comment contains info about original node, file name, and generation time stamp.
output_node_name Optional, 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.

void VOP_CodeGenerator::performFullUpdate (  )  [inline]

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

Definition at line 367 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.

RSL_ContextType VOP_CodeGenerator::pickRslContextType ( VOP_ContextType  context_type  )  const

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

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::setContextParmTagDirty (  )  [inline]

A flag to indicate if the cached parameters may have outdated parm tag that specifies parameter's shading contexts. Only shop clerk is interested in this tag and currently manages the updating itself.

Definition at line 381 of file VOP_CodeGenerator.h.

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

void VOP_CodeGenerator::setLockedCompiledDs ( const char *  ds  ) 

void VOP_CodeGenerator::setNeedsCodeUpdate (  )  [inline]

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

Definition at line 362 of file VOP_CodeGenerator.h.

void VOP_CodeGenerator::setNeedsErrorUpdate (  )  [inline]

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

Definition at line 352 of file VOP_CodeGenerator.h.

void VOP_CodeGenerator::setNeedsParmUpdate (  )  [inline]

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

Definition at line 357 of file VOP_CodeGenerator.h.

void VOP_CodeGenerator::setVexCodeDirty (  ) 

void VOP_CodeGenerator::updateExportedParameterLayout ( const PI_EditScriptedParms new_parm_layout,
const PI_OldParms old_parms,
bool  apply_changes_to_parm_vops = false 
)

Update the layout of the exported parameters using the layout, `new_parm_layout`, that is passed in. The new layout is applied to the owner node's parameter layout and can contain a mix of exported parameters and regular parameters. Use `old_parms` to supply a list of parameters that are to be renamed/deleted from the layout. Set `apply_changes_to_parm_vops` to true if you want to apply the changes from `old_parms` to the defining Parameter VOPs.

void VOP_CodeGenerator::updateExportedParameters (  ) 

Update the definition and layout of the parameters exported by the VOP network. Exported parameters are ones that are defined by Parameter VOPs in the network. The parameter layout is stored in the owner node's parameter layout.


Member Data Documentation

Examples:
SOP/SOP_PrimVOP.C.

Definition at line 596 of file VOP_CodeGenerator.h.

Definition at line 611 of file VOP_CodeGenerator.h.

Examples:
SOP/SOP_PrimVOP.C.

Definition at line 608 of file VOP_CodeGenerator.h.

Definition at line 610 of file VOP_CodeGenerator.h.

Examples:
SOP/SOP_PrimVOP.C.

Definition at line 609 of file VOP_CodeGenerator.h.

Examples:
SOP/SOP_PrimVOP.C.

Definition at line 612 of file VOP_CodeGenerator.h.


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

Generated on Thu Jan 31 00:34:16 2013 for HDK by  doxygen 1.5.9