Loading...
Searching...
No Matches
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;
180
182 : interpolation(HdInterpolationConstant)
183 , role(HdPrimvarRoleTokens->none)
184 , indexed(false)
185 , elementSize(1)
186 {}
187 HdPrimvarDescriptor(TfToken const& name_,
188 HdInterpolation interp_,
189 TfToken const& role_=HdPrimvarRoleTokens->none,
190 bool indexed_=false, int elementSize_=1)
191 : name(name_), interpolation(interp_), role(role_), indexed(indexed_),
192 elementSize(elementSize_)
193 { }
194 bool operator==(HdPrimvarDescriptor const& rhs) const {
195 return name == rhs.name && role == rhs.role
197 && elementSize == rhs.elementSize;
198 }
199 bool operator!=(HdPrimvarDescriptor const& rhs) const {
200 return !(*this == rhs);
201 }
202};
203
204typedef std::vector<HdPrimvarDescriptor> HdPrimvarDescriptorVector;
205
219 // Alternate imaging mode. Options are origin, bounds, cards, default, and
220 // inherited.
221 TfToken drawMode;
222 // Specifies whether to apply the alternative imaging mode or not.
223 bool applyDrawMode;
224 // The color in which to draw the geometry.
225 GfVec3f drawModeColor;
226 // The specific geometry to use in cards mode. Options are cross, box, and
227 // fromTexture.
228 TfToken cardGeometry;
229 // The textures applied to the respective quads in cards mode.
230 SdfAssetPath cardTextureXPos;
231 SdfAssetPath cardTextureYPos;
232 SdfAssetPath cardTextureZPos;
233 SdfAssetPath cardTextureXNeg;
234 SdfAssetPath cardTextureYNeg;
235 SdfAssetPath cardTextureZNeg;
236
238 : drawMode(HdModelDrawModeTokens->inherited)
239 , applyDrawMode(false)
240 , drawModeColor(GfVec3f(0.18))
241 , cardGeometry(HdModelDrawModeTokens->cross)
242 {}
243
246 TfToken const& drawMode_,
247 bool applyDrawMode_=false,
248 GfVec3f drawModeColor_=GfVec3f(0.18),
249 TfToken const& cardGeometry_=HdModelDrawModeTokens->cross,
250 SdfAssetPath cardTextureXPos_=SdfAssetPath(),
251 SdfAssetPath cardTextureYPos_=SdfAssetPath(),
252 SdfAssetPath cardTextureZPos_=SdfAssetPath(),
253 SdfAssetPath cardTextureXNeg_=SdfAssetPath(),
254 SdfAssetPath cardTextureYNeg_=SdfAssetPath(),
255 SdfAssetPath cardTextureZNeg_=SdfAssetPath())
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_)
261 {}
262
263 bool operator==(HdModelDrawMode const& rhs) const {
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;
274 }
275 bool operator!=(HdModelDrawMode const& rhs) const {
276 return !(*this == rhs);
277 }
278};
279
290 SdfPath sourceComputationId;
291 TfToken sourceComputationOutputName;
292 HdTupleType valueType;
293
296 TfToken const& name_,
297 HdInterpolation interp_,
298 TfToken const & role_,
299 SdfPath const & sourceComputationId_,
300 TfToken const & sourceComputationOutputName_,
301 HdTupleType const & valueType_)
302 : HdPrimvarDescriptor(name_, interp_, role_, false)
303 , sourceComputationId(sourceComputationId_)
304 , sourceComputationOutputName(sourceComputationOutputName_)
305 , valueType(valueType_)
306 { }
307 bool operator==(HdExtComputationPrimvarDescriptor const& rhs) const {
308 return HdPrimvarDescriptor::operator==(rhs) &&
309 sourceComputationId == rhs.sourceComputationId &&
310 sourceComputationOutputName == rhs.sourceComputationOutputName &&
311 valueType == rhs.valueType;
312 }
313 bool operator!=(HdExtComputationPrimvarDescriptor const& rhs) const {
314 return !(*this == rhs);
315 }
316};
317
318typedef std::vector<HdExtComputationPrimvarDescriptor>
319 HdExtComputationPrimvarDescriptorVector;
320
330 TfToken name;
331 SdfPath sourceComputationId;
332 TfToken sourceComputationOutputName;
333
336 TfToken const & name_,
337 SdfPath const & sourceComputationId_,
338 TfToken const & sourceComputationOutputName_)
339 : name(name_), sourceComputationId(sourceComputationId_)
340 , sourceComputationOutputName(sourceComputationOutputName_)
341 { }
342
343 bool operator==(HdExtComputationInputDescriptor const& rhs) const {
344 return name == rhs.name &&
345 sourceComputationId == rhs.sourceComputationId &&
346 sourceComputationOutputName == rhs.sourceComputationOutputName;
347 }
348 bool operator!=(HdExtComputationInputDescriptor const& rhs) const {
349 return !(*this == rhs);
350 }
351};
352
353typedef std::vector<HdExtComputationInputDescriptor>
354 HdExtComputationInputDescriptorVector;
355
363 TfToken name;
364 HdTupleType valueType;
365
368 TfToken const & name_,
369 HdTupleType const & valueType_)
370 : name(name_), valueType(valueType_)
371 { }
372
373 bool operator==(HdExtComputationOutputDescriptor const& rhs) const {
374 return name == rhs.name &&
375 valueType == rhs.valueType;
376 }
377 bool operator!=(HdExtComputationOutputDescriptor const& rhs) const {
378 return !(*this == rhs);
379 }
380};
381
382typedef std::vector<HdExtComputationOutputDescriptor>
383 HdExtComputationOutputDescriptorVector;
384
390 TfToken fieldName;
391 TfToken fieldPrimType;
392 SdfPath fieldId;
393
396 TfToken const & fieldName_,
397 TfToken const & fieldPrimType_,
398 SdfPath const & fieldId_)
399 : fieldName(fieldName_), fieldPrimType(fieldPrimType_), fieldId(fieldId_)
400 { }
401};
402
403typedef std::vector<HdVolumeFieldDescriptor>
404 HdVolumeFieldDescriptorVector;
405
411public:
413 HD_API
415 SdfPath const& delegateID);
416
417 HD_API
418 virtual ~HdSceneDelegate();
419
421 HdRenderIndex& GetRenderIndex() { return *_index; }
422
427 SdfPath const& GetDelegateID() const { return _delegateID; }
428
430 HD_API
431 virtual void Sync(HdSyncRequestVector* request);
432
435 HD_API
436 virtual void PostSyncCleanup();
437
438 // -----------------------------------------------------------------------//
440 // -----------------------------------------------------------------------//
441
443 HD_API
444 virtual bool IsEnabled(TfToken const& option) const;
445
446
447 // -----------------------------------------------------------------------//
449 // -----------------------------------------------------------------------//
450
452 HD_API
454
456 HD_API
458
460 HD_API
462
463
471 HD_API
472 virtual GfRange3d GetExtent(SdfPath const & id);
473
475 HD_API
476 virtual GfMatrix4d GetTransform(SdfPath const & id);
477
479 HD_API
480 virtual bool GetVisible(SdfPath const & id);
481
483 HD_API
484 virtual bool GetDoubleSided(SdfPath const & id);
485
487 HD_API
488 virtual HdCullStyle GetCullStyle(SdfPath const &id);
489
491 HD_API
492 virtual VtValue GetShadingStyle(SdfPath const &id);
493
495 HD_API
497
499 HD_API
500 virtual VtValue Get(SdfPath const& id, TfToken const& key);
501
506 HD_API
508 TfToken const& key,
509 VtIntArray *outIndices);
510
512 HD_API
514
517 HD_API
518 virtual TfToken GetRenderTag(SdfPath const& id);
519
522 HD_API
524
526 HD_API
527 virtual std::vector<VtArray<TfToken>>
528 GetInstanceCategories(SdfPath const &instancerId);
529
531 HD_API
532 virtual HdIdVectorSharedPtr GetCoordSysBindings(SdfPath const& id);
533
535 HD_API
537
538 // -----------------------------------------------------------------------//
540 // -----------------------------------------------------------------------//
541
557 HD_API
558 virtual size_t
560 size_t maxSampleCount,
561 float *sampleTimes,
562 GfMatrix4d *sampleValues);
563
567 HD_API
568 virtual size_t
570 float startTime,
571 float endTime,
572 size_t maxSampleCount,
573 float *sampleTimes,
574 GfMatrix4d *sampleValues);
575
579 template <unsigned int CAPACITY>
580 void
581 SampleTransform(SdfPath const & id,
583
588 template <unsigned int CAPACITY>
589 void
590 SampleTransform(SdfPath const & id,
591 float startTime,
592 float endTime,
594
610 HD_API
611 virtual size_t
613 size_t maxSampleCount,
614 float *sampleTimes,
615 GfMatrix4d *sampleValues);
616
620 HD_API
621 virtual size_t
623 float startTime,
624 float endTime,
625 size_t maxSampleCount,
626 float *sampleTimes,
627 GfMatrix4d *sampleValues);
628
633 template <unsigned int CAPACITY>
634 void
635 SampleInstancerTransform(SdfPath const &instancerId,
637
642 template <unsigned int CAPACITY>
643 void
644 SampleInstancerTransform(SdfPath const &instancerId,
645 float startTime, float endTime,
647
672 HD_API
673 virtual size_t
675 TfToken const& key,
676 size_t maxSampleCount,
677 float *sampleTimes,
678 VtValue *sampleValues);
679
683 HD_API
684 virtual size_t
686 TfToken const& key,
687 float startTime,
688 float endTime,
689 size_t maxSampleCount,
690 float *sampleTimes,
691 VtValue *sampleValues);
692
696 template <unsigned int CAPACITY>
697 void
698 SamplePrimvar(SdfPath const &id,
699 TfToken const& key,
701
706 template <unsigned int CAPACITY>
707 void
708 SamplePrimvar(SdfPath const &id,
709 TfToken const& key,
710 float startTime,
711 float endTime,
713
719 HD_API
720 virtual size_t
722 TfToken const& key,
723 size_t maxSampleCount,
724 float *sampleTimes,
725 VtValue *sampleValues,
726 VtIntArray *sampleIndices);
727
731 HD_API
732 virtual size_t
734 TfToken const& key,
735 float startTime,
736 float endTime,
737 size_t maxSampleCount,
738 float *sampleTimes,
739 VtValue *sampleValues,
740 VtIntArray *sampleIndices);
741
746 template <unsigned int CAPACITY>
747 void
748 SampleIndexedPrimvar(SdfPath const &id,
749 TfToken const& key,
751
756 template <unsigned int CAPACITY>
757 void
758 SampleIndexedPrimvar(SdfPath const &id,
759 TfToken const& key,
760 float startTime,
761 float endTime,
763
764 // -----------------------------------------------------------------------//
766 // -----------------------------------------------------------------------//
767
780 HD_API
781 virtual VtIntArray GetInstanceIndices(SdfPath const &instancerId,
782 SdfPath const &prototypeId);
783
785 HD_API
786 virtual GfMatrix4d GetInstancerTransform(SdfPath const &instancerId);
787
789 HD_API
790 virtual SdfPath GetInstancerId(SdfPath const& primId);
791
796 HD_API
797 virtual SdfPathVector GetInstancerPrototypes(SdfPath const& instancerId);
798
799 // -----------------------------------------------------------------------//
801 // -----------------------------------------------------------------------//
802
807 HD_API
808 virtual SdfPath GetScenePrimPath(SdfPath const& rprimId,
809 int instanceIndex,
810 HdInstancerContext *instancerContext = nullptr);
811
817 HD_API
818 virtual SdfPathVector GetScenePrimPaths(SdfPath const& rprimId,
819 std::vector<int> instanceIndices,
820 std::vector<HdInstancerContext> *instancerContexts = nullptr);
821
822 // -----------------------------------------------------------------------//
824 // -----------------------------------------------------------------------//
825
827 HD_API
828 virtual SdfPath GetMaterialId(SdfPath const &rprimId);
829
830 // Returns a material resource which contains the information
831 // needed to create a material.
832 HD_API
833 virtual VtValue GetMaterialResource(SdfPath const &materialId);
834
835 // -----------------------------------------------------------------------//
837 // -----------------------------------------------------------------------//
838
840 HD_API
842
843 // -----------------------------------------------------------------------//
845 // -----------------------------------------------------------------------//
846
847 // Returns a single value for a given light and parameter.
848 HD_API
849 virtual VtValue GetLightParamValue(SdfPath const &id,
850 TfToken const &paramName);
851
852 // -----------------------------------------------------------------------//
854 // -----------------------------------------------------------------------//
855
858 HD_API
859 virtual VtValue GetCameraParamValue(SdfPath const& cameraId,
860 TfToken const& paramName);
861
862 // -----------------------------------------------------------------------//
864 // -----------------------------------------------------------------------//
865
866 // Returns a single value for a given volume and parameter.
867 HD_API
868 virtual VtValue GetVolumeParamValue(SdfPath const &id,
869 TfToken const &paramName);
870
871 HD_API
872 virtual HdVolumeFieldDescriptorVector
873 GetVolumeFieldDescriptors(SdfPath const &volumeId);
874
875 // -----------------------------------------------------------------------//
877 // -----------------------------------------------------------------------//
878
886 HD_API
887 virtual TfTokenVector
889
895 HD_API
896 virtual HdExtComputationInputDescriptorVector
898
903 HD_API
904 virtual HdExtComputationOutputDescriptorVector
906
907
915 HD_API
916 virtual HdExtComputationPrimvarDescriptorVector
918 HdInterpolation interpolationMode);
919
922 HD_API
923 virtual VtValue GetExtComputationInput(SdfPath const& computationId,
924 TfToken const& input);
925
933 HD_API
934 virtual size_t SampleExtComputationInput(SdfPath const& computationId,
935 TfToken const& input,
936 size_t maxSampleCount,
937 float *sampleTimes,
938 VtValue *sampleValues);
939
940 // An overload of SampleTransform that explicitly takes the startTime
941 // and endTime rather than relying on the scene delegate having state
942 // about what the source of the current shutter interval should be.
943 HD_API
944 virtual size_t SampleExtComputationInput(SdfPath const& computationId,
945 TfToken const& input,
946 float startTime,
947 float endTime,
948 size_t maxSampleCount,
949 float *sampleTimes,
950 VtValue *sampleValues);
951
956 template <unsigned int CAPACITY>
957 void SampleExtComputationInput(SdfPath const& computationId,
958 TfToken const& input,
960
965 template <unsigned int CAPACITY>
966 void SampleExtComputationInput(SdfPath const& computationId,
967 TfToken const& input,
968 float startTime,
969 float endTime,
971
975 HD_API
976 virtual std::string GetExtComputationKernel(SdfPath const& computationId);
977
988 HD_API
989 virtual void InvokeExtComputation(SdfPath const& computationId,
990 HdExtComputationContext *context);
991
992 // -----------------------------------------------------------------------//
994 // -----------------------------------------------------------------------//
995
997 HD_API
998 virtual HdPrimvarDescriptorVector
999 GetPrimvarDescriptors(SdfPath const& id, HdInterpolation interpolation);
1000
1001 // -----------------------------------------------------------------------//
1003 // -----------------------------------------------------------------------//
1004 HD_API
1005 virtual TfTokenVector GetTaskRenderTags(SdfPath const& taskId);
1006
1007private:
1008 HdRenderIndex *_index;
1009 SdfPath _delegateID;
1010
1011 HdSceneDelegate() = delete;
1012 HdSceneDelegate(HdSceneDelegate &) = delete;
1013 HdSceneDelegate &operator=(HdSceneDelegate &) = delete;
1014};
1015
1016template <unsigned int CAPACITY>
1017void
1020 size_t authoredSamples =
1021 SampleTransform(id, CAPACITY, sa->times.data(), sa->values.data());
1022 if (authoredSamples > CAPACITY) {
1023 sa->Resize(authoredSamples);
1024 size_t authoredSamplesSecondAttempt =
1026 id,
1027 authoredSamples,
1028 sa->times.data(),
1029 sa->values.data());
1030 // Number of samples should be consisntent through multiple
1031 // invokations of the sampling function.
1032 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1033 }
1034 sa->count = authoredSamples;
1035}
1036
1037template <unsigned int CAPACITY>
1038void
1040 float startTime,
1041 float endTime,
1043 size_t authoredSamples =
1044 SampleTransform(id, startTime, endTime, CAPACITY,
1045 sa->times.data(), sa->values.data());
1046 if (authoredSamples > CAPACITY) {
1047 sa->Resize(authoredSamples);
1048 size_t authoredSamplesSecondAttempt =
1050 id,
1051 startTime,
1052 endTime,
1053 authoredSamples,
1054 sa->times.data(),
1055 sa->values.data());
1056 // Number of samples should be consisntent through multiple
1057 // invokations of the sampling function.
1058 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1059 }
1060 sa->count = authoredSamples;
1061}
1062
1063template <unsigned int CAPACITY>
1064void
1066 SdfPath const &instancerId,
1068 size_t authoredSamples =
1070 instancerId,
1071 CAPACITY,
1072 sa->times.data(),
1073 sa->values.data());
1074 if (authoredSamples > CAPACITY) {
1075 sa->Resize(authoredSamples);
1076 size_t authoredSamplesSecondAttempt =
1078 instancerId,
1079 authoredSamples,
1080 sa->times.data(),
1081 sa->values.data());
1082 // Number of samples should be consisntent through multiple
1083 // invokations of the sampling function.
1084 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1085 }
1086 sa->count = authoredSamples;
1087}
1088
1089template <unsigned int CAPACITY>
1090void
1092 SdfPath const &instancerId,
1093 float startTime, float endTime,
1095 size_t authoredSamples =
1097 instancerId,
1098 startTime,
1099 endTime,
1100 CAPACITY,
1101 sa->times.data(),
1102 sa->values.data());
1103 if (authoredSamples > CAPACITY) {
1104 sa->Resize(authoredSamples);
1105 size_t authoredSamplesSecondAttempt =
1107 instancerId,
1108 startTime,
1109 endTime,
1110 authoredSamples,
1111 sa->times.data(),
1112 sa->values.data());
1113 // Number of samples should be consisntent through multiple
1114 // invokations of the sampling function.
1115 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1116 }
1117 sa->count = authoredSamples;
1118}
1119
1120template <unsigned int CAPACITY>
1121void
1123 TfToken const& key,
1125 size_t authoredSamples =
1127 id,
1128 key,
1129 CAPACITY,
1130 sa->times.data(),
1131 sa->values.data());
1132 if (authoredSamples > CAPACITY) {
1133 sa->Resize(authoredSamples);
1134 size_t authoredSamplesSecondAttempt =
1136 id,
1137 key,
1138 authoredSamples,
1139 sa->times.data(),
1140 sa->values.data());
1141 // Number of samples should be consistent through multiple
1142 // invocations of the sampling function.
1143 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1144 }
1145 sa->count = authoredSamples;
1146}
1147
1148template <unsigned int CAPACITY>
1149void
1151 TfToken const& key,
1152 float startTime,
1153 float endTime,
1155 size_t authoredSamples =
1157 id,
1158 key,
1159 startTime,
1160 endTime,
1161 CAPACITY,
1162 sa->times.data(),
1163 sa->values.data());
1164 if (authoredSamples > CAPACITY) {
1165 sa->Resize(authoredSamples);
1166 size_t authoredSamplesSecondAttempt =
1168 id,
1169 key,
1170 startTime,
1171 endTime,
1172 authoredSamples,
1173 sa->times.data(),
1174 sa->values.data());
1175 // Number of samples should be consistent through multiple
1176 // invocations of the sampling function.
1177 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1178 }
1179 sa->count = authoredSamples;
1180}
1181
1182template <unsigned int CAPACITY>
1183void
1185 TfToken const& key,
1187 size_t authoredSamples =
1189 id,
1190 key,
1191 CAPACITY,
1192 sa->times.data(),
1193 sa->values.data(),
1194 sa->indices.data());
1195 if (authoredSamples > CAPACITY) {
1196 sa->Resize(authoredSamples);
1197 size_t authoredSamplesSecondAttempt =
1199 id,
1200 key,
1201 authoredSamples,
1202 sa->times.data(),
1203 sa->values.data(),
1204 sa->indices.data());
1205 // Number of samples should be consistent through multiple
1206 // invocations of the sampling function.
1207 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1208 }
1209 sa->count = authoredSamples;
1210}
1211
1212template <unsigned int CAPACITY>
1213void
1215 TfToken const& key,
1216 float startTime,
1217 float endTime,
1219 size_t authoredSamples =
1221 id,
1222 key,
1223 startTime,
1224 endTime,
1225 CAPACITY,
1226 sa->times.data(),
1227 sa->values.data(),
1228 sa->indices.data());
1229 if (authoredSamples > CAPACITY) {
1230 sa->Resize(authoredSamples);
1231 size_t authoredSamplesSecondAttempt =
1233 id,
1234 key,
1235 startTime,
1236 endTime,
1237 authoredSamples,
1238 sa->times.data(),
1239 sa->values.data(),
1240 sa->indices.data());
1241 // Number of samples should be consistent through multiple
1242 // invocations of the sampling function.
1243 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1244 }
1245 sa->count = authoredSamples;
1246}
1247
1248template <unsigned int CAPACITY>
1249void
1251 SdfPath const& computationId,
1252 TfToken const& input,
1254 size_t authoredSamples = SampleExtComputationInput(
1255 computationId, input, CAPACITY,
1256 sa->times.data(), sa->values.data());
1257
1258 if (authoredSamples > CAPACITY) {
1259 sa->Resize(authoredSamples);
1260 size_t authoredSamplesSecondAttempt = SampleExtComputationInput(
1261 computationId, input, authoredSamples,
1262 sa->times.data(), sa->values.data());
1263 // Number of samples should be consisntent through multiple
1264 // invokations of the sampling function.
1265 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1266 }
1267 sa->count = authoredSamples;
1268}
1269
1270template <unsigned int CAPACITY>
1271void
1273 SdfPath const& computationId,
1274 TfToken const& input,
1275 float startTime,
1276 float endTime,
1278 size_t authoredSamples = SampleExtComputationInput(
1279 computationId, input, startTime, endTime, CAPACITY,
1280 sa->times.data(), sa->values.data());
1281
1282 if (authoredSamples > CAPACITY) {
1283 sa->Resize(authoredSamples);
1284 size_t authoredSamplesSecondAttempt = SampleExtComputationInput(
1285 computationId, input, startTime, endTime, authoredSamples,
1286 sa->times.data(), sa->values.data());
1287 // Number of samples should be consisntent through multiple
1288 // invokations of the sampling function.
1289 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1290 }
1291 sa->count = authoredSamples;
1292}
1293
1294PXR_NAMESPACE_CLOSE_SCOPE
1295
1296#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:47
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.
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:79
A path value used to locate objects in layers or scenegraphs.
Definition path.h:281
value_type * data()
Direct access to the underlying array.
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:81
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:90
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition diagnostic.h:69
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition diagnostic.h:267
STL namespace.
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 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/...
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.
Definition aov.h:67
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.
Definition types.h:343
Description of a single field related to a volume primitive.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition token.h:489