HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_Cache.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SOP_Cache.h ( SOP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __SOP_Cache__
12 #define __SOP_Cache__
13 
14 #include "SOP_API.h"
15 #include "SOP_Node.h"
16 #include <UT/UT_Map.h>
17 #include <utility>
18 
19 class UT_InfoTree;
20 class CH_Manager;
21 
23 {
24 public:
25  SOP_Cache(OP_Network *net, const char *name, OP_Operator *entry);
26  ~SOP_Cache() override;
27 
28  static OP_Node *myConstructor(OP_Network *net,
29  const char *name,
30  OP_Operator *entry);
31 
33 
34  static PRM_Template myTemplateList[];
35 
37  OP_Context &context,
38  OP_NodeInfoParms &iparms) override;
39 
40  // Fill in tree with this node's details
42  UT_InfoTree &tree,
44  ) override;
45 
46  bool unloadData() override;
47  int64 getLoadedMemoryUsage() const override;
48 
50  { return myRemoveSerial; }
51 
52  bool updateParmsFlags() override;
53  void syncNodeVersion(
54  const char *old_version,
55  const char *cur_version,
56  bool *node_deleted) override;
57 
58 
59  static fpreal roundTime(fpreal current_t);
60 
61  void pruneCache(exint maxframes, fpreal current_t);
62 
63  /// NOTE: This MUST NOT be named "clearCache", because there's a virtual
64  /// function on OP_Node with that name!
65  void clearCacheSopCache();
66 
67  void makePreserveRequest() override;
68 
69  const SOP_NodeVerb* cookVerb() const override;
70 
71  bool opNotifyVarChange(
72  const char *varname,
73  OP_NodeList *changed_nodes = nullptr) override;
74 
75 protected:
76  OP_ERROR cookMySop(OP_Context &context) override;
77  void setInstance(GU_DetailHandle *igdh);
78  int isRefInput(OP_InputIdx i) const override;
79  const char *inputLabel(OP_InputIdx idx) const override;
80 
81 private:
82  bool ANYFRAME() { return evalInt("anyframe", 0, 0) != 0; }
83  int MAXFRAMES(fpreal t) { return evalInt("maxframes",0, t); }
84  bool CLEARONCHANGE(fpreal t) { return evalInt("clearonchange", 0, t) != 0; }
85 
86  int START(fpreal t) { return evalInt("range", 0, t); }
87  int END(fpreal t) { return evalInt("range", 1, t); }
88  int INC(fpreal t) { return evalInt("range", 2, t); }
89 
90  fpreal INDEX(fpreal t) { return evalFloat("index", 0, t); }
91  void PARAM(UT_String &str) { evalString(str, "param", 0, 0); }
92 
93  int INDEXTIME() { return evalInt("indextime", 0, 0); }
94 
95  int LOADMETHOD() { return evalInt("loadmethod", 0, 0); }
96 
97 // int LOAD() { return evalInt("reload", 0, 0); }
98 // int RESET() { return evalInt("clear", 0, 0); }
99 
100  bool CACHEPOINTS() { return evalInt("cachepoints", 0, 0) != 0; }
101  bool BLENDPOS() { return evalInt("blendpos", 0, 0) != 0; }
102 
103  void clearGDPLists();
104  void clearGDPList(fpreal t);
105 
106  void loadLocalGeometry(fpreal t, bool cache_points, int ind,
107  int check_merge = 0);
108  GU_DetailHandle *getLocalGeometry(fpreal t, bool cache_points, int ind,
109  int check_merge = 0);
110 
111  static int preLoadLocalCache(void *data, int index, fpreal t,
112  const PRM_Template *);
113  static int preClearLocalCache(void *data, int index, fpreal t,
114  const PRM_Template *);
115  static int preClearLocalCacheFrame(void *data, int index, fpreal t,
116  const PRM_Template *);
117 
118  void blendGDP(fpreal t, bool cache_points, fpreal index);
119  void setGDP(fpreal t, bool cache_points, int i0);
120 
121  const GU_Detail *getLocalInput(fpreal t, fpreal val, const char *param,
122  CH_Manager *cman);
123 
124  void getRange(int &start, int &end, int &inc, fpreal t);
125 
126  void shiftCache(int start, int end, int inc);
127 
128  /// This maps from frame time to detail. Each detail has an
129  /// integer that indicates the cache access count when
130  /// it was last accessed.
131  /// When removing one item from the cache, the minimum integer is
132  /// found and removed. When removing everything (or all but one)
133  /// from the cache, it's easily cleared. Otherwise, the items
134  /// are sorted for removal.
136 
137  /// This is a cache access count, used for tracking age in myCache.
138  exint myCacheAccessCount;
139 
140  /// Cache whether any of the cooks in the cache have been time dependent.
141  bool myTimeDep;
142 
143  int myCacheStart;
144  int myCacheEnd;
145  int myCacheInc;
146  int myTotal;
147 
148  UT_Array<GU_DetailHandle *> myGDPLists;
149  fpreal myLastIndex;
150  int64 myCachedMemoryUsage;
151 
152  int64 myRemoveSerial;
153  int myLastRefInputId;
154  int myLastRefInputModVer;
155 
156  bool myPreserveRequest;
157 };
158 
159 #endif
virtual bool updateParmsFlags()
virtual const SOP_NodeVerb * cookVerb() const
Definition: SOP_Node.h:931
Unsorted map container.
Definition: UT_Map.h:114
void syncNodeVersion(const char *old_version, const char *current_version, bool *node_deleted) override
virtual void makePreserveRequest()
GLuint start
Definition: glcorearb.h:475
int OP_InputIdx
Definition: OP_DataTypes.h:184
int64 exint
Definition: SYS_Types.h:125
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
int64 getCacheRemoveSerial() const
Definition: SOP_Cache.h:49
virtual const char * inputLabel(OP_InputIdx idx) const
void evalString(UT_String &val, int pi, int vi, fpreal t) const
GLuint GLuint end
Definition: glcorearb.h:475
virtual int64 getLoadedMemoryUsage() const
long long int64
Definition: SYS_Types.h:116
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual int isRefInput(OP_InputIdx idx) const
GLdouble t
Definition: glad.h:2397
GA_API const UT_StringHolder parms
GLenum GLfloat param
Definition: glcorearb.h:104
Parameters for OP_Node::fillInfoTree()/OP_Node::fillInfoTreeNodeSpecific()
fpreal64 fpreal
Definition: SYS_Types.h:283
GLuint index
Definition: glcorearb.h:786
GLuint GLfloat * val
Definition: glcorearb.h:1608
#define SOP_API
Definition: SOP_API.h:10
virtual bool opNotifyVarChange(const char *varname, OP_NodeList *changed_nodes=nullptr)=0
exint evalInt(int pi, int vi, fpreal t) const
virtual OP_ERROR cookMySop(OP_Context &context)=0
void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &iparms) override
Definition: format.h:1821
static const UT_StringHolder theSOPTypeName
Definition: SOP_Cache.h:32
void fillInfoTreeNodeSpecific(UT_InfoTree &tree, const OP_NodeInfoTreeParms &parms) override
Fill in tree with this SOP's details.
bool unloadData() override