7 #ifndef PXR_USD_IMAGING_USD_IMAGING_UNIT_TEST_HELPER_H 8 #define PXR_USD_IMAGING_USD_IMAGING_UNIT_TEST_HELPER_H 15 #include "pxr/imaging/hd/changeTracker.h" 16 #include "pxr/imaging/hd/engine.h" 17 #include "pxr/imaging/hd/renderIndex.h" 18 #include "pxr/imaging/hd/renderPass.h" 19 #include "pxr/imaging/hd/rprim.h" 20 #include "pxr/imaging/hd/rprimCollection.h" 21 #include "pxr/imaging/hd/tokens.h" 22 #include "pxr/imaging/hd/unitTestNullRenderDelegate.h" 23 #include "pxr/imaging/hd/unitTestNullRenderPass.h" 28 PXR_NAMESPACE_OPEN_SCOPE
30 using HdRenderPassSharedPtr = std::shared_ptr<HdRenderPass>;
33 class UsdImaging_TestTask final :
public HdTask 36 UsdImaging_TestTask(HdRenderPassSharedPtr
const &renderPass,
39 , _renderPass(renderPass)
40 , _renderTags(renderTags)
46 HdDirtyBits* dirtyBits)
override {
49 *dirtyBits = HdChangeTracker::Clean;
52 virtual void Prepare(HdTaskContext* ctx,
56 virtual void Execute(HdTaskContext* ctx)
override {
64 HdRenderPassSharedPtr _renderPass;
76 class UsdImaging_TestDriver final {
78 UsdImaging_TestDriver(std::string
const& usdFilePath)
81 , _renderIndex(nullptr)
91 renderTags.push_back(HdRenderTagTokens->geometry);
99 UsdImaging_TestDriver(std::string
const& usdFilePath,
105 , _renderIndex(nullptr)
120 UsdImaging_TestDriver(UsdStageRefPtr
const& usdStage)
123 , _renderIndex(nullptr)
133 renderTags.push_back(HdRenderTagTokens->geometry);
138 UsdImaging_TestDriver(UsdStageRefPtr
const& usdStage,
144 , _renderIndex(nullptr)
156 UsdImaging_TestDriver(UsdStageRefPtr
const& usdStage,
162 , _renderIndex(nullptr)
167 _Init(usdStage, collection, delegateId, renderTags);
170 ~UsdImaging_TestDriver()
177 HdTaskSharedPtrVector tasks = {
178 std::make_shared<UsdImaging_TestTask>(_geometryPass, _renderTags)
180 _engine.Execute(&_delegate->GetRenderIndex(), &tasks);
182 void SetTime(
double time) {
183 _delegate->SetTime(time);
187 void MarkRprimDirty(
SdfPath path, HdDirtyBits flag) {
188 _delegate->GetRenderIndex().GetChangeTracker()
189 .MarkRprimDirty(path, flag);
198 UsdStageRefPtr
const& GetStage() {
204 Hd_UnitTestNullRenderDelegate _renderDelegate;
207 HdRenderPassSharedPtr _geometryPass;
208 UsdStageRefPtr _stage;
211 void _Init(UsdStageRefPtr
const& usdStage,
220 _delegate->
Populate(_stage->GetPseudoRoot());
222 _geometryPass = HdRenderPassSharedPtr(
223 new Hd_UnitTestNullRenderPass(_renderIndex, collection));
225 _renderTags = renderTags;
229 PXR_NAMESPACE_CLOSE_SCOPE
231 #endif //PXR_USD_IMAGING_USD_IMAGING_UNIT_TEST_HELPER_H The render index is part of the Hydra 1.0 API and is only used for emulation purposes so that HdScene...
virtual void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits)=0
Sync Phase: Obtain task state from Scene delegate based on change processing.
virtual HD_API const TfTokenVector & GetRenderTags() const
Render Tag Gather.
static HD_API HdRenderIndex * New(HdRenderDelegate *renderDelegate, HdDriverVector const &drivers, const std::string &instanceName=std::string(), const std::string &appName=std::string())
"instanceName" is an optional identifier useful for applications to associate this render index with ...
virtual void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex)=0
Prepare Phase: Resolve bindings and manage resources.
Token for efficient comparison, assignment, and hashing of known strings.
virtual void Execute(HdTaskContext *ctx)=0
Execute Phase: Runs the task.
#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.
HdTask represents a unit of work to perform during a Hydra render.
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.
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.