24 #ifndef PXR_IMAGING_HD_SCENE_DELEGATE_H
25 #define PXR_IMAGING_HD_SCENE_DELEGATE_H
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
31 #include "pxr/imaging/hd/aov.h"
32 #include "pxr/imaging/hd/basisCurvesTopology.h"
33 #include "pxr/imaging/hd/enums.h"
34 #include "pxr/imaging/hd/meshTopology.h"
35 #include "pxr/imaging/hd/renderIndex.h"
36 #include "pxr/imaging/hd/repr.h"
37 #include "pxr/imaging/hd/timeSampleArray.h"
43 #include "pxr/base/vt/value.h"
44 #include "pxr/usd/sdf/path.h"
52 PXR_NAMESPACE_OPEN_SCOPE
57 typedef std::shared_ptr<SdfPathVector> HdIdVectorSharedPtr;
60 typedef std::vector<std::pair<SdfPath, int>> HdInstancerContext;
73 std::vector<HdDirtyBits> dirtyBits;
113 bool flatShading =
false,
114 bool displacement =
true,
115 bool occludedSelectionShowsThrough_ =
false)
121 if (refineLevel_ < 0) {
123 }
else if (refineLevel_ > 8) {
139 return !(*
this == rhs);
161 HdInterpolation interp_,
162 TfToken const& role_=HdPrimvarRoleTokens->none,
171 return !(*
this == rhs);
175 typedef std::vector<HdPrimvarDescriptor> HdPrimvarDescriptorVector;
188 TfToken sourceComputationOutputName;
194 HdInterpolation interp_,
196 SdfPath const & sourceComputationId_,
197 TfToken const & sourceComputationOutputName_,
200 , sourceComputationId(sourceComputationId_)
201 , sourceComputationOutputName(sourceComputationOutputName_)
202 , valueType(valueType_)
205 return HdPrimvarDescriptor::operator==(rhs) &&
206 sourceComputationId == rhs.sourceComputationId &&
207 sourceComputationOutputName == rhs.sourceComputationOutputName &&
208 valueType == rhs.valueType;
211 return !(*
this == rhs);
215 typedef std::vector<HdExtComputationPrimvarDescriptor>
216 HdExtComputationPrimvarDescriptorVector;
229 TfToken sourceComputationOutputName;
234 SdfPath const & sourceComputationId_,
235 TfToken const & sourceComputationOutputName_)
236 : name(name_), sourceComputationId(sourceComputationId_)
237 , sourceComputationOutputName(sourceComputationOutputName_)
241 return name == rhs.name &&
242 sourceComputationId == rhs.sourceComputationId &&
243 sourceComputationOutputName == rhs.sourceComputationOutputName;
246 return !(*
this == rhs);
250 typedef std::vector<HdExtComputationInputDescriptor>
251 HdExtComputationInputDescriptorVector;
267 : name(name_), valueType(valueType_)
271 return name == rhs.name &&
272 valueType == rhs.valueType;
275 return !(*
this == rhs);
279 typedef std::vector<HdExtComputationOutputDescriptor>
280 HdExtComputationOutputDescriptorVector;
294 TfToken const & fieldPrimType_,
296 : fieldName(fieldName_), fieldPrimType(fieldPrimType_), fieldId(fieldId_)
300 typedef std::vector<HdVolumeFieldDescriptor>
301 HdVolumeFieldDescriptorVector;
315 virtual ~HdSceneDelegate();
409 VtIntArray *outIndices);
426 virtual std::vector<VtArray<TfToken>>
447 size_t maxSampleCount,
454 template <
unsigned int CAPACITY>
458 size_t authoredSamples =
460 if (authoredSamples > CAPACITY) {
461 sa->
Resize(authoredSamples);
462 size_t authoredSamplesSecondAttempt =
470 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
472 sa->count = authoredSamples;
485 size_t maxSampleCount,
493 template <
unsigned int CAPACITY>
497 size_t authoredSamples =
503 if (authoredSamples > CAPACITY) {
504 sa->
Resize(authoredSamples);
505 size_t authoredSamplesSecondAttempt =
513 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
515 sa->count = authoredSamples;
539 size_t maxSampleCount,
546 template <
unsigned int CAPACITY>
561 size_t maxSampleCount,
564 VtIntArray *sampleIndices);
569 template <
unsigned int CAPACITY>
620 HdInstancerContext *instancerContext =
nullptr);
667 virtual HdVolumeFieldDescriptorVector
668 GetVolumeFieldDescriptors(
SdfPath const &volumeId);
691 virtual HdExtComputationInputDescriptorVector
699 virtual HdExtComputationOutputDescriptorVector
711 virtual HdExtComputationPrimvarDescriptorVector
713 HdInterpolation interpolationMode);
731 size_t maxSampleCount,
739 template <
unsigned int CAPACITY>
744 computationId, input, CAPACITY,
745 sa->times.
data(), sa->values.data());
747 if (authoredSamples > CAPACITY) {
748 sa->
Resize(authoredSamples);
750 computationId, input, authoredSamples,
751 sa->times.
data(), sa->values.data());
754 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
756 sa->count = authoredSamples;
785 virtual HdPrimvarDescriptorVector
798 HdSceneDelegate() =
delete;
799 HdSceneDelegate(HdSceneDelegate &) =
delete;
800 HdSceneDelegate &operator=(HdSceneDelegate &) =
delete;
803 template <
unsigned int CAPACITY>
808 size_t authoredSamples =
815 if (authoredSamples > CAPACITY) {
816 sa->
Resize(authoredSamples);
817 size_t authoredSamplesSecondAttempt =
826 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
828 sa->count = authoredSamples;
831 template <
unsigned int CAPACITY>
836 size_t authoredSamples =
844 if (authoredSamples > CAPACITY) {
845 sa->
Resize(authoredSamples);
846 size_t authoredSamplesSecondAttempt =
856 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
858 sa->count = authoredSamples;
861 PXR_NAMESPACE_CLOSE_SCOPE
863 #endif //PXR_IMAGING_HD_SCENE_DELEGATE_H
virtual HD_API bool IsEnabled(TfToken const &option) const
Returns true if the named option is enabled by the delegate.
Interface class that defines the execution environment for the client to run a computation.
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Basic type: 3-dimensional floating point range.
virtual HD_API void InvokeExtComputation(SdfPath const &computationId, HdExtComputationContext *context)
Requests the scene delegate run the ExtComputation with the given id.
virtual HD_API HdBasisCurvesTopology GetBasisCurvesTopology(SdfPath const &id)
Gets the topological curve data for a given prim.
Describes how the geometry of a prim should be displayed.
value_type * data()
Direct access to the underlying array.
virtual HD_API VtValue GetShadingStyle(SdfPath const &id)
Returns the shading style for the given prim.
HdDisplayStyle(int refineLevel_, bool flatShading=false, bool displacement=true, bool occludedSelectionShowsThrough_=false)
Creates a DisplayStyle.
virtual HD_API VtValue Get(SdfPath const &id, TfToken const &key)
Returns a named value.
virtual HD_API TfTokenVector GetExtComputationSceneInputNames(SdfPath const &computationId)
For the given computation id, returns a list of inputs which will be requested from the scene delegat...
HdTupleType represents zero, one, or more values of the same HdType.
virtual HD_API SdfPath GetMaterialId(SdfPath const &rprimId)
Returns the material ID bound to the rprim rprimId.
virtual HD_API std::vector< VtArray< TfToken > > GetInstanceCategories(SdfPath const &instancerId)
Returns the categories for all instances in the instancer.
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Describes the allocation structure of a render buffer bprim.
bool flatShadingEnabled
Is the prim flat shaded.
virtual HD_API GfMatrix4d GetInstancerTransform(SdfPath const &instancerId)
Returns the instancer transform.
void SampleExtComputationInput(SdfPath const &computationId, TfToken const &input, HdTimeSampleArray< VtValue, CAPACITY > *sa)
Convenience form of SampleExtComputationInput() that takes an HdTimeSampleArray.
TfToken name
Name of the primvar.
virtual HD_API bool GetDoubleSided(SdfPath const &id)
Returns the doubleSided state for the given prim.
virtual HD_API void PostSyncCleanup()
Opportunity for the delegate to clean itself up after performing parallel work during sync phase...
virtual HD_API VtValue GetCameraParamValue(SdfPath const &cameraId, TfToken const ¶mName)
Returns a single value for a given camera and parameter.
virtual HD_API GfMatrix4d GetTransform(SdfPath const &id)
Returns the object space transform, including all parent transforms.
virtual HD_API HdExtComputationOutputDescriptorVector GetExtComputationOutputDescriptors(SdfPath const &computationId)
For the given computation id, returns a list of computation output descriptors.
virtual HD_API HdIdVectorSharedPtr GetCoordSysBindings(SdfPath const &id)
Returns the coordinate system bindings, or a nullptr if none are bound.
virtual HD_API size_t SampleExtComputationInput(SdfPath const &computationId, TfToken const &input, size_t maxSampleCount, float *sampleTimes, VtValue *sampleValues)
Return up to maxSampleCount samples for a given computation id and input token.
virtual HD_API HdRenderBufferDescriptor GetRenderBufferDescriptor(SdfPath const &id)
Returns the allocation descriptor for a given render buffer prim.
void SampleInstancerTransform(SdfPath const &instancerId, HdTimeSampleArray< GfMatrix4d, CAPACITY > *sa)
Convenience form of SampleInstancerTransform() that takes an HdTimeSampleArray.
Token for efficient comparison, assignment, and hashing of known strings.
virtual HD_API HdExtComputationPrimvarDescriptorVector GetExtComputationPrimvarDescriptors(SdfPath const &id, HdInterpolation interpolationMode)
Returns a list of primvar names that should be bound to a generated output from an ExtComputation for...
Describes an output of an ExtComputation.
HdInterpolation interpolation
Interpolation (data-sampling rate) of the primvar.
Description of a single field related to a volume primitive.
virtual HD_API size_t SampleTransform(SdfPath const &id, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues)
Store up to maxSampleCount transform samples in *sampleValues.
Stores a 4x4 matrix of double elements.
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
virtual HD_API size_t SamplePrimvar(SdfPath const &id, TfToken const &key, size_t maxSampleCount, float *sampleTimes, VtValue *sampleValues)
Store up to maxSampleCount primvar samples in *samplesValues.
virtual HD_API HdCullStyle GetCullStyle(SdfPath const &id)
Returns the cullstyle for the given prim.
Adapter class providing data exchange with the client scene graph.
virtual HD_API SdfPathVector GetInstancerPrototypes(SdfPath const &instancerId)
Returns a list of prototypes of this instancer.
std::vector< TfToken > TfTokenVector
Convenience types.
bool occludedSelectionShowsThrough
Does the prim act "transparent" to allow occluded selection to show through?
void SampleTransform(SdfPath const &id, HdTimeSampleArray< GfMatrix4d, CAPACITY > *sa)
Convenience form of SampleTransform() that takes an HdTimeSampleArray.
A path value used to locate objects in layers or scenegraphs.
bool indexed
Optional bool, true if primvar is indexed.
virtual HD_API VtValue GetExtComputationInput(SdfPath const &computationId, TfToken const &input)
Returns a single value for a given computation id and input token.
Topology data for basisCurves.
virtual HD_API void Sync(HdSyncRequestVector *request)
Synchronizes the delegate state for the given request vector.
virtual HD_API bool GetVisible(SdfPath const &id)
Returns the authored visible state of the prim.
virtual HD_API size_t SampleIndexedPrimvar(SdfPath const &id, TfToken const &key, size_t maxSampleCount, float *sampleTimes, VtValue *sampleValues, VtIntArray *sampleIndices)
SamplePrimvar() for getting an unflattened primvar and its indices.
virtual HD_API VtValue GetIndexedPrimvar(SdfPath const &id, TfToken const &key, VtIntArray *outIndices)
Returns a named primvar value.
int refineLevel
The prim refine level, in the range [0, 8].
HdDisplayStyle()
Creates a default DisplayStyle.
virtual HD_API HdExtComputationInputDescriptorVector GetExtComputationInputDescriptors(SdfPath const &computationId)
For the given computation id, returns a list of computation input descriptors.
virtual HD_API HdPrimvarDescriptorVector GetPrimvarDescriptors(SdfPath const &id, HdInterpolation interpolation)
Returns descriptors for all primvars of the given interpolation type.
virtual HD_API HdMeshTopology GetMeshTopology(SdfPath const &id)
Gets the topological mesh data for a given prim.
virtual HD_API GfRange3d GetExtent(SdfPath const &id)
Gets the axis aligned bounds of a prim.
virtual HD_API HdReprSelector GetReprSelector(SdfPath const &id)
Returns the authored repr (if any) for the given prim.
void Resize(unsigned int newSize) override
Resize the internal buffers.
The SceneDelegate is requested to synchronize prims as the result of executing a specific render pass...
virtual HD_API PxOsdSubdivTags GetSubdivTags(SdfPath const &id)
Gets the subdivision surface tags (sharpness, holes, etc).
virtual HD_API TfToken GetRenderTag(SdfPath const &id)
Returns the render tag that will be used to bucket prims during render pass bucketing.
Describes one or more authored display representations for an rprim.
virtual HD_API VtIntArray GetInstanceIndices(SdfPath const &instancerId, SdfPath const &prototypeId)
Gets the extracted indices array of the prototype id used in the instancer.
virtual HD_API size_t SampleInstancerTransform(SdfPath const &instancerId, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues)
Store up to maxSampleCount transform samples in *sampleValues.
An array of a value sampled over time, in struct-of-arrays layout.
Extends HdPrimvarDescriptor to describe a primvar that takes data from the output of an ExtComputatio...
virtual void Resize(unsigned int newSize)
Resize the internal buffers.
virtual HD_API HdDisplayStyle GetDisplayStyle(SdfPath const &id)
Returns the refinement level for the given prim in the range [0,8].
bool displacementEnabled
Is the prim displacement shaded.
virtual HD_API std::string GetExtComputationKernel(SdfPath const &computationId)
Returns the kernel source assigned to the computation at the path id.
virtual HD_API SdfPath GetInstancerId(SdfPath const &primId)
Returns the parent instancer of the given rprim or instancer.
TfToken role
Optional "role" indicating a desired interpretation – for example, to distinguish color/vector/point/...
Topology data for meshes.
SdfPath const & GetDelegateID() const
Returns the ID of this delegate, which is used as a prefix for all objects it creates in the RenderIn...
HdRenderIndex & GetRenderIndex()
Returns the RenderIndex owned by this delegate.
An array of a value and its indices sampled over time, in struct-of-arrays layout.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
virtual HD_API SdfPath GetScenePrimPath(SdfPath const &rprimId, int instanceIndex, HdInstancerContext *instancerContext=nullptr)
Returns the scene address of the prim corresponding to the given rprim/instance index.
virtual HD_API VtArray< TfToken > GetCategories(SdfPath const &id)
Returns the prim categories.