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 
22 class SOP_API SOP_Cache : public SOP_Node
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 
32  static PRM_Template myTemplateList[];
33 
36  OP_NodeInfoParms &iparms) override;
37 
38  // Fill in tree with this node's details
40  UT_InfoTree &tree,
41  const OP_NodeInfoTreeParms &parms
42  ) override;
43 
44  bool unloadData() override;
45  int64 getLoadedMemoryUsage() const override;
46 
48  { return myRemoveSerial; }
49 
50  bool updateParmsFlags() override;
51  void syncNodeVersion(
52  const char *old_version,
53  const char *cur_version,
54  bool *node_deleted) override;
55 
56  static fpreal roundTime(fpreal current_t);
57 
58  void pruneCache(exint maxframes, fpreal current_t);
59 
60  /// NOTE: This MUST NOT be named "clearCache", because there's a virtual
61  /// function on OP_Node with that name!
62  void clearCacheSopCache();
63 
64  void makePreserveRequest() override;
65 
66 protected:
68  void setInstance(GU_DetailHandle *igdh);
69  int isRefInput(unsigned int i) const override;
70  const char *inputLabel(unsigned idx) const override;
71 
72 private:
73  bool ANYFRAME() { return evalInt("anyframe", 0, 0) != 0; }
74  int MAXFRAMES(fpreal t) { return evalInt("maxframes",0, t); }
75  bool CLEARONCHANGE(fpreal t) { return evalInt("clearonchange", 0, t) != 0; }
76 
77  int START(fpreal t) { return evalInt("range", 0, t); }
78  int END(fpreal t) { return evalInt("range", 1, t); }
79  int INC(fpreal t) { return evalInt("range", 2, t); }
80 
81  fpreal INDEX(fpreal t) { return evalFloat("index", 0, t); }
82  void PARAM(UT_String &str) { evalString(str, "param", 0, 0); }
83 
84  int INDEXTIME() { return evalInt("indextime", 0, 0); }
85 
86  int LOADMETHOD() { return evalInt("loadmethod", 0, 0); }
87 
88 // int LOAD() { return evalInt("reload", 0, 0); }
89 // int RESET() { return evalInt("clear", 0, 0); }
90 
91  bool CACHEPOINTS() { return evalInt("cachepoints", 0, 0) != 0; }
92  bool BLENDPOS() { return evalInt("blendpos", 0, 0) != 0; }
93 
94  void clearGDPLists();
95  void clearGDPList(fpreal t);
96 
97  void loadLocalGeometry(fpreal t, bool cache_points, int ind,
98  int check_merge = 0);
99  GU_DetailHandle *getLocalGeometry(fpreal t, bool cache_points, int ind,
100  int check_merge = 0);
101 
102  static int preLoadLocalCache(void *data, int index, fpreal t,
103  const PRM_Template *);
104  static int preClearLocalCache(void *data, int index, fpreal t,
105  const PRM_Template *);
106  static int preClearLocalCacheFrame(void *data, int index, fpreal t,
107  const PRM_Template *);
108 
109  void blendGDP(fpreal t, bool cache_points, fpreal index);
110  void setGDP(fpreal t, bool cache_points, int i0);
111 
112  const GU_Detail *getLocalInput(fpreal t, fpreal val, const char *param,
113  CH_Manager *cman);
114 
115  void getRange(int &start, int &end, int &inc, fpreal t);
116 
117  void shiftCache(int start, int end, int inc);
118 
119  /// This maps from frame time to detail. Each detail has an
120  /// integer that indicates the cache access count when
121  /// it was last accessed.
122  /// When removing one item from the cache, the minimum integer is
123  /// found and removed. When removing everything (or all but one)
124  /// from the cache, it's easily cleared. Otherwise, the items
125  /// are sorted for removal.
127 
128  /// This is a cache access count, used for tracking age in myCache.
129  exint myCacheAccessCount;
130 
131  /// Cache whether any of the cooks in the cache have been time dependent.
132  bool myTimeDep;
133 
134  int myCacheStart;
135  int myCacheEnd;
136  int myCacheInc;
137  int myTotal;
138 
139  UT_Array<GU_DetailHandle *> myGDPLists;
140  fpreal myLastIndex;
141  int64 myCachedMemoryUsage;
142 
143  int64 myRemoveSerial;
144  int myLastRefInputId;
145  int myLastRefInputModVer;
146 
147  bool myPreserveRequest;
148 };
149 
150 #endif
virtual bool updateParmsFlags()
GLuint const GLchar * name
Definition: glew.h:1814
Unsorted map container.
Definition: UT_Map.h:83
void syncNodeVersion(const char *old_version, const char *current_version, bool *node_deleted) override
virtual void makePreserveRequest()
GLuint index
Definition: glew.h:1814
GLuint const GLfloat * val
Definition: glew.h:2794
virtual const char * inputLabel(unsigned idx) const
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()
GLfloat param
Definition: glew.h:1530
int64 getCacheRemoveSerial() const
Definition: SOP_Cache.h:47
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
void evalString(UT_String &val, int pi, int vi, fpreal t) const
GLuint GLuint end
Definition: glew.h:1253
virtual int64 getLoadedMemoryUsage() const
long long int64
Definition: SYS_Types.h:116
GLuint start
Definition: glew.h:1253
Parameters for OP_Node::fillInfoTree()/OP_Node::fillInfoTreeNodeSpecific()
fpreal64 fpreal
Definition: SYS_Types.h:277
#define SOP_API
Definition: SOP_API.h:10
exint evalInt(int pi, int vi, fpreal t) const
virtual OP_ERROR cookMySop(OP_Context &context)=0
virtual int isRefInput(unsigned idx) const
void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &iparms) override
GLdouble GLdouble t
Definition: glew.h:1398
void fillInfoTreeNodeSpecific(UT_InfoTree &tree, const OP_NodeInfoTreeParms &parms) override
Fill in tree with this SOP's details.
bool unloadData() override