This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
sceneDelegate.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_SCENE_DELEGATE_H
8#define PXR_IMAGING_HD_SCENE_DELEGATE_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hd/api.h"
12#include "pxr/imaging/hd/version.h"
13
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"
21
23
24#include "pxr/base/vt/array.h"
26#include "pxr/base/vt/value.h"
28#include "pxr/usd/sdf/path.h"
29
30#include "pxr/base/gf/vec2i.h"
31#include "pxr/base/tf/hash.h"
32
33#include <memory>
34#include <vector>
35
36PXR_NAMESPACE_OPEN_SCOPE
37
39
41typedef std::shared_ptr<SdfPathVector> HdIdVectorSharedPtr;
42
44typedef std::vector<std::pair<SdfPath, int>> HdInstancerContext;
45
53 // The Prims to synchronize in this request.
54 SdfPathVector IDs;
55
56 // The HdChangeTracker::DirtyBits that are set for each Prim.
57 std::vector<HdDirtyBits> dirtyBits;
58};
59
70
73
76
79
83
87
91
100 : refineLevel(0)
101 , flatShadingEnabled(false)
102 , displacementEnabled(true)
103 , displayInOverlay(false)
105 , pointsShadingEnabled(false)
106 , materialIsFinal(false)
107 { }
108
122 HdDisplayStyle(int refineLevel_,
123 bool flatShading = false,
124 bool displacement = true,
125 bool displayInOverlay_ = false,
126 bool occludedSelectionShowsThrough_ = false,
127 bool pointsShadingEnabled_ = false,
128 bool materialIsFinal_ = false)
129 : refineLevel(std::max(0, refineLevel_))
130 , flatShadingEnabled(flatShading)
131 , displacementEnabled(displacement)
132 , displayInOverlay(displayInOverlay_)
133 , occludedSelectionShowsThrough(occludedSelectionShowsThrough_)
134 , pointsShadingEnabled(pointsShadingEnabled_)
135 , materialIsFinal(materialIsFinal_)
136 {
137 if (refineLevel_ < 0) {
138 TF_CODING_ERROR("negative refine level is not supported");
139 } else if (refineLevel_ > 8) {
140 TF_CODING_ERROR("refine level > 8 is not supported");
141 }
142 }
143
144 HdDisplayStyle(HdDisplayStyle const& rhs) = default;
145 ~HdDisplayStyle() = default;
146
147 bool operator==(HdDisplayStyle const& rhs) const {
148 return refineLevel == rhs.refineLevel
156 }
157 bool operator!=(HdDisplayStyle const& rhs) const {
158 return !(*this == rhs);
159 }
160};
161
169 HdInterpolation interpolation;
177
179 : interpolation(HdInterpolationConstant)
180 , role(HdPrimvarRoleTokens->none)
181 , indexed(false)
182 {}
183 HdPrimvarDescriptor(TfToken const& name_,
184 HdInterpolation interp_,
185 TfToken const& role_=HdPrimvarRoleTokens->none,
186 bool indexed_=false)
187 : name(name_), interpolation(interp_), role(role_), indexed(indexed_)
188 { }
189 bool operator==(HdPrimvarDescriptor const& rhs) const {
190 return name == rhs.name && role == rhs.role
192 }
193 bool operator!=(HdPrimvarDescriptor const& rhs) const {
194 return !(*this == rhs);
195 }
196};
197
198typedef std::vector<HdPrimvarDescriptor> HdPrimvarDescriptorVector;
199
213 // Alternate imaging mode. Options are origin, bounds, cards, default, and
214 // inherited.
215 TfToken drawMode;
216 // Specifies whether to apply the alternative imaging mode or not.
217 bool applyDrawMode;
218 // The color in which to draw the geometry.
219 GfVec3f drawModeColor;
220 // The specific geometry to use in cards mode. Options are cross, box, and
221 // fromTexture.
222 TfToken cardGeometry;
223 // The textures applied to the respective quads in cards mode.
224 SdfAssetPath cardTextureXPos;
225 SdfAssetPath cardTextureYPos;
226 SdfAssetPath cardTextureZPos;
227 SdfAssetPath cardTextureXNeg;
228 SdfAssetPath cardTextureYNeg;
229 SdfAssetPath cardTextureZNeg;
230
232 : drawMode(HdModelDrawModeTokens->inherited)
233 , applyDrawMode(false)
234 , drawModeColor(GfVec3f(0.18))
235 , cardGeometry(HdModelDrawModeTokens->cross)
236 {}
237
240 TfToken const& drawMode_,
241 bool applyDrawMode_=false,
242 GfVec3f drawModeColor_=GfVec3f(0.18),
243 TfToken const& cardGeometry_=HdModelDrawModeTokens->cross,
244 SdfAssetPath cardTextureXPos_=SdfAssetPath(),
245 SdfAssetPath cardTextureYPos_=SdfAssetPath(),
246 SdfAssetPath cardTextureZPos_=SdfAssetPath(),
247 SdfAssetPath cardTextureXNeg_=SdfAssetPath(),
248 SdfAssetPath cardTextureYNeg_=SdfAssetPath(),
249 SdfAssetPath cardTextureZNeg_=SdfAssetPath())
250 : drawMode(drawMode_), applyDrawMode(applyDrawMode_),
251 drawModeColor(drawModeColor_), cardGeometry(cardGeometry_),
252 cardTextureXPos(cardTextureXPos_), cardTextureYPos(cardTextureYPos_),
253 cardTextureZPos(cardTextureZPos_), cardTextureXNeg(cardTextureXNeg_),
254 cardTextureYNeg(cardTextureYNeg_), cardTextureZNeg(cardTextureZNeg_)
255 {}
256
257 bool operator==(HdModelDrawMode const& rhs) const {
258 return drawMode == rhs.drawMode &&
259 applyDrawMode == rhs.applyDrawMode &&
260 drawModeColor == rhs.drawModeColor &&
261 cardGeometry == rhs.cardGeometry &&
262 cardTextureXPos == rhs.cardTextureXPos &&
263 cardTextureYPos == rhs.cardTextureYPos &&
264 cardTextureZPos == rhs.cardTextureZPos &&
265 cardTextureXNeg == rhs.cardTextureXNeg &&
266 cardTextureYNeg == rhs.cardTextureYNeg &&
267 cardTextureZNeg == rhs.cardTextureZNeg;
268 }
269 bool operator!=(HdModelDrawMode const& rhs) const {
270 return !(*this == rhs);
271 }
272};
273
284 SdfPath sourceComputationId;
285 TfToken sourceComputationOutputName;
286 HdTupleType valueType;
287
290 TfToken const& name_,
291 HdInterpolation interp_,
292 TfToken const & role_,
293 SdfPath const & sourceComputationId_,
294 TfToken const & sourceComputationOutputName_,
295 HdTupleType const & valueType_)
296 : HdPrimvarDescriptor(name_, interp_, role_, false)
297 , sourceComputationId(sourceComputationId_)
298 , sourceComputationOutputName(sourceComputationOutputName_)
299 , valueType(valueType_)
300 { }
301 bool operator==(HdExtComputationPrimvarDescriptor const& rhs) const {
302 return HdPrimvarDescriptor::operator==(rhs) &&
303 sourceComputationId == rhs.sourceComputationId &&
304 sourceComputationOutputName == rhs.sourceComputationOutputName &&
305 valueType == rhs.valueType;
306 }
307 bool operator!=(HdExtComputationPrimvarDescriptor const& rhs) const {
308 return !(*this == rhs);
309 }
310};
311
312typedef std::vector<HdExtComputationPrimvarDescriptor>
313 HdExtComputationPrimvarDescriptorVector;
314
324 TfToken name;
325 SdfPath sourceComputationId;
326 TfToken sourceComputationOutputName;
327
330 TfToken const & name_,
331 SdfPath const & sourceComputationId_,
332 TfToken const & sourceComputationOutputName_)
333 : name(name_), sourceComputationId(sourceComputationId_)
334 , sourceComputationOutputName(sourceComputationOutputName_)
335 { }
336
337 bool operator==(HdExtComputationInputDescriptor const& rhs) const {
338 return name == rhs.name &&
339 sourceComputationId == rhs.sourceComputationId &&
340 sourceComputationOutputName == rhs.sourceComputationOutputName;
341 }
342 bool operator!=(HdExtComputationInputDescriptor const& rhs) const {
343 return !(*this == rhs);
344 }
345};
346
347typedef std::vector<HdExtComputationInputDescriptor>
348 HdExtComputationInputDescriptorVector;
349
357 TfToken name;
358 HdTupleType valueType;
359
362 TfToken const & name_,
363 HdTupleType const & valueType_)
364 : name(name_), valueType(valueType_)
365 { }
366
367 bool operator==(HdExtComputationOutputDescriptor const& rhs) const {
368 return name == rhs.name &&
369 valueType == rhs.valueType;
370 }
371 bool operator!=(HdExtComputationOutputDescriptor const& rhs) const {
372 return !(*this == rhs);
373 }
374};
375
376typedef std::vector<HdExtComputationOutputDescriptor>
377 HdExtComputationOutputDescriptorVector;
378
384 TfToken fieldName;
385 TfToken fieldPrimType;
386 SdfPath fieldId;
387
390 TfToken const & fieldName_,
391 TfToken const & fieldPrimType_,
392 SdfPath const & fieldId_)
393 : fieldName(fieldName_), fieldPrimType(fieldPrimType_), fieldId(fieldId_)
394 { }
395};
396
397typedef std::vector<HdVolumeFieldDescriptor>
398 HdVolumeFieldDescriptorVector;
399
405public:
407 HD_API
409 SdfPath const& delegateID);
410
411 HD_API
412 virtual ~HdSceneDelegate();
413
415 HdRenderIndex& GetRenderIndex() { return *_index; }
416
421 SdfPath const& GetDelegateID() const { return _delegateID; }
422
424 HD_API
425 virtual void Sync(HdSyncRequestVector* request);
426
429 HD_API
430 virtual void PostSyncCleanup();
431
432 // -----------------------------------------------------------------------//
434 // -----------------------------------------------------------------------//
435
437 HD_API
438 virtual bool IsEnabled(TfToken const& option) const;
439
440
441 // -----------------------------------------------------------------------//
443 // -----------------------------------------------------------------------//
444
446 HD_API
448
450 HD_API
452
454 HD_API
456
457
465 HD_API
466 virtual GfRange3d GetExtent(SdfPath const & id);
467
469 HD_API
470 virtual GfMatrix4d GetTransform(SdfPath const & id);
471
473 HD_API
474 virtual bool GetVisible(SdfPath const & id);
475
477 HD_API
478 virtual bool GetDoubleSided(SdfPath const & id);
479
481 HD_API
482 virtual HdCullStyle GetCullStyle(SdfPath const &id);
483
485 HD_API
486 virtual VtValue GetShadingStyle(SdfPath const &id);
487
489 HD_API
491
493 HD_API
494 virtual VtValue Get(SdfPath const& id, TfToken const& key);
495
500 HD_API
502 TfToken const& key,
503 VtIntArray *outIndices);
504
506 HD_API
508
511 HD_API
512 virtual TfToken GetRenderTag(SdfPath const& id);
513
516 HD_API
518
520 HD_API
521 virtual std::vector<VtArray<TfToken>>
522 GetInstanceCategories(SdfPath const &instancerId);
523
525 HD_API
526 virtual HdIdVectorSharedPtr GetCoordSysBindings(SdfPath const& id);
527
529 HD_API
531
532 // -----------------------------------------------------------------------//
534 // -----------------------------------------------------------------------//
535
551 HD_API
552 virtual size_t
554 size_t maxSampleCount,
555 float *sampleTimes,
556 GfMatrix4d *sampleValues);
557
561 HD_API
562 virtual size_t
564 float startTime,
565 float endTime,
566 size_t maxSampleCount,
567 float *sampleTimes,
568 GfMatrix4d *sampleValues);
569
573 template <unsigned int CAPACITY>
574 void
575 SampleTransform(SdfPath const & id,
577
582 template <unsigned int CAPACITY>
583 void
584 SampleTransform(SdfPath const & id,
585 float startTime,
586 float endTime,
588
604 HD_API
605 virtual size_t
607 size_t maxSampleCount,
608 float *sampleTimes,
609 GfMatrix4d *sampleValues);
610
614 HD_API
615 virtual size_t
617 float startTime,
618 float endTime,
619 size_t maxSampleCount,
620 float *sampleTimes,
621 GfMatrix4d *sampleValues);
622
627 template <unsigned int CAPACITY>
628 void
629 SampleInstancerTransform(SdfPath const &instancerId,
631
636 template <unsigned int CAPACITY>
637 void
638 SampleInstancerTransform(SdfPath const &instancerId,
639 float startTime, float endTime,
641
666 HD_API
667 virtual size_t
669 TfToken const& key,
670 size_t maxSampleCount,
671 float *sampleTimes,
672 VtValue *sampleValues);
673
677 HD_API
678 virtual size_t
680 TfToken const& key,
681 float startTime,
682 float endTime,
683 size_t maxSampleCount,
684 float *sampleTimes,
685 VtValue *sampleValues);
686
690 template <unsigned int CAPACITY>
691 void
692 SamplePrimvar(SdfPath const &id,
693 TfToken const& key,
695
700 template <unsigned int CAPACITY>
701 void
702 SamplePrimvar(SdfPath const &id,
703 TfToken const& key,
704 float startTime,
705 float endTime,
707
713 HD_API
714 virtual size_t
716 TfToken const& key,
717 size_t maxSampleCount,
718 float *sampleTimes,
719 VtValue *sampleValues,
720 VtIntArray *sampleIndices);
721
725 HD_API
726 virtual size_t
728 TfToken const& key,
729 float startTime,
730 float endTime,
731 size_t maxSampleCount,
732 float *sampleTimes,
733 VtValue *sampleValues,
734 VtIntArray *sampleIndices);
735
740 template <unsigned int CAPACITY>
741 void
742 SampleIndexedPrimvar(SdfPath const &id,
743 TfToken const& key,
745
750 template <unsigned int CAPACITY>
751 void
752 SampleIndexedPrimvar(SdfPath const &id,
753 TfToken const& key,
754 float startTime,
755 float endTime,
757
758 // -----------------------------------------------------------------------//
760 // -----------------------------------------------------------------------//
761
774 HD_API
775 virtual VtIntArray GetInstanceIndices(SdfPath const &instancerId,
776 SdfPath const &prototypeId);
777
779 HD_API
780 virtual GfMatrix4d GetInstancerTransform(SdfPath const &instancerId);
781
783 HD_API
784 virtual SdfPath GetInstancerId(SdfPath const& primId);
785
790 HD_API
791 virtual SdfPathVector GetInstancerPrototypes(SdfPath const& instancerId);
792
793 // -----------------------------------------------------------------------//
795 // -----------------------------------------------------------------------//
796
801 HD_API
802 virtual SdfPath GetScenePrimPath(SdfPath const& rprimId,
803 int instanceIndex,
804 HdInstancerContext *instancerContext = nullptr);
805
811 HD_API
812 virtual SdfPathVector GetScenePrimPaths(SdfPath const& rprimId,
813 std::vector<int> instanceIndices,
814 std::vector<HdInstancerContext> *instancerContexts = nullptr);
815
816 // -----------------------------------------------------------------------//
818 // -----------------------------------------------------------------------//
819
821 HD_API
822 virtual SdfPath GetMaterialId(SdfPath const &rprimId);
823
824 // Returns a material resource which contains the information
825 // needed to create a material.
826 HD_API
827 virtual VtValue GetMaterialResource(SdfPath const &materialId);
828
829 // -----------------------------------------------------------------------//
831 // -----------------------------------------------------------------------//
832
834 HD_API
836
837 // -----------------------------------------------------------------------//
839 // -----------------------------------------------------------------------//
840
841 // Returns a single value for a given light and parameter.
842 HD_API
843 virtual VtValue GetLightParamValue(SdfPath const &id,
844 TfToken const &paramName);
845
846 // -----------------------------------------------------------------------//
848 // -----------------------------------------------------------------------//
849
852 HD_API
853 virtual VtValue GetCameraParamValue(SdfPath const& cameraId,
854 TfToken const& paramName);
855
856 // -----------------------------------------------------------------------//
858 // -----------------------------------------------------------------------//
859
860 HD_API
861 virtual HdVolumeFieldDescriptorVector
862 GetVolumeFieldDescriptors(SdfPath const &volumeId);
863
864 // -----------------------------------------------------------------------//
866 // -----------------------------------------------------------------------//
867
875 HD_API
876 virtual TfTokenVector
878
884 HD_API
885 virtual HdExtComputationInputDescriptorVector
887
892 HD_API
893 virtual HdExtComputationOutputDescriptorVector
895
896
904 HD_API
905 virtual HdExtComputationPrimvarDescriptorVector
907 HdInterpolation interpolationMode);
908
911 HD_API
912 virtual VtValue GetExtComputationInput(SdfPath const& computationId,
913 TfToken const& input);
914
922 HD_API
923 virtual size_t SampleExtComputationInput(SdfPath const& computationId,
924 TfToken const& input,
925 size_t maxSampleCount,
926 float *sampleTimes,
927 VtValue *sampleValues);
928
929 // An overload of SampleTransform that explicitly takes the startTime
930 // and endTime rather than relying on the scene delegate having state
931 // about what the source of the current shutter interval should be.
932 HD_API
933 virtual size_t SampleExtComputationInput(SdfPath const& computationId,
934 TfToken const& input,
935 float startTime,
936 float endTime,
937 size_t maxSampleCount,
938 float *sampleTimes,
939 VtValue *sampleValues);
940
945 template <unsigned int CAPACITY>
946 void SampleExtComputationInput(SdfPath const& computationId,
947 TfToken const& input,
949
954 template <unsigned int CAPACITY>
955 void SampleExtComputationInput(SdfPath const& computationId,
956 TfToken const& input,
957 float startTime,
958 float endTime,
960
964 HD_API
965 virtual std::string GetExtComputationKernel(SdfPath const& computationId);
966
977 HD_API
978 virtual void InvokeExtComputation(SdfPath const& computationId,
979 HdExtComputationContext *context);
980
981 // -----------------------------------------------------------------------//
983 // -----------------------------------------------------------------------//
984
986 HD_API
987 virtual HdPrimvarDescriptorVector
988 GetPrimvarDescriptors(SdfPath const& id, HdInterpolation interpolation);
989
990 // -----------------------------------------------------------------------//
992 // -----------------------------------------------------------------------//
993 HD_API
994 virtual TfTokenVector GetTaskRenderTags(SdfPath const& taskId);
995
996private:
997 HdRenderIndex *_index;
998 SdfPath _delegateID;
999
1000 HdSceneDelegate() = delete;
1001 HdSceneDelegate(HdSceneDelegate &) = delete;
1002 HdSceneDelegate &operator=(HdSceneDelegate &) = delete;
1003};
1004
1005template <unsigned int CAPACITY>
1006void
1009 size_t authoredSamples =
1010 SampleTransform(id, CAPACITY, sa->times.data(), sa->values.data());
1011 if (authoredSamples > CAPACITY) {
1012 sa->Resize(authoredSamples);
1013 size_t authoredSamplesSecondAttempt =
1015 id,
1016 authoredSamples,
1017 sa->times.data(),
1018 sa->values.data());
1019 // Number of samples should be consisntent through multiple
1020 // invokations of the sampling function.
1021 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1022 }
1023 sa->count = authoredSamples;
1024}
1025
1026template <unsigned int CAPACITY>
1027void
1029 float startTime,
1030 float endTime,
1032 size_t authoredSamples =
1033 SampleTransform(id, startTime, endTime, CAPACITY,
1034 sa->times.data(), sa->values.data());
1035 if (authoredSamples > CAPACITY) {
1036 sa->Resize(authoredSamples);
1037 size_t authoredSamplesSecondAttempt =
1039 id,
1040 startTime,
1041 endTime,
1042 authoredSamples,
1043 sa->times.data(),
1044 sa->values.data());
1045 // Number of samples should be consisntent through multiple
1046 // invokations of the sampling function.
1047 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1048 }
1049 sa->count = authoredSamples;
1050}
1051
1052template <unsigned int CAPACITY>
1053void
1055 SdfPath const &instancerId,
1057 size_t authoredSamples =
1059 instancerId,
1060 CAPACITY,
1061 sa->times.data(),
1062 sa->values.data());
1063 if (authoredSamples > CAPACITY) {
1064 sa->Resize(authoredSamples);
1065 size_t authoredSamplesSecondAttempt =
1067 instancerId,
1068 authoredSamples,
1069 sa->times.data(),
1070 sa->values.data());
1071 // Number of samples should be consisntent through multiple
1072 // invokations of the sampling function.
1073 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1074 }
1075 sa->count = authoredSamples;
1076}
1077
1078template <unsigned int CAPACITY>
1079void
1081 SdfPath const &instancerId,
1082 float startTime, float endTime,
1084 size_t authoredSamples =
1086 instancerId,
1087 startTime,
1088 endTime,
1089 CAPACITY,
1090 sa->times.data(),
1091 sa->values.data());
1092 if (authoredSamples > CAPACITY) {
1093 sa->Resize(authoredSamples);
1094 size_t authoredSamplesSecondAttempt =
1096 instancerId,
1097 startTime,
1098 endTime,
1099 authoredSamples,
1100 sa->times.data(),
1101 sa->values.data());
1102 // Number of samples should be consisntent through multiple
1103 // invokations of the sampling function.
1104 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1105 }
1106 sa->count = authoredSamples;
1107}
1108
1109template <unsigned int CAPACITY>
1110void
1112 TfToken const& key,
1114 size_t authoredSamples =
1116 id,
1117 key,
1118 CAPACITY,
1119 sa->times.data(),
1120 sa->values.data());
1121 if (authoredSamples > CAPACITY) {
1122 sa->Resize(authoredSamples);
1123 size_t authoredSamplesSecondAttempt =
1125 id,
1126 key,
1127 authoredSamples,
1128 sa->times.data(),
1129 sa->values.data());
1130 // Number of samples should be consistent through multiple
1131 // invocations of the sampling function.
1132 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1133 }
1134 sa->count = authoredSamples;
1135}
1136
1137template <unsigned int CAPACITY>
1138void
1140 TfToken const& key,
1141 float startTime,
1142 float endTime,
1144 size_t authoredSamples =
1146 id,
1147 key,
1148 startTime,
1149 endTime,
1150 CAPACITY,
1151 sa->times.data(),
1152 sa->values.data());
1153 if (authoredSamples > CAPACITY) {
1154 sa->Resize(authoredSamples);
1155 size_t authoredSamplesSecondAttempt =
1157 id,
1158 key,
1159 startTime,
1160 endTime,
1161 authoredSamples,
1162 sa->times.data(),
1163 sa->values.data());
1164 // Number of samples should be consistent through multiple
1165 // invocations of the sampling function.
1166 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1167 }
1168 sa->count = authoredSamples;
1169}
1170
1171template <unsigned int CAPACITY>
1172void
1174 TfToken const& key,
1176 size_t authoredSamples =
1178 id,
1179 key,
1180 CAPACITY,
1181 sa->times.data(),
1182 sa->values.data(),
1183 sa->indices.data());
1184 if (authoredSamples > CAPACITY) {
1185 sa->Resize(authoredSamples);
1186 size_t authoredSamplesSecondAttempt =
1188 id,
1189 key,
1190 authoredSamples,
1191 sa->times.data(),
1192 sa->values.data(),
1193 sa->indices.data());
1194 // Number of samples should be consistent through multiple
1195 // invocations of the sampling function.
1196 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1197 }
1198 sa->count = authoredSamples;
1199}
1200
1201template <unsigned int CAPACITY>
1202void
1204 TfToken const& key,
1205 float startTime,
1206 float endTime,
1208 size_t authoredSamples =
1210 id,
1211 key,
1212 startTime,
1213 endTime,
1214 CAPACITY,
1215 sa->times.data(),
1216 sa->values.data(),
1217 sa->indices.data());
1218 if (authoredSamples > CAPACITY) {
1219 sa->Resize(authoredSamples);
1220 size_t authoredSamplesSecondAttempt =
1222 id,
1223 key,
1224 startTime,
1225 endTime,
1226 authoredSamples,
1227 sa->times.data(),
1228 sa->values.data(),
1229 sa->indices.data());
1230 // Number of samples should be consistent through multiple
1231 // invocations of the sampling function.
1232 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1233 }
1234 sa->count = authoredSamples;
1235}
1236
1237template <unsigned int CAPACITY>
1238void
1240 SdfPath const& computationId,
1241 TfToken const& input,
1243 size_t authoredSamples = SampleExtComputationInput(
1244 computationId, input, CAPACITY,
1245 sa->times.data(), sa->values.data());
1246
1247 if (authoredSamples > CAPACITY) {
1248 sa->Resize(authoredSamples);
1249 size_t authoredSamplesSecondAttempt = SampleExtComputationInput(
1250 computationId, input, authoredSamples,
1251 sa->times.data(), sa->values.data());
1252 // Number of samples should be consisntent through multiple
1253 // invokations of the sampling function.
1254 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1255 }
1256 sa->count = authoredSamples;
1257}
1258
1259template <unsigned int CAPACITY>
1260void
1262 SdfPath const& computationId,
1263 TfToken const& input,
1264 float startTime,
1265 float endTime,
1267 size_t authoredSamples = SampleExtComputationInput(
1268 computationId, input, startTime, endTime, CAPACITY,
1269 sa->times.data(), sa->values.data());
1270
1271 if (authoredSamples > CAPACITY) {
1272 sa->Resize(authoredSamples);
1273 size_t authoredSamplesSecondAttempt = SampleExtComputationInput(
1274 computationId, input, startTime, endTime, authoredSamples,
1275 sa->times.data(), sa->values.data());
1276 // Number of samples should be consisntent through multiple
1277 // invokations of the sampling function.
1278 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1279 }
1280 sa->count = authoredSamples;
1281}
1282
1283PXR_NAMESPACE_CLOSE_SCOPE
1284
1285#endif //PXR_IMAGING_HD_SCENE_DELEGATE_H
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Basic type: 3-dimensional floating point range.
Definition: range3d.h:47
Basic type for a vector of 3 float components.
Definition: vec3f.h:46
Topology data for basisCurves.
Interface class that defines the execution environment for the client to run a computation.
Topology data for meshes.
Definition: meshTopology.h:38
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:105
Describes one or more authored display representations for an rprim.
Definition: repr.h:32
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 &paramName)
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.
Tags for non-hierarchial subdiv surfaces.
Definition: subdivTags.h:26
Contains an asset path and optional evaluated and resolved paths.
Definition: assetPath.h:73
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
value_type * data()
Direct access to the underlying array.
Definition: smallVector.h:735
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:213
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:68
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition: diagnostic.h:266
STL namespace.
Describes how the geometry of a prim should be displayed.
Definition: sceneDelegate.h:64
bool flatShadingEnabled
Is the prim flat shaded.
Definition: sceneDelegate.h:72
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.
Definition: sceneDelegate.h:75
bool pointsShadingEnabled
Should the prim's points get shaded like surfaces, as opposed to constant shaded?
Definition: sceneDelegate.h:86
HdDisplayStyle()
Creates a default DisplayStyle.
Definition: sceneDelegate.h:99
bool materialIsFinal
Is this prim exempt from having its material disabled or overridden, for example, when a renderer cho...
Definition: sceneDelegate.h:90
int refineLevel
The prim refine level, in the range [0, 8].
Definition: sceneDelegate.h:69
bool occludedSelectionShowsThrough
Does the prim act "transparent" to allow occluded selection to show through?
Definition: sceneDelegate.h:82
bool displayInOverlay
Is the prim overlayed on top of other prims.
Definition: sceneDelegate.h:78
Describes an input to an ExtComputation that takes data from the output of another ExtComputation.
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.
Describes a primvar.
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/...
TfToken name
Name of the primvar.
Describes the allocation structure of a render buffer bprim.
Definition: aov.h:67
The SceneDelegate is requested to synchronize prims as the result of executing a specific render pass...
Definition: sceneDelegate.h:52
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.
Definition: types.h:343
Description of a single field related to a volume primitive.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440