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"
28PXR_NAMESPACE_OPEN_SCOPE
30using HdRenderPassSharedPtr = std::shared_ptr<HdRenderPass>;
33class 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;
76class 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;
229PXR_NAMESPACE_CLOSE_SCOPE
The application-facing entry point top-level entry point for accessing Hydra.
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
static HD_API HdRenderIndex * New(HdRenderDelegate *renderDelegate, HdDriverVector const &drivers, const std::string &instanceName=std::string(), const std::string &appName=std::string())
Create a render index with the given render delegate.
Describes one or more authored display representations for an rprim.
A named, semantic collection of objects.
Adapter class providing data exchange with the client scene graph.
HdTask represents a unit of work to perform during a Hydra render.
virtual void Execute(HdTaskContext *ctx)=0
Execute Phase: Runs the task.
virtual HD_API const TfTokenVector & GetRenderTags() const
Render Tag Gather.
virtual void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex)=0
Prepare Phase: Resolve bindings and manage resources.
virtual void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits)=0
Sync Phase: Obtain task state from Scene delegate based on change processing.
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.
Token for efficient comparison, assignment, and hashing of known strings.
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
USDIMAGING_API void Populate(UsdPrim const &rootPrim)
Populates the rootPrim in the HdRenderIndex.
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...
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
std::vector< TfToken > TfTokenVector
Convenience types.