8 #ifndef __VOP_CodeGenerator_h__ 
    9 #define __VOP_CodeGenerator_h__ 
   30 #define VOP_MININPUTS_NAME      "mininputs" 
   31 #define VOP_MAXINPUTS_NAME      "maxinputs" 
   38 #define VOP_AUTO_SHADER_PREFIX          "_auto_" 
   39 #define VOP_AUTO_SHADER_PREFIX_LEN      6 
   40 #define VOP_AUTO_SHADER_FN_PREFIX       "auto_" 
   41 #define VOP_AUTO_SHADER_FN_PREFIX_LEN   5 
   54 class VOP_VopTypeDefiner;
 
   56 class VOP_ObjectCodeArgs;
 
   59 class VCC_Diagnostics;
 
   60 class VCC_DiagnosticInfo;
 
   66 class vop_CodeCacheData;
 
   67 class vop_CodeGenOutputContext;
 
   76                     { 
return "VOP_SnippetMicroNode"; }
 
  129                                     { 
return myExportedParmsMgr; }
 
  130     virtual bool         hasShaderParameter(
const char *parm_name);
 
  132     void                 beforeAddNode(
OP_Node *node);
 
  133     void                 afterAddNode(
OP_Node *node);
 
  149     void                endUpdate(
int update_level);
 
  153                             myNeedsCodeUpdate = 
false;
 
  155     void                setNeedsCodeUpdate();
 
  159     void                 ownerFinishedLoadingNetwork();
 
  160     void                 generateVopErrors();
 
  164     const char          *getEnglishName();
 
  177     int                  getMinimumInputs() 
const;
 
  178     int                  getMaximumInputs() 
