24 #ifndef USDIMAGING_UNIT_TEST_HELPER
25 #define USDIMAGING_UNIT_TEST_HELPER
30 #include "pxr/usdImaging/usdImaging/delegate.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"
43 #include <boost/shared_ptr.hpp>
45 PXR_NAMESPACE_OPEN_SCOPE
48 typedef boost::shared_ptr<HdRenderPass> HdRenderPassSharedPtr;
51 class UsdImaging_TestTask final :
public HdTask
54 UsdImaging_TestTask(HdRenderPassSharedPtr
const &renderPass,
57 , _renderPass(renderPass)
58 , _renderTags(renderTags)
64 HdDirtyBits* dirtyBits)
override {
67 *dirtyBits = HdChangeTracker::Clean;
70 virtual void Prepare(HdTaskContext* ctx,
74 virtual void Execute(HdTaskContext* ctx)
override {
82 HdRenderPassSharedPtr _renderPass;
94 class UsdImaging_TestDriver final {
96 UsdImaging_TestDriver(std::string
const& usdFilePath)
99 , _renderIndex(nullptr)
109 renderTags.push_back(HdRenderTagTokens->geometry);
117 UsdImaging_TestDriver(std::string
const& usdFilePath,
123 , _renderIndex(nullptr)
141 , _renderIndex(nullptr)
151 renderTags.push_back(HdRenderTagTokens->geometry);
162 , _renderIndex(nullptr)
180 , _renderIndex(nullptr)
185 _Init(usdStage, collection, delegateId, renderTags);
188 ~UsdImaging_TestDriver()
195 HdTaskSharedPtrVector tasks = {
196 boost::make_shared<UsdImaging_TestTask>(_geometryPass, _renderTags)
198 _engine.Execute(&_delegate->GetRenderIndex(), &tasks);
200 void SetTime(
double time) {
201 _delegate->SetTime(time);
205 void MarkRprimDirty(
SdfPath path, HdDirtyBits flag) {
206 _delegate->GetRenderIndex().GetChangeTracker()
207 .MarkRprimDirty(path, flag);
222 Hd_UnitTestNullRenderDelegate _renderDelegate;
225 HdRenderPassSharedPtr _geometryPass;
240 _geometryPass = HdRenderPassSharedPtr(
241 new Hd_UnitTestNullRenderPass(_renderIndex, collection));
243 _renderTags = renderTags;
247 PXR_NAMESPACE_CLOSE_SCOPE
249 #endif //USDIMAGING_UNIT_TEST_HELPER
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
USD_API UsdPrim GetPseudoRoot() const
Return the stage's "pseudo-root" prim, whose name is defined by Usd.
static USDIMAGING_API void Populate(std::vector< UsdImagingDelegate * > const &delegates, UsdPrimVector const &rootPrims, std::vector< SdfPathVector > const &excludedPrimPaths, std::vector< SdfPathVector > const &invisedPrimPaths)
Populates the rootPrim in the HdRenderIndex in each delegate, excluding all paths in the excludedPrim...
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.
static HD_API HdRenderIndex * New(HdRenderDelegate *renderDelegate)
Create a render index with the given render delegate.
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.
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.