24 #ifndef PXR_USD_IMAGING_USD_IMAGING_UNIT_TEST_HELPER_H 25 #define PXR_USD_IMAGING_USD_IMAGING_UNIT_TEST_HELPER_H 32 #include "pxr/imaging/hd/changeTracker.h" 33 #include "pxr/imaging/hd/engine.h" 34 #include "pxr/imaging/hd/renderIndex.h" 35 #include "pxr/imaging/hd/renderPass.h" 36 #include "pxr/imaging/hd/rprim.h" 37 #include "pxr/imaging/hd/rprimCollection.h" 38 #include "pxr/imaging/hd/tokens.h" 39 #include "pxr/imaging/hd/unitTestNullRenderDelegate.h" 40 #include "pxr/imaging/hd/unitTestNullRenderPass.h" 45 PXR_NAMESPACE_OPEN_SCOPE
47 using HdRenderPassSharedPtr = std::shared_ptr<HdRenderPass>;
50 class UsdImaging_TestTask final :
public HdTask
53 UsdImaging_TestTask(HdRenderPassSharedPtr
const &renderPass,
56 , _renderPass(renderPass)
57 , _renderTags(renderTags)
63 HdDirtyBits* dirtyBits)
override {
66 *dirtyBits = HdChangeTracker::Clean;
69 virtual void Prepare(HdTaskContext* ctx,
73 virtual void Execute(HdTaskContext* ctx)
override {
81 HdRenderPassSharedPtr _renderPass;
93 class UsdImaging_TestDriver final {
95 UsdImaging_TestDriver(std::string
const& usdFilePath)
98 , _renderIndex(nullptr)
108 renderTags.push_back(HdRenderTagTokens->geometry);
116 UsdImaging_TestDriver(std::string
const& usdFilePath,
122 , _renderIndex(nullptr)
137 UsdImaging_TestDriver(UsdStageRefPtr
const& usdStage)
140 , _renderIndex(nullptr)
150 renderTags.push_back(HdRenderTagTokens->geometry);
155 UsdImaging_TestDriver(UsdStageRefPtr
const& usdStage,
161 , _renderIndex(nullptr)
173 UsdImaging_TestDriver(UsdStageRefPtr
const& usdStage,
179 , _renderIndex(nullptr)
184 _Init(usdStage, collection, delegateId, renderTags);
187 ~UsdImaging_TestDriver()
194 HdTaskSharedPtrVector tasks = {
195 std::make_shared<UsdImaging_TestTask>(_geometryPass, _renderTags)
197 _engine.Execute(&_delegate->GetRenderIndex(), &tasks);
199 void SetTime(
double time) {
200 _delegate->SetTime(time);
204 void MarkRprimDirty(
SdfPath path, HdDirtyBits flag) {
205 _delegate->GetRenderIndex().GetChangeTracker()
206 .MarkRprimDirty(path, flag);
215 UsdStageRefPtr
const& GetStage() {
221 Hd_UnitTestNullRenderDelegate _renderDelegate;
224 HdRenderPassSharedPtr _geometryPass;
225 UsdStageRefPtr _stage;
228 void _Init(UsdStageRefPtr
const& usdStage,
237 _delegate->
Populate(_stage->GetPseudoRoot());
239 _geometryPass = HdRenderPassSharedPtr(
240 new Hd_UnitTestNullRenderPass(_renderIndex, collection));
242 _renderTags = renderTags;
246 PXR_NAMESPACE_CLOSE_SCOPE
248 #endif //PXR_USD_IMAGING_USD_IMAGING_UNIT_TEST_HELPER_H The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Token for efficient comparison, assignment, and hashing of known strings.
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
The application-facing entry point top-level entry point for accessing Hydra.
Adapter class providing data exchange with the client scene graph.
std::vector< TfToken > TfTokenVector
Convenience types.
A named, semantic collection of objects.
A path value used to locate objects in layers or scenegraphs.
static SDF_API const SdfPath & AbsoluteRootPath()
The absolute path representing the top of the namespace hierarchy.
static HD_API HdRenderIndex * New(HdRenderDelegate *renderDelegate, HdDriverVector const &drivers)
Create a render index with the given render delegate.
USDIMAGING_API void Populate(UsdPrim const &rootPrim)
Populates the rootPrim in the HdRenderIndex.
Describes one or more authored display representations for an rprim.
static USD_API UsdStageRefPtr Open(const std::string &filePath, InitialLoadSet load=LoadAll)
Attempt to find a matching existing stage in a cache if UsdStageCacheContext objects exist on the sta...
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.