Loading...
Searching...
No Matches
loftedOutputSet.h
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_EXEC_EF_LOFTED_OUTPUT_SET_H
8#define PXR_EXEC_EF_LOFTED_OUTPUT_SET_H
9
10#include "pxr/pxr.h"
11
12#include "pxr/exec/ef/api.h"
13
14#include "pxr/exec/vdf/types.h"
15
16#include <tbb/concurrent_hash_map.h>
17
18#include <atomic>
19#include <cstddef>
20#include <cstdint>
21#include <memory>
22#include <vector>
23
24PXR_NAMESPACE_OPEN_SCOPE
25
26class VdfMaskedOutput;
27class VdfNetwork;
28class VdfMask;
29using VdfMaskedOutputVector = std::vector<VdfMaskedOutput>;
30class VdfOutput;
31
36{
37public:
38 EF_API
40
41 EF_API
43
45 size_t GetSize() const {
46 return _loftedOutputs.size();
47 }
48
55 EF_API
56 void Resize(const VdfNetwork &network);
57
62 EF_API
63 bool Add(
64 const VdfOutput &output,
65 const VdfMask &mask);
66
68 EF_API
69 void Remove(
70 const VdfId outputId,
71 const VdfId nodeId,
72 const VdfMask &mask);
73
75 EF_API
77
79 EF_API
80 void Clear();
81
83 EF_API
85 const VdfOutputToMaskMap &deps,
86 VdfMaskedOutputVector *processedRequest) const;
87
88private:
89 // A set of outputs, which had their values sourced from the page cache
90 // during evaluation (or getting of output values.) We need to keep track
91 // of these outputs in order to allows us to later properly invalidate them.
92 using _LoftedOutputsMap = tbb::concurrent_hash_map<VdfId, VdfMask>;
93 _LoftedOutputsMap _loftedOutputs;
94
95 // An array of node references used to accelerate lookups into the
96 // _loftedOutputs map.
97 std::unique_ptr<std::atomic<uint32_t>[]> _loftedNodeRefs;
98
99 // The size of _loftedNodeRefs, which grows to accommodate the network's
100 // maximum capacity.
101 size_t _numLoftedNodeRefs = 0;
102};
103
104PXR_NAMESPACE_CLOSE_SCOPE
105
106#endif
Tracks the set of lofted outputs (outputs whose values were sourced from the page cache during evalua...
size_t GetSize() const
Returns the number of outputs lofted into the page cache.
EF_API bool Add(const VdfOutput &output, const VdfMask &mask)
Adds an output to the set of lofted outputs.
EF_API void Clear()
Removes all outputs from the set of lofted outputs.
EF_API void Remove(const VdfId outputId, const VdfId nodeId, const VdfMask &mask)
Removes an output from the set of lofted outputs.
EF_API void RemoveAllOutputsForNode(const VdfNode &node)
Removes all outputs on node from the set of lofted outputs.
EF_API void CollectLoftedDependencies(const VdfOutputToMaskMap &deps, VdfMaskedOutputVector *processedRequest) const
Inserts any lofted outputs in deps into processedRequest.
EF_API void Resize(const VdfNetwork &network)
Allocates storage to accommodate the maximum capacity of the network.
A VdfMask is placed on connections to specify the data flowing through them.
Definition: mask.h:37
Class to hold on to an externally owned output and a mask.
Definition: maskedOutput.h:32
A VdfNetwork is a collection of VdfNodes and their connections.
Definition: network.h:60
This is the base class for all nodes in a VdfNetwork.
Definition: node.h:53
A VdfOutput represents an output on a node.
Definition: output.h:32
uint64_t VdfId
The unique identifier type for Vdf objects.
Definition: types.h:107
std::unordered_map< const VdfOutput *, VdfMask, TfHash > VdfOutputToMaskMap
A map from output pointer to mask.
Definition: types.h:104