const;
 
  182     bool                 canGenerateCode( 
VOP_Type shader_type ) 
const;
 
  187     void                 setVexCodeDirty();
 
  200     bool                 outputVexCode(std::ostream &os, 
const char *shadername,
 
  203                             bool *is_pure_compiled = 
nullptr,
 
  209         return findCachedCode(context_type) ? 
true : 
false;
 
  229     virtual bool         outputVflCode(
 
  230                             std::ostream &os, 
const char *shadername,
 
  233                             bool skipheader = 
false,
 
  234                             const char * output_node_name = 
nullptr,
 
  235                             VCC_Diagnostics *diag = 
nullptr,
 
  240     bool                 outputEncapsulatedVflCode(
 
  243                             const char *function_name,
 
  246                             bool generate_outer_code);
 
  250     static bool         compileAndCacheVflCode(
UT_WorkBuffer &vex_output,
 
  253                             VCC_Compiler *compiler,
 
  254                             const VCC_Options &opts);
 
  274     time_t               getCachedCodeTimeStamp(
 
  277     bool                 hasCachedCode() 
const;
 
  280                                            const char *cache_directory,
 
  281                                            const char *renderer,
 
  284                                            const char *shaderpath,
 
  285                                            const char *shadername,
 
  287                                            bool ignore_dirty_flag,
 
  291                                            const char *cache_directory,
 
  292                                            const char *shaderpath,
 
  293                                            const char *shadername,
 
  295                                            bool ignore_dirty_flag,
 
  299     void                 getClassMethodInfos( 
 
  315                                      const char *defcompiler);
 
  317                                      const char *defcompiler);
 
  322     bool                 getGeneratorErrors(
UT_String &errors) 
const;
 
  323     bool                 getGeneratorErrors(
UT_String &errors, 
 
  325     bool                 getGeneratorErrorsAndWarnings(
UT_String &msgs) 
const;
 
  326     bool                 getGeneratorErrorsAndWarnings(
UT_String &msgs,
 
  329     bool                 getDiagnosticsForNode(
VOP_Node *node,
 
  335                          { 
return myLanguage; }
 
  341                          { 
return myContextTypeList.get(); }
 
  352                          { myIsAutoGenerator = is_auto; }
 
  354                          { 
return myIsAutoGenerator; }
 
  367     bool                 needsToGenerateAutoShader(
 
  368                                 bool allow_value_inputs = 
false) 
const;
 
  372     bool                 isSingleContextType() 
const;
 
  375     bool                 isClassBasedShader() 
const;
 
  378     bool                 isClassBasedShader(
 
  388                                 { 
return myOwnerHasParameters; }
 
  406                          { 
return myCompilerArgs; }
 
  411     void                 setLockedCompiledCode(
 
  413                             bool is_source_code);
 
  424     static void                  installCommands();
 
  428     static bool                  convertVopOpToVopOpType(
OP_Node *node,
 
  432     static const char           *getDefaultVEXMask();
 
  443     static bool                  forceCompile(
OP_Node *node);
 
  444     static int                   forceCompile(
void *
data, 
int, 
fpreal,
 
  465     void                 getVopFunctionArgInfosFromExports( 
 
  479                             { 
return myErrorMicroNode; }
 
  481     static void         formatDiagnostic(
const VCC_DiagnosticInfo &info,
 
  493     bool                 getNodesForContextOrNodeFunctionVflCode(
 
  498                                     const char *output_node_name, 
 
  500                                     VCC_Diagnostics *diagnostics);
 
  507     bool                 getNodesForSubnetFunctionVflCode(
VOP_NodeList &nodes, 
 
  511                                     bool require_context_check);
 
  518                             { 
return myNeedsAutoVopNodeCleanup; }
 
  522                             { myUseIfdefVex = flag; }
 
  526                             { myOmitPragmas = flag; }
 
  540                          { myIsChangingAutoShader = flag; }
 
  542                          { 
return myIsChangingAutoShader; }
 
  547     void                 generateObjectCode(VOP_ObjectCodeArgs *
args);
 
  551                 { 
return myLockedCompiledCode[context_type].length() > 0; }
 
  554     void                 outputVflHeaderComment(std::ostream &os);
 
  555     void                 outputShaderDefines(std::ostream &os,
 
  557     bool                 outputShaderVflCodeBlock(std::ostream &os,
 
  558                                 const char *shadername,
 
  561                                 const char *output_node_name,
 
  562                                 VCC_Diagnostics *diagnostics);
 
  563     bool                 outputStandardShaderVflCodeBlock(std::ostream &os,
 
  564                                 const char *shadername,
 
  567                                 const char *output_node_name,
 
  568                                 VCC_Diagnostics *diagnostics);
 
  569     bool                 outputFunctionVflCodeBlock(std::ostream &os,
 
  570                                 const char *function_name,
 
  574                                 bool generate_outer_code);
 
  575     bool                 outputMethodVflCodeBlock(
 
  576                                 const vop_CodeGenOutputContext &output_ctx,
 
  580                                 VCC_Diagnostics *diagnostics);
 
  581     bool                 outputClassVflCodeBlock(std::ostream &os,
 
  582                                 const char *shadername,
 
  585                                 VCC_Diagnostics *diagnostics);
 
  586     void                 outputVflPragmas(std::ostream &os,
 
  589     void                 outputVflFunctionBlock(
 
  590                                 const vop_CodeGenOutputContext &output_ctx,
 
  594                                 const char *return_type,
 
  595                                 const char *function_name,
 
  599                                 bool generate_outer_code);
 
  600     void                 outputIsConnectedDeclarations(std::ostream &os,
 
  604     void                 outputShaderVflDeclaration(
 
  605                                 const vop_CodeGenOutputContext &output_ctx,
 
  607                                 const char *return_type,
 
  608                                 const char *function_name,
 
  610     void                 outputClassVflDeclaration(
 
  611                                 const vop_CodeGenOutputContext &output_ctx,
 
  612                                 const char *shadername,
 
  614     void                 outputStructVflDeclaration(
 
  615                                 const vop_CodeGenOutputContext &output_ctx,
 
  616                                 const char *shadername);
 
  617     void                 outputFunctionVflDeclaration(
 
  618                                 const vop_CodeGenOutputContext &output_ctx,
 
  621                                 const char *return_type,
 
  622                                 const char *function_name,
 
  625     void                 outputVflEmptyShaderFunction(std::ostream &os,
 
  626                                 const char *shadername,
 
  628     void                 outputShaderParameterDeclarations(std::ostream &os,
 
  632     void                 outputMemberVariableDeclarations(
 
  633                                 const vop_CodeGenOutputContext &output_ctx);
 
  634     void                 outputFunctionParameterDeclarations(std::ostream &os,
 
  641     void                 getFunctionNameOrOverride(
UT_String &function_name,
 
  642                                                 const char *
override);
 
  644     void                 clearFileCache();
 
  652     bool                 hasSubscribingSiblings( 
VOP_Type shader_type ) 
const;
 
  673                             bool only_essential) 
const;
 
  683     void                 ensureDstDirCreated(
UT_String &output_file_no_ext,
 
  684                             const char *
path, 
const char *shaderpath, 
 
  685                             const char *shadername, 
const char *context_suffix);
 
  688                                              const char *shadername,
 
  691     bool                 usesStandardVCCOptions();
 
  695     void                 getContextFileSuffix( 
UT_String & suffix,
 
  699     vop_CodeCacheData * findCachedCode( 
VOP_ContextType context_type ) 
const;
 
  706                                        vop_CodeCacheData * cache_data );
 
  707     void                copyCachedErrorToDiagnostic(
 
  708                                        const vop_CodeCacheData * cache_data );
 
  709     void                clearCachedCode();
 
  712     bool                getCachedMessages(
 
  720     bool                isMetaSwitchParm(
int parm_index) 
const;
 
  723     bool                isMantraShadingContext(
 
  726     void                 checkForErrorsOnChildren(
OP_Context &cxt, 
 
  735     void                 generateErrorsAndPropagateToOwner();
 
  753     mutable UT_Lock              myCachedCodeLock;
 
  759     int                          myMinimumNumberOfInputs;
 
  760     int                          myMaximumNumberOfInputs;
 
  762     mutable int                  myCollectNodeId;
 
  764     bool                         myNeedsCodeUpdate;
 
  766     bool                         myOwnerHasParameters;
 
  767     bool                         myIsReCookingOwner;
 
  768     bool                         myNeedsAutoVopNodeCleanup;
 
  772     bool                         myIsAutoGenerator;
 
  773     bool                         myIsChangingAutoShader;
 
  837                         const char *shader_name );
 
  840                 { 
return myNestedSubnetShaders; }
 
  842                 { myNestedSubnetShaders[sub_shader] = 
name; }
 
  846     bool        shouldAddSubShader(
VOP_Node *shader_node) 
const;
 
  849     void        replaceSubShaderNamePrefix( 
UT_String &sub_shader_name, 
 
  853     void        removeShaderNamePrefix( 
UT_String &sub_shader_name ) 
const;
 
Reprsents a language for which VOPs can generate source code. 
 
static PRM_Name theVopCompilerName
 
UT_ErrorManager & getErrorManager()
 
OP_Network * ownerNetwork() const 
 
GT_API const UT_StringHolder filename
 
void addSubShader(VOP_Node *sub_shader, const char *name) const 
 
virtual void becameDirty(DEP_MicroNode &src, const DEP_PropagateData &propdata)
 
static PRM_Default theVopCompilerOslDefault
 
bool isVexCodeCached(VOP_ContextType context_type) const 
Determines if the giving context has already been cached. 
 
void setOmitPragmas(bool flag)
Controls whether the source code contains pragmas. 
 
void addExplicitInput(DEP_MicroNode &inp, bool check_dup)
Methods for manipulating explicit edges. 
 
bool needsAutoVopNodeCleanup() const 
 
const UT_Map< VOP_Node *, UT_StringHolder > & getNestedSubnetShaders() const 
 
GLsizei const GLfloat * value
 
bool isAutoGenerator() const 
 
GLsizei const GLchar *const * path
 
bool getOwnerHasParameters() const 
 
void setIsAutoGenerator(bool is_auto)
 
const char * className() const override
 
static PRM_Name theVopForceCompileName
 
std::map< VOP_ContextType, std::string > TContextTypeStringMap
 
void setUseIfdefVex(bool flag)
Controls whether the source code is laced with #ifdef __vex. 
 
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects. 
 
static PRM_ChoiceList theVopCompilerChoices
 
static PRM_Default theVopCompilerRslDefault
 
VOP_CodeGenerator & myCodeGenerator
 
VOP_ExportedParmsManager * exportedParmsManager() const 
Return the exported parameters manager. 
 
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr. 
 
void stealErrors(UT_ErrorManager &src, bool borrow_only=false)
 
void clearAllUpdateFlags()
 
~VOP_CodeGeneratorErrorThief()
 
#define VOP_CONTEXT_TYPE_INVALID
 
const VOP_Language * getLanguage() const 
Get the VOP language generated by this code generator. 
 
VOP_ErrorMicroNode & errorMicroNode()
 
GLuint const GLchar * name
 
UT_Array< VCC_DiagnosticInfo > VCC_DiagnosticList
 
OSL_ContextType
RenderMan shader context types. 
 
Class that contains information about a struct/class method. 
 
virtual bool allowOperatorAsChild(OP_Operator *op)
 
void addCodeDependency(DEP_MicroNode *target)
 
const VOP_LanguageContextTypeList * getLanguageContextTypeList() const 
 
VEX_CodeGenFlags
VEX code generation flags when calling VEX_VexResolver::getVflCode. 
 
VOP_CodeCompilerArgs * getCompilerArgs()
Returns the compiler arguments. 
 
A global error manager scope. 
 
VOP_Type
Enumeration of the built-in (basic) VOP data types. 
 
Propagation info for a dep micro node. 
 
**If you just want to fire and args
 
VOP_CodeGeneratorErrorThief(OP_Node &node)
 
RSL_ContextType
RenderMan shader context types. 
 
GLsizei GLenum GLenum * types
 
virtual VOP_CodeGenerator * getVopCodeGenerator()
 
bool getIsChangingAutoShader() const 
 
static PRM_Default theVopCompilerVexDefault
 
void setIsChangingAutoShader(bool flag)