HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
poolChainIndex.h
Go to the documentation of this file.
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_VDF_POOL_CHAIN_INDEX_H
8 #define PXR_EXEC_VDF_POOL_CHAIN_INDEX_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/api.h"
15 #include "pxr/exec/vdf/output.h"
16 
18 
19 
20 /// Opaque pool chain index type.
21 ///
22 /// Clients may compare indicies to determine the pool chain ordering.
24 {
25 public:
26  bool operator<(VdfPoolChainIndex rhs) const
27  {
28  return _index < rhs._index;
29  }
30 
31  bool operator<=(VdfPoolChainIndex rhs) const
32  {
33  return !(rhs < *this);
34  }
35 
36  bool operator>(VdfPoolChainIndex rhs) const
37  {
38  return rhs < *this;
39  }
40 
41  bool operator>=(VdfPoolChainIndex rhs) const
42  {
43  return !(*this < rhs);
44  }
45 
46  bool operator==(VdfPoolChainIndex rhs) const
47  {
48  return _index == rhs._index;
49  }
50 
51  bool operator!=(VdfPoolChainIndex rhs) const
52  {
53  return !(*this == rhs);
54  }
55 
56 private:
57  friend class VdfPoolChainIndexer;
58  VdfPoolChainIndex(int poolChainIndex, uint32_t outputIndex)
59  // Combine the pool chain and output indices into a single field.
60  //
61  // The combined index should be sorted primarily in pool chain order.
62  // The invalid pool chain index is -1 so we increment the pool chain
63  // index to ensure that the previous implementation's order, which put
64  // invalid entries first, is maintained.
65  : _index(((static_cast<size_t>(poolChainIndex)+1) << 32ull) |
66  outputIndex)
67  {}
68 
69 private:
70  size_t _index;
71 };
72 
73 
74 /// Returns \c true if \p output is a pool output, i.e., an output that has an
75 /// associated input, that outputs vectorized data.
76 ///
77 inline bool
79 {
80  return output.GetAssociatedInput() && output.GetNumDataEntries() > 1;
81 }
82 
84 
85 #endif
bool operator==(VdfPoolChainIndex rhs) const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
bool operator<=(VdfPoolChainIndex rhs) const
const VdfInput * GetAssociatedInput() const
Definition: output.h:76
bool operator>=(VdfPoolChainIndex rhs) const
friend class VdfPoolChainIndexer
bool Vdf_IsPoolOutput(const VdfOutput &output)
bool operator!=(VdfPoolChainIndex rhs) const
bool operator>(VdfPoolChainIndex rhs) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
bool operator<(VdfPoolChainIndex rhs) const
VDF_API int GetNumDataEntries() const