HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rprimUtils.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_ST_RPRIM_UTILS_H
25 #define PXR_IMAGING_HD_ST_RPRIM_UTILS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
30 
31 #include <memory>
32 #include <string>
33 #include <vector>
34 
36 
37 class HdChangeTracker;
38 class HdDrawItem;
39 class HdRenderIndex;
40 class HdRprim;
41 struct HdRprimSharedData;
42 class HdStDrawItem;
43 class HdStInstancer;
44 
45 using HdBufferArrayRangeSharedPtr = std::shared_ptr<class HdBufferArrayRange>;
46 
47 using HdBufferSourceSharedPtrVector = std::vector<HdBufferSourceSharedPtr>;
48 using HdBufferSpecVector = std::vector<struct HdBufferSpec>;
49 using HdStShaderCodeSharedPtr = std::shared_ptr<class HdStShaderCode>;
50 
51 using HdComputationSharedPtr = std::shared_ptr<class HdComputation>;
52 using HdComputationSharedPtrVector = std::vector<HdComputationSharedPtr>;
53 
55  std::shared_ptr<class HdStResourceRegistry>;
56 
57 // -----------------------------------------------------------------------------
58 // Primvar descriptor filtering utilities
59 // -----------------------------------------------------------------------------
60 // Get filtered primvar descriptors for drawItem
64  HdRprim const * prim,
65  HdStDrawItem const * drawItem,
66  HdSceneDelegate * delegate,
67  HdInterpolation interpolation);
68 
69 // Get filtered instancer primvar descriptors for drawItem
73  HdStInstancer const * instancer,
74  HdRprim const * prim,
75  HdStDrawItem const * drawItem,
76  HdSceneDelegate * delegate);
77 
78 // -----------------------------------------------------------------------------
79 // Material shader utility
80 // -----------------------------------------------------------------------------
81 // Resolves the material shader for the given prim (using a fallback
82 // material as necessary), including optional mixin shader source code.
86  HdRprim const * prim,
87  HdSceneDelegate * delegate,
88  std::string const & mixinSource = std::string());
89 
90 // -----------------------------------------------------------------------------
91 // Primvar processing and BAR allocation utilities
92 // -----------------------------------------------------------------------------
93 // Returns true if range is non-empty and valid.
96 
97 // Returns true if curRange can be used as-is (even if it's empty) during
98 // primvar processing.
102  HdComputationSharedPtrVector const& computations,
103  HdBufferArrayRangeSharedPtr const& curRange,
104  HdDirtyBits dirtyBits);
105 
106 HDST_API
109  HdBufferArrayRangeSharedPtr const& curRange,
110  HdDirtyBits dirtyBits);
111 
112 // Returns the buffer specs that have been removed from curRange based on the
113 // new primvar descriptors and internally generated primvar names.
114 //
115 // Internally generated primvar names will never be among the specs returned,
116 HDST_API
119  HdBufferArrayRangeSharedPtr const& curRange,
120  HdPrimvarDescriptorVector const& newPrimvarDescs,
121  HdExtComputationPrimvarDescriptorVector const& newCompPrimvarDescs,
122  TfTokenVector const& internallyGeneratedPrimvarNames,
123  SdfPath const& rprimId);
124 
125 HDST_API
128  HdBufferArrayRangeSharedPtr const& curRange,
129  HdPrimvarDescriptorVector const& newPrimvarDescs,
130  TfTokenVector const& internallyGeneratedPrimvarNames,
131  SdfPath const& rprimId);
132 
133 // Updates the existing range at drawCoordIndex with newRange and flags garbage
134 // collection (for the existing range) and rebuild of all draw batches when
135 // necessary.
136 HDST_API
138  HdBufferArrayRangeSharedPtr const& newRange,
139  int drawCoordIndex,
140  HdRprimSharedData *sharedData,
141  HdRenderIndex &renderIndex);
142 
143 // -----------------------------------------------------------------------------
144 // Constant primvar processing utilities
145 // -----------------------------------------------------------------------------
146 // Returns whether constant primvars need to be populated/updated based on the
147 // dirty bits for a given rprim.
148 HDST_API
150  HdDirtyBits const *dirtyBits,
151  SdfPath const& id);
152 
153 // Given prim information it will create sources representing
154 // constant primvars and hand it to the resource registry.
155 HDST_API
157  HdRprim *prim,
158  HdRprimSharedData *sharedData,
159  HdSceneDelegate *delegate,
160  HdDrawItem *drawItem,
161  HdDirtyBits *dirtyBits,
162  HdPrimvarDescriptorVector const& constantPrimvars);
163 
164 // -----------------------------------------------------------------------------
165 // Topological visibility processing utility
166 // -----------------------------------------------------------------------------
167 // Creates/Updates/Migrates the topology visiblity BAR with element and point
168 // visibility encoded using one bit per element/point of the topology.
169 HDST_API
171  VtIntArray invisibleElements,
172  int numTotalElements,
173  VtIntArray invisiblePoints,
174  int numTotalPoints,
175  HdRprimSharedData *sharedData,
176  HdStDrawItem *drawItem,
177  HdChangeTracker *changeTracker,
178  HdStResourceRegistrySharedPtr const &resourceRegistry,
179  SdfPath const& rprimId);
180 
181 
183 
184 #endif // PXR_IMAGING_HD_ST_RPRIM_UTILS_H
GLenum GLint * range
Definition: glew.h:3500
GLsizei GLenum * sources
Definition: glew.h:3954
HDST_API HdBufferSpecVector HdStGetRemovedPrimvarBufferSpecs(HdBufferArrayRangeSharedPtr const &curRange, HdPrimvarDescriptorVector const &newPrimvarDescs, HdExtComputationPrimvarDescriptorVector const &newCompPrimvarDescs, TfTokenVector const &internallyGeneratedPrimvarNames, SdfPath const &rprimId)
uint32_t HdDirtyBits
Definition: types.h:127
std::vector< HdBufferSourceSharedPtr > HdBufferSourceSharedPtrVector
Definition: bufferSource.h:44
HDST_API void HdStUpdateDrawItemBAR(HdBufferArrayRangeSharedPtr const &newRange, int drawCoordIndex, HdRprimSharedData *sharedData, HdRenderIndex &renderIndex)
HDST_API void HdStProcessTopologyVisibility(VtIntArray invisibleElements, int numTotalElements, VtIntArray invisiblePoints, int numTotalPoints, HdRprimSharedData *sharedData, HdStDrawItem *drawItem, HdChangeTracker *changeTracker, HdStResourceRegistrySharedPtr const &resourceRegistry, SdfPath const &rprimId)
Definition: rprim.h:68
HDST_API HdStShaderCodeSharedPtr HdStGetMaterialShader(HdRprim const *prim, HdSceneDelegate *delegate, std::string const &mixinSource=std::string())
std::shared_ptr< class HdComputation > HdComputationSharedPtr
Definition: computation.h:41
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:446
Definition: path.h:288
std::vector< struct HdBufferSpec > HdBufferSpecVector
HDST_API bool HdStIsValidBAR(HdBufferArrayRangeSharedPtr const &range)
GLsizei const GLchar *const * string
Definition: glew.h:1844
HDST_API HdPrimvarDescriptorVector HdStGetInstancerPrimvarDescriptors(HdStInstancer const *instancer, HdRprim const *prim, HdStDrawItem const *drawItem, HdSceneDelegate *delegate)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
HDST_API void HdStPopulateConstantPrimvars(HdRprim *prim, HdRprimSharedData *sharedData, HdSceneDelegate *delegate, HdDrawItem *drawItem, HdDirtyBits *dirtyBits, HdPrimvarDescriptorVector const &constantPrimvars)
#define HDST_API
Definition: api.h:40
HdInterpolation
Definition: enums.h:194
HDST_API bool HdStShouldPopulateConstantPrimvars(HdDirtyBits const *dirtyBits, SdfPath const &id)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:45
HDST_API HdPrimvarDescriptorVector HdStGetPrimvarDescriptors(HdRprim const *prim, HdStDrawItem const *drawItem, HdSceneDelegate *delegate, HdInterpolation interpolation)
std::vector< HdComputationSharedPtr > HdComputationSharedPtrVector
Definition: computation.h:42
std::vector< HdPrimvarDescriptor > HdPrimvarDescriptorVector
HDST_API bool HdStCanSkipBARAllocationOrUpdate(HdBufferSourceSharedPtrVector const &sources, HdComputationSharedPtrVector const &computations, HdBufferArrayRangeSharedPtr const &curRange, HdDirtyBits dirtyBits)
std::shared_ptr< class HdStResourceRegistry > HdStResourceRegistrySharedPtr
Definition: commandBuffer.h:47
std::shared_ptr< class HdStShaderCode > HdStShaderCodeSharedPtr
Definition: drawItem.h:34
std::vector< HdExtComputationPrimvarDescriptor > HdExtComputationPrimvarDescriptorVector