HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_LockedStageRegistry.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_LockedStageRegistry_h__
19 #define __HUSD_LockedStageRegistry_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_LockedStage.h"
24 #include <UT/UT_StringMap.h>
25 #include <utility>
26 
27 class GU_PackedImpl;
28 class OP_Context;
29 
30 // This singleton class is used to generate safely locked, unalterable copies
31 // of stages generated by LOP nodes. This is primarily for LOP nodes that
32 // introduce references to the stages output from other LOP nodes. See the
33 // HUSD_LockedStage class for more information.
35 {
36 public:
37  static HUSD_LockedStageRegistry &getInstance();
38 
39  // This function isd called by GusdGU_PackedUSD to track all packed USD
40  // prims so we can ensure that any packed USD prims that point to LOP node
41  // stages keep alive a shared pointer to that locked stage as long as the
42  // packed primitive exists.
43  static void packedUSDTracker(const GU_PackedImpl *prim, bool create);
44 
45  // Exit callback used to clean up the locked stage tracker objects at a
46  // predicatable time during shutdown, rather than relying on static object
47  // destruction ordering.
48  static void exitCallback(void *);
49 
50  HUSD_LockedStagePtr getLockedStage(OP_Node *node,
51  int output_index,
52  const HUSD_DataHandle &data,
53  bool strip_layers,
54  fpreal t,
55  HUSD_StripLayerResponse response);
56  void clearLockedStage(OP_Node *node,
57  const OP_Context &context);
58  void clearLockedStage(OP_Node *node);
59 
60 private:
63 
64  // Locked stages are identified by a string generateed from the stage
65  // cook time and a bool flag indicating whether that node's stage was
66  // flattened with or without layers from above layer breaks stripped out.
67  // Use a weak pointer so that we can track the life of the locked stage
68  // pointer accurately. Keeping a shared pointer in this structure would
69  // mean the locked stage would never be deleted.
71 
72  // A map from the LOP node id to the locked stage map for that LOP node.
73  // Each LOP node may have any number of locked stages active at the same
74  // time, depending on the range of time samples for which the LOP has been
75  // cooked.
76  UT_Map<int, LockedStageMap> myLockedStageMaps;
77 };
78 
79 #endif
80 
Unsorted map container.
Definition: UT_Map.h:109
#define HUSD_API
Definition: HUSD_API.h:31
HUSD_StripLayerResponse
Definition: HUSD_Utils.h:98
GLdouble t
Definition: glad.h:2397
fpreal64 fpreal
Definition: SYS_Types.h:278
UT_SharedPtr< HUSD_LockedStage > HUSD_LockedStagePtr
Definition: format.h:1821