HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_PrimVOP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  */
27 
28 #ifndef __SOP_PrimVOP__
29 #define __SOP_PrimVOP__
30 
31 #include <SOP/SOP_Node.h>
32 
33 #include <VEX/VEX_PodTypes.h>
34 template <VEX_Precision PREC> class CVEX_ContextT;
36 
37 #include <VOP/VOP_CodeGenerator.h>
39 
40 template <VEX_Precision PREC> class CVEX_RunDataT;
42 class OP_Caller;
43 
44 namespace HDK_Sample {
45 class SOP_PrimVOP : public SOP_Node
46 {
47 public:
48  SOP_PrimVOP(OP_Network *net, const char *, OP_Operator *entry);
49  ~SOP_PrimVOP() override;
50 
51  static OP_Node *myConstructor(OP_Network *net, const char *name,
52  OP_Operator *entry);
54 
55  /// Overriding these are what allow us to contain VOPs
57  const char *getChildType() const override;
58  OP_OpTypeId getChildTypeID() const override;
59 
61  bool hasVexShaderParameter(const char *parm_name) override;
62 
63  /// We need special alerts now that we contain VOPs.
64  void opChanged(OP_EventType reason, void *data=0) override;
65 
66  /// Code generation variables.
67  bool evalVariableValue(
69  int index,
70  int thread) override;
71 
72  // Add virtual overload that delegates to the super class to avoid
73  // shadow warnings.
75  fpreal &v,
76  int i,
77  int thread) override
78  { return SOP_Node::evalVariableValue(v,i,thread); }
79 
80  static const char *theChildTableName;
81 
82 protected:
83  OP_ERROR cookMySop(OP_Context &context) override;
84 
85  void executeVex(int argc, char **argv,
86  fpreal t, OP_Caller &opcaller);
87 
88  void processVexBlock(CVEX_Context &context,
89  CVEX_RunData &rundata,
90  int argc, char **argv,
91  int *primid, int n,
92  fpreal t);
93 
95  { return evalInt("vexsrc", 0, t); }
97  { evalString(s, "script", 0, t); }
98 
100  { evalString(path, "shoppath", 0, t); }
101 
102  /// VOP and VEX functions
104  bool is_child_call=false) override;
105  void addNode(OP_Node *node, int notify=1,
106  int explicitly=1) override;
108  OP_Context &context,
109  OP_NodeInfoParms &parms) override;
110 
111  void buildScript(UT_String &script, fpreal t);
112 
113  /// Every operator that has a VOP code generator needs to define
114  /// this method in order for Parameter VOP changes to be reflected
115  /// in the VOP network's parameter interface.
116  ///
117  /// This method requires <VOP/VOP_CodeGenerator.h>
118  /// and <VOP/VOP_ExportedParmsManager.h> to be included.
120  {
121  // Check if the spare parameter templates
122  // are out-of-date.
123  if (getVopCodeGenerator()
125  .requiresUpdate(0.0))
126  {
127  // Call into the code generator to update
128  // the spare parameter templates.
132  }
133  }
134 
136 };
137 } // End HDK_Sample namespace
138 
139 #endif
140 
bool evalVariableValue(fpreal &val, int index, int thread) override
OP_ERROR cookMySop(OP_Context &context) override
Definition: SOP_PrimVOP.C:146
void addNode(OP_Node *node, int notify=1, int explicitly=1) override
Definition: SOP_PrimVOP.C:773
bool evalVariableValue(UT_String &value, int index, int thread) override
Code generation variables.
Definition: SOP_PrimVOP.C:718
const GLdouble * v
Definition: glcorearb.h:837
const char * getChildType() const override
Definition: SOP_PrimVOP.C:745
VOP_CodeGenerator * getVopCodeGenerator() override
Definition: SOP_PrimVOP.C:733
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
void opChanged(OP_EventType reason, void *data=0) override
We need special alerts now that we contain VOPs.
Definition: SOP_PrimVOP.C:757
SOP_PrimVOP(OP_Network *net, const char *, OP_Operator *entry)
Definition: SOP_PrimVOP.C:119
GLdouble s
Definition: glad.h:3009
UT_ErrorSeverity
Definition: UT_Error.h:25
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
void updateOwnerSpareParmLayout(bool allow_update_while_loading=false)
Update the owner network's spare parameter layout.
static const char * theChildTableName
Definition: SOP_PrimVOP.h:80
void ensureSpareParmsAreUpdatedSubclass() override
Definition: SOP_PrimVOP.h:119
static PRM_Template myTemplateList[]
Definition: SOP_PrimVOP.h:53
GLdouble n
Definition: glcorearb.h:2008
VOP_ExportedParmsManager * exportedParmsManager() const
Return the exported parameters manager.
void SCRIPT(UT_String &s, fpreal t)
Definition: SOP_PrimVOP.h:96
void evalString(UT_String &val, int pi, int vi, fpreal t) const
void finishedLoadingNetwork(bool is_child_call=false) override
VOP and VEX functions.
Definition: SOP_PrimVOP.C:766
void SHOPPATH(UT_String &path, fpreal t)
Definition: SOP_PrimVOP.h:99
bool hasVexShaderParameter(const char *parm_name) override
Definition: SOP_PrimVOP.C:739
DEP_MicroNode & eventMicroNode(OP_EventType e)
bool evalVariableValue(fpreal &v, int i, int thread) override
Definition: SOP_PrimVOP.h:74
OP_OpTypeId
Definition: OP_OpTypeId.h:18
GLuint const GLchar * name
Definition: glcorearb.h:786
void executeVex(int argc, char **argv, fpreal t, OP_Caller &opcaller)
Definition: SOP_PrimVOP.C:192
GLdouble t
Definition: glad.h:2397
void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &parms) override
Definition: SOP_PrimVOP.C:781
static OP_Node * myConstructor(OP_Network *net, const char *name, OP_Operator *entry)
Definition: SOP_PrimVOP.C:113
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint index
Definition: glcorearb.h:786
OP_EventType
Definition: OP_Value.h:22
Per-run data for CVEX execution.
Definition: CVEX_Context.h:38
Definition: core.h:1131
exint evalInt(int pi, int vi, fpreal t) const
OP_OpTypeId getChildTypeID() const override
Definition: SOP_PrimVOP.C:751
OP_OperatorFilter * getOperatorFilter() override
Overriding these are what allow us to contain VOPs.
Definition: SOP_PrimVOP.C:727
Call VEX from C++.
Definition: CVEX_Context.h:203
void processVexBlock(CVEX_Context &context, CVEX_RunData &rundata, int argc, char **argv, int *primid, int n, fpreal t)
Definition: SOP_PrimVOP.C:501
VOP_CodeGenerator myCodeGenerator
Definition: SOP_PrimVOP.h:135
int VEXSRC(fpreal t)
Definition: SOP_PrimVOP.h:94
Definition: format.h:895
void buildScript(UT_String &script, fpreal t)
Definition: SOP_PrimVOP.C:668