HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawItem.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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_IMAGING_HD_ST_DRAW_ITEM_H
8 #define PXR_IMAGING_HD_ST_DRAW_ITEM_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
12 
14 
16 
17 
19  std::shared_ptr<class HdSt_GeometricShader>;
21  std::shared_ptr<class HdSt_MaterialNetworkShader>;
22 
23 class HdStDrawItem : public HdDrawItem
24 {
25 public:
26  HF_MALLOC_TAG_NEW("new HdStDrawItem");
27 
28  HDST_API
29  HdStDrawItem(HdRprimSharedData const *sharedData);
30 
31  HDST_API
32  ~HdStDrawItem() override;
33 
34  /// Returns true if the drawItem has an instancer.
35  bool HasInstancer() const {
36  TF_VERIFY(_GetSharedData()->instancerLevels != -1);
37  return (_GetSharedData()->instancerLevels > 0);
38  }
39 
40  /// Returns the number of nested levels of instance primvars.
42  TF_VERIFY(_GetSharedData()->instancerLevels != -1);
44  }
45 
46  /// Returns a BufferArrayRange of instance primvars at \p level
47  /// the level is assigned to nested instancers in a bottom-up manner.
48  ///
49  /// example: (numLevels = 2)
50  ///
51  /// instancerA (level = 1)
52  /// |
53  /// +-- instancerB (level = 0)
54  /// |
55  /// +-- mesh_prototype
56  ///
60  _GetDrawingCoord().GetInstancePrimvarIndex(level));
61  }
62 
63  /// Returns instance-index indirection BAR.
66  _GetDrawingCoord().GetInstanceIndexIndex());
67  }
68 
69  /// Returns constant primvar BAR.
72  _GetDrawingCoord().GetConstantPrimvarIndex());
73  }
74 
75  /// Returns element primvar BAR.
78  _GetDrawingCoord().GetElementPrimvarIndex());
79  }
80 
81  /// Returns vertex primvar BAR.
84  _GetDrawingCoord().GetVertexPrimvarIndex());
85  }
86 
87  /// Returns varying primvar BAR.
90  _GetDrawingCoord().GetVaryingPrimvarIndex());
91  }
92 
93  /// Returns face varying primvar BAR.
96  _GetDrawingCoord().GetFaceVaryingPrimvarIndex());
97  }
98 
99  /// Returns topology BAR.
101  return _GetSharedData()->barContainer.Get(
102  _GetDrawingCoord().GetTopologyIndex());
103  }
104 
105  /// Returns topological visibility BAR (e.g. per-face, per-point, etc.)
107  return _GetSharedData()->barContainer.Get(
108  _GetDrawingCoord().GetTopologyVisibilityIndex());
109  }
110 
111  /// Returns mapping from refined fvar channels to named primvar.
114  }
115 
117  _geometricShader = shader;
118  }
119 
121  return _geometricShader;
122  }
123 
126  return _materialNetworkShader;
127  }
128 
131  _materialNetworkShader = shader;
132  }
133 
134  bool GetMaterialIsFinal() const {
135  return _materialIsFinal;
136  }
137 
138  void SetMaterialIsFinal(bool isFinal) {
139  _materialIsFinal = isFinal;
140  }
141 
142  /// Tests intersection with the specified view projection matrix.
143  /// Returns true if this drawItem is in the frustum.
144  ///
145  /// XXX: Currently if this drawitem uses instancing, always returns true.
146  HDST_API
147  bool IntersectsViewVolume(GfMatrix4d const &viewProjMatrix) const;
148 
149  /// Returns the hash of the versions of underlying buffers. When the
150  /// hash changes, it means the drawing coord might have been reassigned,
151  /// so any drawing coord caching buffer (e.g. indirect dispatch buffer)
152  /// has to be rebuilt at the moment.
153  /// Note that this value is a hash, not sequential.
154  HDST_API
155  size_t GetBufferArraysHash() const;
156 
157  /// Returns the hash of the element offsets of the underlying BARs.
158  /// When the hash changes, it means that any drawing coord caching
159  /// buffer (e.g. the indirect dispatch buffer) has to be rebuilt.
160  /// Note that this value is a hash, not sequential.
161  HDST_API
162  size_t GetElementOffsetsHash() const;
163 
164 private:
165  HdSt_GeometricShaderSharedPtr _geometricShader;
166  HdSt_MaterialNetworkShaderSharedPtr _materialNetworkShader;
167  bool _materialIsFinal;
168 };
169 
170 
172 
173 #endif //PXR_IMAGING_HD_ST_DRAW_ITEM_H
HDST_API bool IntersectsViewVolume(GfMatrix4d const &viewProjMatrix) const
TopologyToPrimvarVector const & GetFvarTopologyToPrimvarVector() const
Returns mapping from refined fvar channels to named primvar.
Definition: drawItem.h:112
HD_API HdBufferArrayRangeSharedPtr const & Get(int index) const
std::shared_ptr< class HdSt_MaterialNetworkShader > HdSt_MaterialNetworkShaderSharedPtr
Definition: drawItem.h:21
GLint level
Definition: glcorearb.h:108
std::shared_ptr< class HdSt_GeometricShader > HdSt_GeometricShaderSharedPtr
Definition: drawItem.h:19
HdDrawingCoord const & _GetDrawingCoord() const
Returns the drawingCoord.
Definition: drawItem.h:87
HdRprimSharedData const * _GetSharedData() const
Returns the shared data.
Definition: drawItem.h:92
HdBufferArrayRangeSharedPtr const & GetInstancePrimvarRange(int level) const
Definition: drawItem.h:58
void SetGeometricShader(HdSt_GeometricShaderSharedPtr const &shader)
Definition: drawItem.h:116
void SetMaterialNetworkShader(HdSt_MaterialNetworkShaderSharedPtr const &shader)
Definition: drawItem.h:129
HdBufferArrayRangeContainer barContainer
HdBufferArrayRangeSharedPtr const & GetVaryingPrimvarRange() const
Returns varying primvar BAR.
Definition: drawItem.h:88
HdBufferArrayRangeSharedPtr const & GetElementPrimvarRange() const
Returns element primvar BAR.
Definition: drawItem.h:76
void SetMaterialIsFinal(bool isFinal)
Definition: drawItem.h:138
TopologyToPrimvarVector fvarTopologyToPrimvarVector
HdBufferArrayRangeSharedPtr const & GetFaceVaryingPrimvarRange() const
Returns face varying primvar BAR.
Definition: drawItem.h:94
HdSt_MaterialNetworkShaderSharedPtr const & GetMaterialNetworkShader() const
Definition: drawItem.h:125
HDST_API ~HdStDrawItem() override
HdBufferArrayRangeSharedPtr const & GetVertexPrimvarRange() const
Returns vertex primvar BAR.
Definition: drawItem.h:82
int GetInstancePrimvarNumLevels() const
Returns the number of nested levels of instance primvars.
Definition: drawItem.h:41
HDST_API size_t GetBufferArraysHash() const
HF_MALLOC_TAG_NEW("new HdStDrawItem")
HdSt_GeometricShaderSharedPtr const & GetGeometricShader() const
Definition: drawItem.h:120
GLuint shader
Definition: glcorearb.h:785
std::vector< std::pair< VtIntArray, std::vector< TfToken >>> TopologyToPrimvarVector
HdBufferArrayRangeSharedPtr const & GetTopologyVisibilityRange() const
Returns topological visibility BAR (e.g. per-face, per-point, etc.)
Definition: drawItem.h:106
HDST_API size_t GetElementOffsetsHash() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define HDST_API
Definition: api.h:23
HdBufferArrayRangeSharedPtr const & GetInstanceIndexRange() const
Returns instance-index indirection BAR.
Definition: drawItem.h:64
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:27
HDST_API HdStDrawItem(HdRprimSharedData const *sharedData)
HdBufferArrayRangeSharedPtr const & GetTopologyRange() const
Returns topology BAR.
Definition: drawItem.h:100
bool GetMaterialIsFinal() const
Definition: drawItem.h:134
bool HasInstancer() const
Returns true if the drawItem has an instancer.
Definition: drawItem.h:35
HdBufferArrayRangeSharedPtr const & GetConstantPrimvarRange() const
Returns constant primvar BAR.
Definition: drawItem.h:70