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;
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 // Returns a single value for a given volume and parameter.
861 HD_API
862 virtual VtValue GetVolumeParamValue(SdfPath const &id,
863 TfToken const &paramName);
864
865 HD_API
866 virtual HdVolumeFieldDescriptorVector
867 GetVolumeFieldDescriptors(SdfPath const &volumeId);
868
869 // -----------------------------------------------------------------------//
871 // -----------------------------------------------------------------------//
872
880 HD_API
881 virtual TfTokenVector
883
889 HD_API
890 virtual HdExtComputationInputDescriptorVector
892
897 HD_API
898 virtual HdExtComputationOutputDescriptorVector
900
901
909 HD_API
910 virtual HdExtComputationPrimvarDescriptorVector
912 HdInterpolation interpolationMode);
913
916 HD_API
917 virtual VtValue GetExtComputationInput(SdfPath const& computationId,
918 TfToken const& input);
919
927 HD_API
928 virtual size_t SampleExtComputationInput(SdfPath const& computationId,
929 TfToken const& input,
930 size_t maxSampleCount,
931 float *sampleTimes,
932 VtValue *sampleValues);
933
934 // An overload of SampleTransform that explicitly takes the startTime
935 // and endTime rather than relying on the scene delegate having state
936 // about what the source of the current shutter interval should be.
937 HD_API
938 virtual size_t SampleExtComputationInput(SdfPath const& computationId,
939 TfToken const& input,
940 float startTime,
941 float endTime,
942 size_t maxSampleCount,
943 float *sampleTimes,
944 VtValue *sampleValues);
945
950 template <unsigned int CAPACITY>
951 void SampleExtComputationInput(SdfPath const& computationId,
952 TfToken const& input,
954
959 template <unsigned int CAPACITY>
960 void SampleExtComputationInput(SdfPath const& computationId,
961 TfToken const& input,
962 float startTime,
963 float endTime,
965
969 HD_API
970 virtual std::string GetExtComputationKernel(SdfPath const& computationId);
971
982 HD_API
983 virtual void InvokeExtComputation(SdfPath const& computationId,
984 HdExtComputationContext *context);
985
986 // -----------------------------------------------------------------------//
988 // -----------------------------------------------------------------------//
989
991 HD_API
992 virtual HdPrimvarDescriptorVector
993 GetPrimvarDescriptors(SdfPath const& id, HdInterpolation interpolation);
994
995 // -----------------------------------------------------------------------//
997 // -----------------------------------------------------------------------//
998 HD_API
999 virtual TfTokenVector GetTaskRenderTags(SdfPath const& taskId);
1000
1001private:
1002 HdRenderIndex *_index;
1003 SdfPath _delegateID;
1004
1005 HdSceneDelegate() = delete;
1006 HdSceneDelegate(HdSceneDelegate &) = delete;
1007 HdSceneDelegate &operator=(HdSceneDelegate &) = delete;
1008};
1009
1010template <unsigned int CAPACITY>
1011void
1014 size_t authoredSamples =
1015 SampleTransform(id, CAPACITY, sa->times.data(), sa->values.data());
1016 if (authoredSamples > CAPACITY) {
1017 sa->Resize(authoredSamples);
1018 size_t authoredSamplesSecondAttempt =
1020 id,
1021 authoredSamples,
1022 sa->times.data(),
1023 sa->values.data());
1024 // Number of samples should be consisntent through multiple
1025 // invokations of the sampling function.
1026 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1027 }
1028 sa->count = authoredSamples;
1029}
1030
1031template <unsigned int CAPACITY>
1032void
1034 float startTime,
1035 float endTime,
1037 size_t authoredSamples =
1038 SampleTransform(id, startTime, endTime, CAPACITY,
1039 sa->times.data(), sa->values.data());
1040 if (authoredSamples > CAPACITY) {
1041 sa->Resize(authoredSamples);
1042 size_t authoredSamplesSecondAttempt =
1044 id,
1045 startTime,
1046 endTime,
1047 authoredSamples,
1048 sa->times.data(),
1049 sa->values.data());
1050 // Number of samples should be consisntent through multiple
1051 // invokations of the sampling function.
1052 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1053 }
1054 sa->count = authoredSamples;
1055}
1056
1057template <unsigned int CAPACITY>
1058void
1060 SdfPath const &instancerId,
1062 size_t authoredSamples =
1064 instancerId,
1065 CAPACITY,
1066 sa->times.data(),
1067 sa->values.data());
1068 if (authoredSamples > CAPACITY) {
1069 sa->Resize(authoredSamples);
1070 size_t authoredSamplesSecondAttempt =
1072 instancerId,
1073 authoredSamples,
1074 sa->times.data(),
1075 sa->values.data());
1076 // Number of samples should be consisntent through multiple
1077 // invokations of the sampling function.
1078 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1079 }
1080 sa->count = authoredSamples;
1081}
1082
1083template <unsigned int CAPACITY>
1084void
1086 SdfPath const &instancerId,
1087 float startTime, float endTime,
1089 size_t authoredSamples =
1091 instancerId,
1092 startTime,
1093 endTime,
1094 CAPACITY,
1095 sa->times.data(),
1096 sa->values.data());
1097 if (authoredSamples > CAPACITY) {
1098 sa->Resize(authoredSamples);
1099 size_t authoredSamplesSecondAttempt =
1101 instancerId,
1102 startTime,
1103 endTime,
1104 authoredSamples,
1105 sa->times.data(),
1106 sa->values.data());
1107 // Number of samples should be consisntent through multiple
1108 // invokations of the sampling function.
1109 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1110 }
1111 sa->count = authoredSamples;
1112}
1113
1114template <unsigned int CAPACITY>
1115void
1117 TfToken const& key,
1119 size_t authoredSamples =
1121 id,
1122 key,
1123 CAPACITY,
1124 sa->times.data(),
1125 sa->values.data());
1126 if (authoredSamples > CAPACITY) {
1127 sa->Resize(authoredSamples);
1128 size_t authoredSamplesSecondAttempt =
1130 id,
1131 key,
1132 authoredSamples,
1133 sa->times.data(),
1134 sa->values.data());
1135 // Number of samples should be consistent through multiple
1136 // invocations of the sampling function.
1137 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1138 }
1139 sa->count = authoredSamples;
1140}
1141
1142template <unsigned int CAPACITY>
1143void
1145 TfToken const& key,
1146 float startTime,
1147 float endTime,
1149 size_t authoredSamples =
1151 id,
1152 key,
1153 startTime,
1154 endTime,
1155 CAPACITY,
1156 sa->times.data(),
1157 sa->values.data());
1158 if (authoredSamples > CAPACITY) {
1159 sa->Resize(authoredSamples);
1160 size_t authoredSamplesSecondAttempt =
1162 id,
1163 key,
1164 startTime,
1165 endTime,
1166 authoredSamples,
1167 sa->times.data(),
1168 sa->values.data());
1169 // Number of samples should be consistent through multiple
1170 // invocations of the sampling function.
1171 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1172 }
1173 sa->count = authoredSamples;
1174}
1175
1176template <unsigned int CAPACITY>
1177void
1179 TfToken const& key,
1181 size_t authoredSamples =
1183 id,
1184 key,
1185 CAPACITY,
1186 sa->times.data(),
1187 sa->values.data(),
1188 sa->indices.data());
1189 if (authoredSamples > CAPACITY) {
1190 sa->Resize(authoredSamples);
1191 size_t authoredSamplesSecondAttempt =
1193 id,
1194 key,
1195 authoredSamples,
1196 sa->times.data(),
1197 sa->values.data(),
1198 sa->indices.data());
1199 // Number of samples should be consistent through multiple
1200 // invocations of the sampling function.
1201 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1202 }
1203 sa->count = authoredSamples;
1204}
1205
1206template <unsigned int CAPACITY>
1207void
1209 TfToken const& key,
1210 float startTime,
1211 float endTime,
1213 size_t authoredSamples =
1215 id,
1216 key,
1217 startTime,
1218 endTime,
1219 CAPACITY,
1220 sa->times.data(),
1221 sa->values.data(),
1222 sa->indices.data());
1223 if (authoredSamples > CAPACITY) {
1224 sa->Resize(authoredSamples);
1225 size_t authoredSamplesSecondAttempt =
1227 id,
1228 key,
1229 startTime,
1230 endTime,
1231 authoredSamples,
1232 sa->times.data(),
1233 sa->values.data(),
1234 sa->indices.data());
1235 // Number of samples should be consistent through multiple
1236 // invocations of the sampling function.
1237 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1238 }
1239 sa->count = authoredSamples;
1240}
1241
1242template <unsigned int CAPACITY>
1243void
1245 SdfPath const& computationId,
1246 TfToken const& input,
1248 size_t authoredSamples = SampleExtComputationInput(
1249 computationId, input, CAPACITY,
1250 sa->times.data(), sa->values.data());
1251
1252 if (authoredSamples > CAPACITY) {
1253 sa->Resize(authoredSamples);
1254 size_t authoredSamplesSecondAttempt = SampleExtComputationInput(
1255 computationId, input, authoredSamples,
1256 sa->times.data(), sa->values.data());
1257 // Number of samples should be consisntent through multiple
1258 // invokations of the sampling function.
1259 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1260 }
1261 sa->count = authoredSamples;
1262}
1263
1264template <unsigned int CAPACITY>
1265void
1267 SdfPath const& computationId,
1268 TfToken const& input,
1269 float startTime,
1270 float endTime,
1272 size_t authoredSamples = SampleExtComputationInput(
1273 computationId, input, startTime, endTime, CAPACITY,
1274 sa->times.data(), sa->values.data());
1275
1276 if (authoredSamples > CAPACITY) {
1277 sa->Resize(authoredSamples);
1278 size_t authoredSamplesSecondAttempt = SampleExtComputationInput(
1279 computationId, input, startTime, endTime, authoredSamples,
1280 sa->times.data(), sa->values.data());
1281 // Number of samples should be consisntent through multiple
1282 // invokations of the sampling function.
1283 TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
1284 }
1285 sa->count = authoredSamples;
1286}
1287
1288PXR_NAMESPACE_CLOSE_SCOPE
1289
1290#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.
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: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:90
#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.
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/...
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:440