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
67
70
73
77
81
85
93 : refineLevel(0)
94 , flatShadingEnabled(false)
98 , materialIsFinal(false)
99 { }
100
113 HdDisplayStyle(int refineLevel_,
114 bool flatShading = false,
115 bool displacement = true,
116 bool occludedSelectionShowsThrough_ = false,
117 bool pointsShadingEnabled_ = false,
118 bool materialIsFinal_ = false)
119 : refineLevel(std::max(0, refineLevel_))
120 , flatShadingEnabled(flatShading)
121 , displacementEnabled(displacement)
122 , occludedSelectionShowsThrough(occludedSelectionShowsThrough_)
123 , pointsShadingEnabled(pointsShadingEnabled_)
124 , materialIsFinal(materialIsFinal_)
125 {
126 if (refineLevel_ < 0) {
127 TF_CODING_ERROR("negative refine level is not supported");
128 } else if (refineLevel_ > 8) {
129 TF_CODING_ERROR("refine level > 8 is not supported");
130 }
131 }
132
133 HdDisplayStyle(HdDisplayStyle const& rhs) = default;
134 ~HdDisplayStyle() = default;
135
136 bool operator==(HdDisplayStyle const& rhs) const {
137 return refineLevel == rhs.refineLevel
144 }
145 bool operator!=(HdDisplayStyle const& rhs) const {
146 return !(*this == rhs);
147 }
148};
149
157 HdInterpolation interpolation;
165
167 : interpolation(HdInterpolationConstant)
168 , role(HdPrimvarRoleTokens->none)
169 , indexed(false)
170 {}
171 HdPrimvarDescriptor(TfToken const& name_,
172 HdInterpolation interp_,
173 TfToken const& role_=HdPrimvarRoleTokens->none,
174 bool indexed_=false)
175 : name(name_), interpolation(interp_), role(role_), indexed(indexed_)
176 { }
177 bool operator==(HdPrimvarDescriptor const& rhs) const {
178 return name == rhs.name && role == rhs.role
180 }
181 bool operator!=(HdPrimvarDescriptor const& rhs) const {
182 return !(*this == rhs);
183 }
184};
185
186typedef std::vector<HdPrimvarDescriptor> HdPrimvarDescriptorVector;
187
201 // Alternate imaging mode. Options are origin, bounds, cards, default, and
202 // inherited.
203 TfToken drawMode;
204 // Specifies whether to apply the alternative imaging mode or not.
205 bool applyDrawMode;
206 // The color in which to draw the geometry.
207 GfVec3f drawModeColor;
208 // The specific geometry to use in cards mode. Options are cross, box, and
209 // fromTexture.
210 TfToken cardGeometry;
211 // The textures applied to the respective quads in cards mode.
212 SdfAssetPath cardTextureXPos;
213 SdfAssetPath cardTextureYPos;
214 SdfAssetPath cardTextureZPos;
215 SdfAssetPath cardTextureXNeg;
216 SdfAssetPath cardTextureYNeg;
217 SdfAssetPath cardTextureZNeg;
218
220 : drawMode(HdModelDrawModeTokens->inherited)
221 , applyDrawMode(false)
222 , drawModeColor(GfVec3f(0.18))
223 , cardGeometry(HdModelDrawModeTokens->cross)
224 {}
225
227 TfToken const& drawMode_,
228 bool applyDrawMode_=false,
229 GfVec3f drawModeColor_=GfVec3f(0.18),
230 TfToken const& cardGeometry_=HdModelDrawModeTokens->cross,
231 SdfAssetPath cardTextureXPos_=SdfAssetPath(),
232 SdfAssetPath cardTextureYPos_=SdfAssetPath(),
233 SdfAssetPath cardTextureZPos_=SdfAssetPath(),
234 SdfAssetPath cardTextureXNeg_=SdfAssetPath(),
235 SdfAssetPath cardTextureYNeg_=SdfAssetPath(),
236 SdfAssetPath cardTextureZNeg_=SdfAssetPath())
237 : drawMode(drawMode_), applyDrawMode(applyDrawMode_),
238 drawModeColor(drawModeColor_), cardGeometry(cardGeometry_),
239 cardTextureXPos(cardTextureXPos_), cardTextureYPos(cardTextureYPos_),
240 cardTextureZPos(cardTextureZPos_), cardTextureXNeg(cardTextureXNeg_),
241 cardTextureYNeg(cardTextureYNeg_), cardTextureZNeg(cardTextureZNeg_)
242 {}
243
244 bool operator==(HdModelDrawMode const& rhs) const {
245 return drawMode == rhs.drawMode &&
246 applyDrawMode == rhs.applyDrawMode &&
247 drawModeColor == rhs.drawModeColor &&
248 cardGeometry == rhs.cardGeometry &&
249 cardTextureXPos == rhs.cardTextureXPos &&
250 cardTextureYPos == rhs.cardTextureYPos &&
251 cardTextureZPos == rhs.cardTextureZPos &&
252 cardTextureXNeg == rhs.cardTextureXNeg &&
253 cardTextureYNeg == rhs.cardTextureYNeg &&
254 cardTextureZNeg == rhs.cardTextureZNeg;
255 }
256 bool operator!=(HdModelDrawMode const& rhs) const {
257 return !(*this == rhs);
258 }
259};
260
271 SdfPath sourceComputationId;
272 TfToken sourceComputationOutputName;
273 HdTupleType valueType;
274
277 TfToken const& name_,
278 HdInterpolation interp_,
279 TfToken const & role_,
280 SdfPath const & sourceComputationId_,
281 TfToken const & sourceComputationOutputName_,
282 HdTupleType const & valueType_)
283 : HdPrimvarDescriptor(name_, interp_, role_, false)
284 , sourceComputationId(sourceComputationId_)
285 , sourceComputationOutputName(sourceComputationOutputName_)
286 , valueType(valueType_)
287 { }
288 bool operator==(HdExtComputationPrimvarDescriptor const& rhs) const {
289 return HdPrimvarDescriptor::operator==(rhs) &&
290 sourceComputationId == rhs.sourceComputationId &&
291 sourceComputationOutputName == rhs.sourceComputationOutputName &&
292 valueType == rhs.valueType;
293 }
294 bool operator!=(HdExtComputationPrimvarDescriptor const& rhs) const {
295 return !(*this == rhs);
296 }
297};
298
299typedef std::vector<HdExtComputationPrimvarDescriptor>
300 HdExtComputationPrimvarDescriptorVector;
301
311 TfToken name;
312 SdfPath sourceComputationId;
313 TfToken sourceComputationOutputName;
314
317 TfToken const & name_,
318 SdfPath const & sourceComputationId_,
319 TfToken const & sourceComputationOutputName_)
320 : name(name_), sourceComputationId(sourceComputationId_)
321 , sourceComputationOutputName(sourceComputationOutputName_)
322 { }
323
324 bool operator==(HdExtComputationInputDescriptor const& rhs) const {
325 return name == rhs.name &&
326 sourceComputationId == rhs.sourceComputationId &&
327 sourceComputationOutputName == rhs.sourceComputationOutputName;
328 }
329 bool operator!=(HdExtComputationInputDescriptor const& rhs) const {
330 return !(*this == rhs);
331 }
332};
333
334typedef std::vector<HdExtComputationInputDescriptor>
335 HdExtComputationInputDescriptorVector;
336
344 TfToken name;
345 HdTupleType valueType;
346
349 TfToken const & name_,
350 HdTupleType const & valueType_)
351 : name(name_), valueType(valueType_)
352 { }
353
354 bool operator==(HdExtComputationOutputDescriptor const& rhs) const {
355 return name == rhs.name &&
356 valueType == rhs.valueType;
357 }
358 bool operator!=(HdExtComputationOutputDescriptor const& rhs) const {
359 return !(*this == rhs);
360 }
361};
362
363typedef std::vector<HdExtComputationOutputDescriptor>
364 HdExtComputationOutputDescriptorVector;
365
371 TfToken fieldName;
372 TfToken fieldPrimType;
373 SdfPath fieldId;
374
377 TfToken const & fieldName_,
378 TfToken const & fieldPrimType_,
379 SdfPath const & fieldId_)
380 : fieldName(fieldName_), fieldPrimType(fieldPrimType_), fieldId(fieldId_)
381 { }
382};
383
384typedef std::vector<HdVolumeFieldDescriptor>
385 HdVolumeFieldDescriptorVector;
386
392public:
394 HD_API
396 SdfPath const& delegateID);
397
398 HD_API
399 virtual ~HdSceneDelegate();
400
402 HdRenderIndex& GetRenderIndex() { return *_index; }
403
408 SdfPath const& GetDelegateID() const { return _delegateID; }
409
411 HD_API
412 virtual void Sync(HdSyncRequestVector* request);
413
416 HD_API
417 virtual void PostSyncCleanup();
418
419 // -----------------------------------------------------------------------//
421 // -----------------------------------------------------------------------//
422
424 HD_API
425 virtual bool IsEnabled(TfToken const& option) const;
426
427
428 // -----------------------------------------------------------------------//
430 // -----------------------------------------------------------------------//
431
433 HD_API
435
437 HD_API
439
441 HD_API
443
444
452 HD_API
453 virtual GfRange3d GetExtent(SdfPath const & id);
454
456 HD_API
457 virtual GfMatrix4d GetTransform(SdfPath const & id);
458
460 HD_API
461 virtual bool GetVisible(SdfPath const & id);
462
464 HD_API
465 virtual bool GetDoubleSided(SdfPath const & id);
466
468 HD_API
469 virtual HdCullStyle GetCullStyle(SdfPath const &id);
470
472 HD_API
473 virtual VtValue GetShadingStyle(SdfPath const &id);
474
479 HD_API
481
483 HD_API
484 virtual VtValue Get(SdfPath const& id, TfToken const& key);
485
490 HD_API
492 TfToken const& key,
493 VtIntArray *outIndices);
494
496 HD_API
498
501 HD_API
502 virtual TfToken GetRenderTag(SdfPath const& id);
503
506 HD_API
508
510 HD_API
511 virtual std::vector<VtArray<TfToken>>
512 GetInstanceCategories(SdfPath const &instancerId);
513
515 HD_API
516 virtual HdIdVectorSharedPtr GetCoordSysBindings(SdfPath const& id);
517
519 HD_API
521
522 // -----------------------------------------------------------------------//
524 // -----------------------------------------------------------------------//
525
533 HD_API
534 virtual size_t
536 size_t maxSampleCount,
537 float *sampleTimes,
538 GfMatrix4d *sampleValues);
539
540 // An overload of SampleTransform that explicitly takes the startTime
541 // and endTime rather than relying on the scene delegate having state
542 // about what the source of the current shutter interval should be.
543 HD_API
544 virtual size_t
545 SampleTransform(SdfPath const & id,
546 float startTime,
547 float endTime,
548 size_t maxSampleCount,
549 float *sampleTimes,
550 GfMatrix4d *sampleValues);
551
555 template <unsigned int CAPACITY>
556 void
557 SampleTransform(SdfPath const & id,
559
563 template <unsigned int CAPACITY>
564 void
565 SampleTransform(SdfPath const & id,
566 float startTime,
567 float endTime,
569
577 HD_API
578 virtual size_t
580 size_t maxSampleCount,
581 float *sampleTimes,
582 GfMatrix4d *sampleValues);
583
584 // An overload of SampleInstancerTransform that explicitly takes the
585 // startTime and endTime rather than relying on the scene delegate
586 // having state about what the source of the current shutter interval
587 // should be.
588 HD_API
589 virtual size_t
590 SampleInstancerTransform(SdfPath const &instancerId,
591 float startTime,
592 float endTime,
593 size_t maxSampleCount,
594 float *sampleTimes,
595 GfMatrix4d *sampleValues);
596
601 template <unsigned int CAPACITY>
602 void
603 SampleInstancerTransform(SdfPath const &instancerId,
605
610 template <unsigned int CAPACITY>
611 void
612 SampleInstancerTransform(SdfPath const &instancerId,
613 float startTime, float endTime,
615
633 HD_API
634 virtual size_t
636 TfToken const& key,
637 size_t maxSampleCount,
638 float *sampleTimes,
639 VtValue *sampleValues);
640
641 // An overload of SamplePrimvar that explicitly takes the startTime
642 // and endTime rather than relying on the scene delegate having state
643 // about what the source of the current shutter interval should be.
644 HD_API
645 virtual size_t
646 SamplePrimvar(SdfPath const& id,
647 TfToken const& key,
648 float startTime,
649 float endTime,
650 size_t maxSampleCount,
651 float *sampleTimes,
652 VtValue *sampleValues);
653
657 template <unsigned int CAPACITY>
658 void
659 SamplePrimvar(SdfPath const &id,
660 TfToken const& key,
662
666 template <unsigned int CAPACITY>
667 void
668 SamplePrimvar(SdfPath const &id,
669 TfToken const& key,
670 float startTime,
671 float endTime,
673
679 HD_API
680 virtual size_t
682 TfToken const& key,
683 size_t maxSampleCount,
684 float *sampleTimes,
685 VtValue *sampleValues,
686 VtIntArray *sampleIndices);
687
688 // An overload of SampleIndexedPrimvar that explicitly takes the startTime
689 // and endTime rather than relying on the scene delegate having state
690 // about what the source of the current shutter interval should be.
691 HD_API
692 virtual size_t
693 SampleIndexedPrimvar(SdfPath const& id,
694 TfToken const& key,
695 float startTime,
696 float endTime,
697 size_t maxSampleCount,
698 float *sampleTimes,
699 VtValue *sampleValues,
700 VtIntArray *sampleIndices);
701
702
706 template <unsigned int CAPACITY>
707 void
708 SampleIndexedPrimvar(SdfPath const &id,
709 TfToken const& key,
711
715 template <unsigned int CAPACITY>
716 void
717 SampleIndexedPrimvar(SdfPath const &id,
718 TfToken const& key,
719 float startTime,
720 float endTime,
722
723 // -----------------------------------------------------------------------//
725 // -----------------------------------------------------------------------//
726
739 HD_API
740 virtual VtIntArray GetInstanceIndices(SdfPath const &instancerId,
741 SdfPath const &prototypeId);
742
744 HD_API
745 virtual GfMatrix4d GetInstancerTransform(SdfPath const &instancerId);
746
748 HD_API
749 virtual SdfPath GetInstancerId(SdfPath const& primId);
750
755 HD_API
756 virtual SdfPathVector GetInstancerPrototypes(SdfPath const& instancerId);
757
758 // -----------------------------------------------------------------------//
760 // -----------------------------------------------------------------------//
761
766 HD_API
767 virtual SdfPath GetScenePrimPath(SdfPath const& rprimId,
768 int instanceIndex,
769 HdInstancerContext *instancerContext = nullptr);
770
776 HD_API
777 virtual SdfPathVector GetScenePrimPaths(SdfPath const& rprimId,
778 std::vector<int> instanceIndices,
779 std::vector<HdInstancerContext> *instancerContexts = nullptr);
780
781 // -----------------------------------------------------------------------//
783 // -----------------------------------------------------------------------//
784
786 HD_API
787 virtual SdfPath GetMaterialId(SdfPath const &rprimId);
788
789 // Returns a material resource which contains the information
790 // needed to create a material.
791 HD_API
792 virtual VtValue GetMaterialResource(SdfPath const &materialId);
793
794 // -----------------------------------------------------------------------//
796 // -----------------------------------------------------------------------//
797
799 HD_API
801
802 // -----------------------------------------------------------------------//
804 // -----------------------------------------------------------------------//
805
806 // Returns a single value for a given light and parameter.
807 HD_API
808 virtual VtValue GetLightParamValue(SdfPath const &id,
809 TfToken const &paramName);
810
811 // -----------------------------------------------------------------------//
813 // -----------------------------------------------------------------------//
814
817 HD_API
818 virtual VtValue GetCameraParamValue(SdfPath const& cameraId,
819 TfToken const& paramName);
820
821 // -----------------------------------------------------------------------//
823 // -----------------------------------------------------------------------//
824
825 HD_API
826 virtual HdVolumeFieldDescriptorVector
827 GetVolumeFieldDescriptors(SdfPath const &volumeId);
828
829 // -----------------------------------------------------------------------//
831 // -----------------------------------------------------------------------//
832
840 HD_API
841 virtual TfTokenVector
843
849 HD_API
850 virtual HdExtComputationInputDescriptorVector
852
857 HD_API
858 virtual HdExtComputationOutputDescriptorVector
860
861
869 HD_API
870 virtual HdExtComputationPrimvarDescriptorVector
872 HdInterpolation interpolationMode);
873
876 HD_API
877 virtual VtValue GetExtComputationInput(SdfPath const& computationId,
878 TfToken const& input);
879
887 HD_API
888 virtual size_t SampleExtComputationInput(SdfPath const& computationId,
889 TfToken const& input,
890 size_t maxSampleCount,
891 float *sampleTimes,
892 VtValue *sampleValues);
893
894 // An overload of SampleTransform that explicitly takes the startTime
895 // and endTime rather than relying on the scene delegate having state
896 // about what the source of the current shutter interval should be.
897 HD_API
898 virtual size_t SampleExtComputationInput(SdfPath const& computationId,
899 TfToken const& input,
900 float startTime,
901 float endTime,
902 size_t maxSampleCount,
903 float *sampleTimes,
904 VtValue *sampleValues);
905
910 template <unsigned int CAPACITY>
911 void SampleExtComputationInput(SdfPath const& computationId,
912 TfToken const& input,
914
919 template <unsigned int CAPACITY>
920 void SampleExtComputationInput(SdfPath const& computationId,
921 TfToken const& input,
922 float startTime,
923 float endTime,
925
929 HD_API
930 virtual std::string GetExtComputationKernel(SdfPath const& computationId);
931
942 HD_API
943 virtual void InvokeExtComputation(SdfPath const& computationId,
944 HdExtComputationContext *context);
945
946 // -----------------------------------------------------------------------//
948 // -----------------------------------------------------------------------//
949
951 HD_API
952 virtual HdPrimvarDescriptorVector
953 GetPrimvarDescriptors(SdfPath const& id, HdInterpolation interpolation);
954
955 // -----------------------------------------------------------------------//
957 // -----------------------------------------------------------------------//
958 HD_API
959 virtual TfTokenVector GetTaskRenderTags(SdfPath const& taskId);
960
961private:
962 HdRenderIndex *_index;
963 SdfPath _delegateID;
964
965 HdSceneDelegate() = delete;
967 HdSceneDelegate &operator=(HdSceneDelegate &) = delete;
968};
969
970template <unsigned int CAPACITY>
971void
974 size_t authoredSamples =
975 SampleTransform(id, CAPACITY, sa->times.data(), sa->values.data());
976 if (authoredSamples > CAPACITY) {
977 sa->Resize(authoredSamples);
978 size_t authoredSamplesSecondAttempt =
980 id,
981 authoredSamples,
982 sa->times.data(),
983 sa->values.data());
984 // Number of samples should be consisntent through multiple
985 // invokations of the sampling function.
986 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
987 }
988 sa->count = authoredSamples;
989}
990
991template <unsigned int CAPACITY>
992void
994 float startTime,
995 float endTime,
997 size_t authoredSamples =
998 SampleTransform(id, startTime, endTime, CAPACITY,
999 sa->times.data(), sa->values.data());
1000 if (authoredSamples > CAPACITY) {
1001 sa->Resize(authoredSamples);
1002 size_t authoredSamplesSecondAttempt =
1004 id,
1005 startTime,
1006 endTime,
1007 authoredSamples,
1008 sa->times.data(),
1009 sa->values.data());
1010 // Number of samples should be consisntent through multiple
1011 // invokations of the sampling function.
1012 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1013 }
1014 sa->count = authoredSamples;
1015}
1016
1017template <unsigned int CAPACITY>
1018void
1020 SdfPath const &instancerId,
1022 size_t authoredSamples =
1024 instancerId,
1025 CAPACITY,
1026 sa->times.data(),
1027 sa->values.data());
1028 if (authoredSamples > CAPACITY) {
1029 sa->Resize(authoredSamples);
1030 size_t authoredSamplesSecondAttempt =
1032 instancerId,
1033 authoredSamples,
1034 sa->times.data(),
1035 sa->values.data());
1036 // Number of samples should be consisntent through multiple
1037 // invokations of the sampling function.
1038 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1039 }
1040 sa->count = authoredSamples;
1041}
1042
1043template <unsigned int CAPACITY>
1044void
1046 SdfPath const &instancerId,
1047 float startTime, float endTime,
1049 size_t authoredSamples =
1051 instancerId,
1052 startTime,
1053 endTime,
1054 CAPACITY,
1055 sa->times.data(),
1056 sa->values.data());
1057 if (authoredSamples > CAPACITY) {
1058 sa->Resize(authoredSamples);
1059 size_t authoredSamplesSecondAttempt =
1061 instancerId,
1062 startTime,
1063 endTime,
1064 authoredSamples,
1065 sa->times.data(),
1066 sa->values.data());
1067 // Number of samples should be consisntent through multiple
1068 // invokations of the sampling function.
1069 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1070 }
1071 sa->count = authoredSamples;
1072}
1073
1074template <unsigned int CAPACITY>
1075void
1077 TfToken const& key,
1079 size_t authoredSamples =
1081 id,
1082 key,
1083 CAPACITY,
1084 sa->times.data(),
1085 sa->values.data());
1086 if (authoredSamples > CAPACITY) {
1087 sa->Resize(authoredSamples);
1088 size_t authoredSamplesSecondAttempt =
1090 id,
1091 key,
1092 authoredSamples,
1093 sa->times.data(),
1094 sa->values.data());
1095 // Number of samples should be consistent through multiple
1096 // invocations of the sampling function.
1097 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1098 }
1099 sa->count = authoredSamples;
1100}
1101
1102template <unsigned int CAPACITY>
1103void
1105 TfToken const& key,
1106 float startTime,
1107 float endTime,
1109 size_t authoredSamples =
1111 id,
1112 key,
1113 startTime,
1114 endTime,
1115 CAPACITY,
1116 sa->times.data(),
1117 sa->values.data());
1118 if (authoredSamples > CAPACITY) {
1119 sa->Resize(authoredSamples);
1120 size_t authoredSamplesSecondAttempt =
1122 id,
1123 key,
1124 startTime,
1125 endTime,
1126 authoredSamples,
1127 sa->times.data(),
1128 sa->values.data());
1129 // Number of samples should be consistent through multiple
1130 // invocations of the sampling function.
1131 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1132 }
1133 sa->count = authoredSamples;
1134}
1135
1136template <unsigned int CAPACITY>
1137void
1139 TfToken const& key,
1141 size_t authoredSamples =
1143 id,
1144 key,
1145 CAPACITY,
1146 sa->times.data(),
1147 sa->values.data(),
1148 sa->indices.data());
1149 if (authoredSamples > CAPACITY) {
1150 sa->Resize(authoredSamples);
1151 size_t authoredSamplesSecondAttempt =
1153 id,
1154 key,
1155 authoredSamples,
1156 sa->times.data(),
1157 sa->values.data(),
1158 sa->indices.data());
1159 // Number of samples should be consistent through multiple
1160 // invocations of the sampling function.
1161 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1162 }
1163 sa->count = authoredSamples;
1164}
1165
1166template <unsigned int CAPACITY>
1167void
1169 TfToken const& key,
1170 float startTime,
1171 float endTime,
1173 size_t authoredSamples =
1175 id,
1176 key,
1177 startTime,
1178 endTime,
1179 CAPACITY,
1180 sa->times.data(),
1181 sa->values.data(),
1182 sa->indices.data());
1183 if (authoredSamples > CAPACITY) {
1184 sa->Resize(authoredSamples);
1185 size_t authoredSamplesSecondAttempt =
1187 id,
1188 key,
1189 startTime,
1190 endTime,
1191 authoredSamples,
1192 sa->times.data(),
1193 sa->values.data(),
1194 sa->indices.data());
1195 // Number of samples should be consistent through multiple
1196 // invocations of the sampling function.
1197 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1198 }
1199 sa->count = authoredSamples;
1200}
1201
1202template <unsigned int CAPACITY>
1203void
1205 SdfPath const& computationId,
1206 TfToken const& input,
1208 size_t authoredSamples = SampleExtComputationInput(
1209 computationId, input, CAPACITY,
1210 sa->times.data(), sa->values.data());
1211
1212 if (authoredSamples > CAPACITY) {
1213 sa->Resize(authoredSamples);
1214 size_t authoredSamplesSecondAttempt = SampleExtComputationInput(
1215 computationId, input, authoredSamples,
1216 sa->times.data(), sa->values.data());
1217 // Number of samples should be consisntent through multiple
1218 // invokations of the sampling function.
1219 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1220 }
1221 sa->count = authoredSamples;
1222}
1223
1224template <unsigned int CAPACITY>
1225void
1227 SdfPath const& computationId,
1228 TfToken const& input,
1229 float startTime,
1230 float endTime,
1232 size_t authoredSamples = SampleExtComputationInput(
1233 computationId, input, startTime, endTime, CAPACITY,
1234 sa->times.data(), sa->values.data());
1235
1236 if (authoredSamples > CAPACITY) {
1237 sa->Resize(authoredSamples);
1238 size_t authoredSamplesSecondAttempt = SampleExtComputationInput(
1239 computationId, input, startTime, endTime, authoredSamples,
1240 sa->times.data(), sa->values.data());
1241 // Number of samples should be consisntent through multiple
1242 // invokations of the sampling function.
1243 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1244 }
1245 sa->count = authoredSamples;
1246}
1247
1248PXR_NAMESPACE_CLOSE_SCOPE
1249
1250#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:104
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 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 refinement level for the given prim in the range [0,8].
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 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 void PostSyncCleanup()
Opportunity for the delegate to clean itself up after performing parallel work during sync phase.
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 an optional resolved path.
Definition: assetPath.h:30
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:211
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:69
bool displacementEnabled
Is the prim displacement shaded.
Definition: sceneDelegate.h:72
bool pointsShadingEnabled
Should the prim's points get shaded like surfaces, as opposed to constant shaded?
Definition: sceneDelegate.h:80
HdDisplayStyle()
Creates a default DisplayStyle.
Definition: sceneDelegate.h:92
bool materialIsFinal
Is this prim exempt from having its material disabled or overridden, for example, when a renderer cho...
Definition: sceneDelegate.h:84
HdDisplayStyle(int refineLevel_, bool flatShading=false, bool displacement=true, bool occludedSelectionShowsThrough_=false, bool pointsShadingEnabled_=false, bool materialIsFinal_=false)
Creates a DisplayStyle.
int refineLevel
The prim refine level, in the range [0, 8].
Definition: sceneDelegate.h:66
bool occludedSelectionShowsThrough
Does the prim act "transparent" to allow occluded selection to show through?
Definition: sceneDelegate.h:76
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.
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