7#ifndef PXR_IMAGING_HD_SCENE_DELEGATE_H
8#define PXR_IMAGING_HD_SCENE_DELEGATE_H
11#include "pxr/imaging/hd/api.h"
12#include "pxr/imaging/hd/version.h"
14#include "pxr/imaging/hd/aov.h"
15#include "pxr/imaging/hd/basisCurvesTopology.h"
16#include "pxr/imaging/hd/enums.h"
17#include "pxr/imaging/hd/meshTopology.h"
18#include "pxr/imaging/hd/renderIndex.h"
19#include "pxr/imaging/hd/repr.h"
20#include "pxr/imaging/hd/timeSampleArray.h"
26#include "pxr/base/vt/value.h"
28#include "pxr/usd/sdf/path.h"
36PXR_NAMESPACE_OPEN_SCOPE
41typedef std::shared_ptr<SdfPathVector> HdIdVectorSharedPtr;
44typedef std::vector<std::pair<SdfPath, int>> HdInstancerContext;
57 std::vector<HdDirtyBits> dirtyBits;
123 bool flatShading =
false,
124 bool displacement =
true,
125 bool displayInOverlay_ =
false,
126 bool occludedSelectionShowsThrough_ =
false,
127 bool pointsShadingEnabled_ =
false,
128 bool materialIsFinal_ =
false)
137 if (refineLevel_ < 0) {
139 }
else if (refineLevel_ > 8) {
158 return !(*
this == rhs);
183 ,
role(HdPrimvarRoleTokens->none)
188 HdInterpolation interp_,
189 TfToken const& role_=HdPrimvarRoleTokens->none,
190 bool indexed_=
false,
int elementSize_=1)
200 return !(*
this == rhs);
204typedef std::vector<HdPrimvarDescriptor> HdPrimvarDescriptorVector;
238 : drawMode(HdModelDrawModeTokens->inherited)
239 , applyDrawMode(
false)
241 , cardGeometry(HdModelDrawModeTokens->cross)
247 bool applyDrawMode_=
false,
249 TfToken const& cardGeometry_=HdModelDrawModeTokens->cross,
256 : drawMode(drawMode_), applyDrawMode(applyDrawMode_),
257 drawModeColor(drawModeColor_), cardGeometry(cardGeometry_),
258 cardTextureXPos(cardTextureXPos_), cardTextureYPos(cardTextureYPos_),
259 cardTextureZPos(cardTextureZPos_), cardTextureXNeg(cardTextureXNeg_),
260 cardTextureYNeg(cardTextureYNeg_), cardTextureZNeg(cardTextureZNeg_)
264 return drawMode == rhs.drawMode &&
265 applyDrawMode == rhs.applyDrawMode &&
266 drawModeColor == rhs.drawModeColor &&
267 cardGeometry == rhs.cardGeometry &&
268 cardTextureXPos == rhs.cardTextureXPos &&
269 cardTextureYPos == rhs.cardTextureYPos &&
270 cardTextureZPos == rhs.cardTextureZPos &&
271 cardTextureXNeg == rhs.cardTextureXNeg &&
272 cardTextureYNeg == rhs.cardTextureYNeg &&
273 cardTextureZNeg == rhs.cardTextureZNeg;
276 return !(*
this == rhs);
291 TfToken sourceComputationOutputName;
297 HdInterpolation interp_,
299 SdfPath const & sourceComputationId_,
300 TfToken const & sourceComputationOutputName_,
303 , sourceComputationId(sourceComputationId_)
304 , sourceComputationOutputName(sourceComputationOutputName_)
305 , valueType(valueType_)
308 return HdPrimvarDescriptor::operator==(rhs) &&
309 sourceComputationId == rhs.sourceComputationId &&
310 sourceComputationOutputName == rhs.sourceComputationOutputName &&
311 valueType == rhs.valueType;
314 return !(*
this == rhs);
318typedef std::vector<HdExtComputationPrimvarDescriptor>
319 HdExtComputationPrimvarDescriptorVector;
332 TfToken sourceComputationOutputName;
337 SdfPath const & sourceComputationId_,
338 TfToken const & sourceComputationOutputName_)
339 : name(name_), sourceComputationId(sourceComputationId_)
340 , sourceComputationOutputName(sourceComputationOutputName_)
344 return name == rhs.name &&
345 sourceComputationId == rhs.sourceComputationId &&
346 sourceComputationOutputName == rhs.sourceComputationOutputName;
349 return !(*
this == rhs);
353typedef std::vector<HdExtComputationInputDescriptor>
354 HdExtComputationInputDescriptorVector;
370 : name(name_), valueType(valueType_)
374 return name == rhs.name &&
375 valueType == rhs.valueType;
378 return !(*
this == rhs);
382typedef std::vector<HdExtComputationOutputDescriptor>
383 HdExtComputationOutputDescriptorVector;
397 TfToken const & fieldPrimType_,
399 : fieldName(fieldName_), fieldPrimType(fieldPrimType_), fieldId(fieldId_)
403typedef std::vector<HdVolumeFieldDescriptor>
404 HdVolumeFieldDescriptorVector;
509 VtIntArray *outIndices);
527 virtual std::vector<VtArray<TfToken>>
560 size_t maxSampleCount,
572 size_t maxSampleCount,
579 template <
unsigned int CAPACITY>
588 template <
unsigned int CAPACITY>
613 size_t maxSampleCount,
625 size_t maxSampleCount,
633 template <
unsigned int CAPACITY>
642 template <
unsigned int CAPACITY>
645 float startTime,
float endTime,
676 size_t maxSampleCount,
689 size_t maxSampleCount,
696 template <
unsigned int CAPACITY>
706 template <
unsigned int CAPACITY>
723 size_t maxSampleCount,
726 VtIntArray *sampleIndices);
737 size_t maxSampleCount,
740 VtIntArray *sampleIndices);
746 template <
unsigned int CAPACITY>
756 template <
unsigned int CAPACITY>
810 HdInstancerContext *instancerContext =
nullptr);
819 std::vector<int> instanceIndices,
820 std::vector<HdInstancerContext> *instancerContexts =
nullptr);
872 virtual HdVolumeFieldDescriptorVector
873 GetVolumeFieldDescriptors(
SdfPath const &volumeId);
896 virtual HdExtComputationInputDescriptorVector
904 virtual HdExtComputationOutputDescriptorVector
916 virtual HdExtComputationPrimvarDescriptorVector
918 HdInterpolation interpolationMode);
936 size_t maxSampleCount,
948 size_t maxSampleCount,
956 template <
unsigned int CAPACITY>
965 template <
unsigned int CAPACITY>
998 virtual HdPrimvarDescriptorVector
1016template <
unsigned int CAPACITY>
1020 size_t authoredSamples =
1022 if (authoredSamples > CAPACITY) {
1023 sa->
Resize(authoredSamples);
1024 size_t authoredSamplesSecondAttempt =
1032 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1034 sa->count = authoredSamples;
1037template <
unsigned int CAPACITY>
1043 size_t authoredSamples =
1045 sa->times.
data(), sa->values.
data());
1046 if (authoredSamples > CAPACITY) {
1047 sa->
Resize(authoredSamples);
1048 size_t authoredSamplesSecondAttempt =
1058 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1060 sa->count = authoredSamples;
1063template <
unsigned int CAPACITY>
1068 size_t authoredSamples =
1074 if (authoredSamples > CAPACITY) {
1075 sa->
Resize(authoredSamples);
1076 size_t authoredSamplesSecondAttempt =
1084 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1086 sa->count = authoredSamples;
1089template <
unsigned int CAPACITY>
1093 float startTime,
float endTime,
1095 size_t authoredSamples =
1103 if (authoredSamples > CAPACITY) {
1104 sa->
Resize(authoredSamples);
1105 size_t authoredSamplesSecondAttempt =
1115 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1117 sa->count = authoredSamples;
1120template <
unsigned int CAPACITY>
1125 size_t authoredSamples =
1132 if (authoredSamples > CAPACITY) {
1133 sa->
Resize(authoredSamples);
1134 size_t authoredSamplesSecondAttempt =
1143 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1145 sa->count = authoredSamples;
1148template <
unsigned int CAPACITY>
1155 size_t authoredSamples =
1164 if (authoredSamples > CAPACITY) {
1165 sa->
Resize(authoredSamples);
1166 size_t authoredSamplesSecondAttempt =
1177 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1179 sa->count = authoredSamples;
1182template <
unsigned int CAPACITY>
1187 size_t authoredSamples =
1194 sa->indices.
data());
1195 if (authoredSamples > CAPACITY) {
1196 sa->
Resize(authoredSamples);
1197 size_t authoredSamplesSecondAttempt =
1204 sa->indices.
data());
1207 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1209 sa->count = authoredSamples;
1212template <
unsigned int CAPACITY>
1219 size_t authoredSamples =
1228 sa->indices.
data());
1229 if (authoredSamples > CAPACITY) {
1230 sa->
Resize(authoredSamples);
1231 size_t authoredSamplesSecondAttempt =
1240 sa->indices.
data());
1243 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1245 sa->count = authoredSamples;
1248template <
unsigned int CAPACITY>
1255 computationId, input, CAPACITY,
1256 sa->times.
data(), sa->values.
data());
1258 if (authoredSamples > CAPACITY) {
1259 sa->
Resize(authoredSamples);
1261 computationId, input, authoredSamples,
1262 sa->times.
data(), sa->values.
data());
1265 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1267 sa->count = authoredSamples;
1270template <
unsigned int CAPACITY>
1279 computationId, input, startTime, endTime, CAPACITY,
1280 sa->times.
data(), sa->values.
data());
1282 if (authoredSamples > CAPACITY) {
1283 sa->
Resize(authoredSamples);
1285 computationId, input, startTime, endTime, authoredSamples,
1286 sa->times.
data(), sa->values.
data());
1289 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1291 sa->count = authoredSamples;
1294PXR_NAMESPACE_CLOSE_SCOPE
Stores a 4x4 matrix of double elements.
Basic type: 3-dimensional floating point range.
Basic type for a vector of 3 float components.
Topology data for basisCurves.
Interface class that defines the execution environment for the client to run a computation.
Topology data for meshes.
The render index is part of the Hydra 1.0 API and is only used for emulation purposes so that HdScene...
Describes one or more authored display representations for an rprim.
Adapter class providing data exchange with the client scene graph.
virtual HD_API HdRenderBufferDescriptor GetRenderBufferDescriptor(SdfPath const &id)
Returns the allocation descriptor for a given render buffer 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 TfToken GetRenderTag(SdfPath const &id)
Returns the render tag that will be used to bucket prims during render pass bucketing.
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 SdfPath GetInstancerId(SdfPath const &primId)
Returns the parent instancer of the given rprim or instancer.
virtual HD_API size_t SamplePrimvar(SdfPath const &id, TfToken const &key, float startTime, float endTime, size_t maxSampleCount, float *sampleTimes, VtValue *sampleValues)
An overload of SamplePrimvar that takes frame-relative startTime and endTime, rather than relying on ...
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 HdPrimvarDescriptorVector GetPrimvarDescriptors(SdfPath const &id, HdInterpolation interpolation)
Returns descriptors for all primvars of the given interpolation type.
virtual HD_API HdDisplayStyle GetDisplayStyle(SdfPath const &id)
Returns the display style for the given prim.
virtual HD_API VtValue GetShadingStyle(SdfPath const &id)
Returns the shading style for the given prim.
virtual HD_API bool IsEnabled(TfToken const &option) const
Returns true if the named option is enabled by the delegate.
virtual HD_API SdfPathVector GetInstancerPrototypes(SdfPath const &instancerId)
Returns a list of prototypes of this instancer.
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 VtValue GetCameraParamValue(SdfPath const &cameraId, TfToken const ¶mName)
Returns a single value for a given camera and parameter.
virtual HD_API SdfPath GetMaterialId(SdfPath const &rprimId)
Returns the material ID bound to the rprim rprimId.
virtual HD_API GfRange3d GetExtent(SdfPath const &id)
Gets the axis aligned bounds of a prim.
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.
HD_API HdSceneDelegate(HdRenderIndex *parentIndex, SdfPath const &delegateID)
Constructor used for nested delegate objects which share a RenderIndex.
virtual HD_API GfMatrix4d GetInstancerTransform(SdfPath const &instancerId)
Returns the instancer transform.
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...
virtual HD_API size_t SampleTransform(SdfPath const &id, float startTime, float endTime, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues)
An overload of SampleTransform that takes frame-relative startTime and endTime, rather than relying o...
virtual HD_API SdfPathVector GetScenePrimPaths(SdfPath const &rprimId, std::vector< int > instanceIndices, std::vector< HdInstancerContext > *instancerContexts=nullptr)
A vectorized version of GetScenePrimPath that allows the prim adapter to amortize expensive calculati...
virtual HD_API size_t SampleInstancerTransform(SdfPath const &instancerId, float startTime, float endTime, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues)
An overload of SampleInstancerTransform that takes frame-relative startTime and endTime,...
virtual HD_API void PostSyncCleanup()
Opportunity for the delegate to clean itself up after performing parallel work during sync phase.
virtual HD_API size_t SampleIndexedPrimvar(SdfPath const &id, TfToken const &key, float startTime, float endTime, size_t maxSampleCount, float *sampleTimes, VtValue *sampleValues, VtIntArray *sampleIndices)
An overload of SampleIndexedPrimvar that takes frame-relative startTime and endTime,...
virtual HD_API size_t SampleTransform(SdfPath const &id, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues)
Store up to maxSampleCount transform samples in *sampleValues.
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...
SdfPath const & GetDelegateID() const
Returns the ID of this delegate, which is used as a prefix for all objects it creates in the RenderIn...
virtual HD_API bool GetDoubleSided(SdfPath const &id)
Returns the doubleSided state for the given prim.
virtual HD_API VtArray< TfToken > GetCategories(SdfPath const &id)
Returns the prim categories.
virtual HD_API void Sync(HdSyncRequestVector *request)
Synchronizes the delegate state for the given request vector.
virtual HD_API HdIdVectorSharedPtr GetCoordSysBindings(SdfPath const &id)
Returns the coordinate system bindings, or a nullptr if none are bound.
virtual HD_API VtValue GetExtComputationInput(SdfPath const &computationId, TfToken const &input)
Returns a single value for a given computation id and input token.
virtual HD_API size_t SampleInstancerTransform(SdfPath const &instancerId, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues)
Store up to maxSampleCount transform samples in *sampleValues.
HdRenderIndex & GetRenderIndex()
Returns the RenderIndex owned by this delegate.
virtual HD_API void InvokeExtComputation(SdfPath const &computationId, HdExtComputationContext *context)
Requests the scene delegate run the ExtComputation with the given id.
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 VtValue Get(SdfPath const &id, TfToken const &key)
Returns a named value.
virtual HD_API VtValue GetIndexedPrimvar(SdfPath const &id, TfToken const &key, VtIntArray *outIndices)
Returns a named primvar value.
virtual HD_API HdExtComputationInputDescriptorVector GetExtComputationInputDescriptors(SdfPath const &computationId)
For the given computation id, returns a list of computation input descriptors.
virtual HD_API HdMeshTopology GetMeshTopology(SdfPath const &id)
Gets the topological mesh data for a given prim.
virtual HD_API HdReprSelector GetReprSelector(SdfPath const &id)
Returns the authored repr (if any) for the given prim.
virtual HD_API PxOsdSubdivTags GetSubdivTags(SdfPath const &id)
Gets the subdivision surface tags (sharpness, holes, etc).
virtual HD_API HdModelDrawMode GetModelDrawMode(SdfPath const &id)
Returns the model draw mode object for the given prim.
virtual HD_API HdBasisCurvesTopology GetBasisCurvesTopology(SdfPath const &id)
Gets the topological curve data for a given prim.
virtual HD_API bool GetVisible(SdfPath const &id)
Returns the authored visible state of the prim.
virtual HD_API std::string GetExtComputationKernel(SdfPath const &computationId)
Returns the kernel source assigned to the computation at the path id.
virtual HD_API std::vector< VtArray< TfToken > > GetInstanceCategories(SdfPath const &instancerId)
Returns the categories for each of the instances in the instancer.
virtual HD_API HdCullStyle GetCullStyle(SdfPath const &id)
Returns the cullstyle for the given prim.
Contains an asset path and optional evaluated and resolved paths.
A path value used to locate objects in layers or scenegraphs.
value_type * data()
Direct access to the underlying array.
Token for efficient comparison, assignment, and hashing of known strings.
Represents an arbitrary dimensional rectangular container class.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Describes how the geometry of a prim should be displayed.
bool flatShadingEnabled
Is the prim flat shaded.
HdDisplayStyle(int refineLevel_, bool flatShading=false, bool displacement=true, bool displayInOverlay_=false, bool occludedSelectionShowsThrough_=false, bool pointsShadingEnabled_=false, bool materialIsFinal_=false)
Creates a DisplayStyle.
bool displacementEnabled
Is the prim displacement shaded.
bool pointsShadingEnabled
Should the prim's points get shaded like surfaces, as opposed to constant shaded?
HdDisplayStyle()
Creates a default DisplayStyle.
bool materialIsFinal
Is this prim exempt from having its material disabled or overridden, for example, when a renderer cho...
int refineLevel
The prim refine level, in the range [0, 8].
bool occludedSelectionShowsThrough
Does the prim act "transparent" to allow occluded selection to show through?
bool displayInOverlay
Is the prim overlayed on top of other prims.
Describes an output of an ExtComputation.
Extends HdPrimvarDescriptor to describe a primvar that takes data from the output of an ExtComputatio...
An array of a value and its indices sampled over time, in struct-of-arrays layout.
void Resize(unsigned int newSize) override
Resize the internal buffers.
Describes optional alternative imaging behavior for prims.
HdModelDrawMode(TfToken const &drawMode_, bool applyDrawMode_=false, GfVec3f drawModeColor_=GfVec3f(0.18), TfToken const &cardGeometry_=HdModelDrawModeTokens->cross, SdfAssetPath cardTextureXPos_=SdfAssetPath(), SdfAssetPath cardTextureYPos_=SdfAssetPath(), SdfAssetPath cardTextureZPos_=SdfAssetPath(), SdfAssetPath cardTextureXNeg_=SdfAssetPath(), SdfAssetPath cardTextureYNeg_=SdfAssetPath(), SdfAssetPath cardTextureZNeg_=SdfAssetPath())
DrawModeColor is specified in the rendering color space.
bool indexed
Optional bool, true if primvar is indexed.
HdInterpolation interpolation
Interpolation (data-sampling rate) of the primvar.
TfToken role
Optional "role" indicating a desired interpretation – for example, to distinguish color/vector/point/...
int elementSize
The number of values in the value array that must be aggregated for each element in the primitive.
TfToken name
Name of the primvar.
Describes the allocation structure of a render buffer bprim.
The SceneDelegate is requested to synchronize prims as the result of executing a specific render pass...
An array of a value sampled over time, in struct-of-arrays layout.
virtual void Resize(unsigned int newSize)
Resize the internal buffers.
HdTupleType represents zero, one, or more values of the same HdType.
Description of a single field related to a volume primitive.
std::vector< TfToken > TfTokenVector
Convenience types.