HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sceneDelegate.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef HD_SCENE_DELEGATE_H
25 #define HD_SCENE_DELEGATE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
30 
31 #include "pxr/imaging/hd/aov.h"
33 #include "pxr/imaging/hd/enums.h"
37 #include "pxr/imaging/hd/repr.h"
40 
42 
43 #include "pxr/base/vt/array.h"
44 #include "pxr/base/vt/dictionary.h"
45 #include "pxr/base/vt/value.h"
46 #include "pxr/usd/sdf/path.h"
47 
48 #include "pxr/base/gf/vec2i.h"
49 #include "pxr/base/tf/hash.h"
50 
51 #include <hboost/shared_ptr.hpp>
52 #include <vector>
53 
55 
57 
58 /// A shared pointer to a vector of id's.
59 typedef std::shared_ptr<SdfPathVector> HdIdVectorSharedPtr;
60 
61 /// \class HdSyncRequestVector
62 ///
63 /// The SceneDelegate is requested to synchronize prims as the result of
64 /// executing a specific render pass, the following data structure is passed
65 /// back to the delegate to drive synchronization.
66 ///
68  // The Prims to synchronize in this request.
70 
71  // The HdChangeTracker::DirtyBits that are set for each Prim.
72  std::vector<HdDirtyBits> dirtyBits;
73 };
74 
75 /// \struct HdDisplayStyle
76 ///
77 /// Describes how the geometry of a prim should be displayed.
78 ///
80  /// The prim refine level, in the range [0, 8].
82 
83  /// Is the prim flat shaded.
85 
86  /// Is the prim displacement shaded.
88 
89  /// Creates a default DisplayStyle.
90  /// - refineLevel is 0.
91  /// - flatShading is disabled.
92  /// - displacement is enabled.
94  : refineLevel(0)
95  , flatShadingEnabled(false)
96  , displacementEnabled(true)
97  { }
98 
99  /// Creates a DisplayStyle.
100  /// \param refineLevel_ the refine level to display.
101  /// Valid range is [0, 8].
102  /// \param flatShading enables flat shading, defaults to false.
103  /// \param displacement enables displacement shading, defaults to false.
104  HdDisplayStyle(int refineLevel_,
105  bool flatShading = false,
106  bool displacement = true)
107  : refineLevel(std::max(0, refineLevel_))
108  , flatShadingEnabled(flatShading)
109  , displacementEnabled(displacement)
110  {
111  if (refineLevel_ < 0) {
112  TF_CODING_ERROR("negative refine level is not supported");
113  } else if (refineLevel_ > 8) {
114  TF_CODING_ERROR("refine level > 8 is not supported");
115  }
116  }
117 
118  HdDisplayStyle(HdDisplayStyle const& rhs) = default;
119  ~HdDisplayStyle() = default;
120 
121  bool operator==(HdDisplayStyle const& rhs) const {
122  return refineLevel == rhs.refineLevel
125  }
126  bool operator!=(HdDisplayStyle const& rhs) const {
127  return !(*this == rhs);
128  }
129 };
130 
131 /// \struct HdPrimvarDescriptor
132 ///
133 /// Describes a primvar.
135  /// Name of the primvar.
137  /// Interpolation (data-sampling rate) of the primvar.
139  /// Optional "role" indicating a desired interpretation --
140  /// for example, to distinguish color/vector/point/normal.
141  /// See HdPrimvarRoleTokens; default is HdPrimvarRoleTokens->none.
143 
146  HdInterpolation interp_,
147  TfToken const& role_=HdPrimvarRoleTokens->none)
148  : name(name_), interpolation(interp_), role(role_)
149  { }
150  bool operator==(HdPrimvarDescriptor const& rhs) const {
151  return name == rhs.name && role == rhs.role
152  && interpolation == rhs.interpolation;
153  }
154  bool operator!=(HdPrimvarDescriptor const& rhs) const {
155  return !(*this == rhs);
156  }
157 };
158 
159 typedef std::vector<HdPrimvarDescriptor> HdPrimvarDescriptorVector;
160 
161 /// \struct HdExtComputationPrimvarDescriptor
162 ///
163 /// Extends HdPrimvarDescriptor to describe a primvar that takes
164 /// data from the output of an ExtComputation.
165 ///
166 /// The structure contains the id of the source ExtComputation in the
167 /// render index, the name of an output from that computation from which
168 /// the primvar will take data along with a valueType which describes
169 /// the type of the expected data.
174 
177  TfToken const& name_,
178  HdInterpolation interp_,
179  TfToken const & role_,
180  SdfPath const & sourceComputationId_,
181  TfToken const & sourceComputationOutputName_,
182  HdTupleType const & valueType_)
183  : HdPrimvarDescriptor(name_, interp_, role_)
184  , sourceComputationId(sourceComputationId_)
185  , sourceComputationOutputName(sourceComputationOutputName_)
186  , valueType(valueType_)
187  { }
189  return HdPrimvarDescriptor::operator==(rhs) &&
192  valueType == rhs.valueType;
193  }
195  return !(*this == rhs);
196  }
197 };
198 
199 typedef std::vector<HdExtComputationPrimvarDescriptor>
201 
202 /// \struct HdExtComputationInputDescriptor
203 ///
204 /// Describes an input to an ExtComputation that takes data from
205 /// the output of another ExtComputation.
206 ///
207 /// The structure contains the name of the input and the id of the
208 /// source ExtComputation in the render index, and which output of
209 /// that computation to bind the input to.
214 
217  TfToken const & name_,
218  SdfPath const & sourceComputationId_,
219  TfToken const & sourceComputationOutputName_)
220  : name(name_), sourceComputationId(sourceComputationId_)
221  , sourceComputationOutputName(sourceComputationOutputName_)
222  { }
223 
225  return name == rhs.name &&
228  }
230  return !(*this == rhs);
231  }
232 };
233 
234 typedef std::vector<HdExtComputationInputDescriptor>
236 
237 /// \struct HdExtComputationOutputDescriptor
238 ///
239 /// Describes an output of an ExtComputation.
240 ///
241 /// The structure contains the name of the output along with a valueType
242 /// which describes the type of the computation output data.
246 
249  TfToken const & name_,
250  HdTupleType const & valueType_)
251  : name(name_), valueType(valueType_)
252  { }
253 
255  return name == rhs.name &&
256  valueType == rhs.valueType;
257  }
259  return !(*this == rhs);
260  }
261 };
262 
263 typedef std::vector<HdExtComputationOutputDescriptor>
265 
266 /// \struct HdVolumeFieldDescriptor
267 ///
268 /// Description of a single field related to a volume primitive.
269 ///
274 
277  TfToken const & fieldName_,
278  TfToken const & fieldPrimType_,
279  SdfPath const & fieldId_)
280  : fieldName(fieldName_), fieldPrimType(fieldPrimType_), fieldId(fieldId_)
281  { }
282 };
283 
284 typedef std::vector<HdVolumeFieldDescriptor>
286 
287 /// \class HdSceneDelegate
288 ///
289 /// Adapter class providing data exchange with the client scene graph.
290 ///
292 public:
293  /// Constructor used for nested delegate objects which share a RenderIndex.
294  HD_API
295  HdSceneDelegate(HdRenderIndex *parentIndex,
296  SdfPath const& delegateID);
297 
298  HD_API
299  virtual ~HdSceneDelegate();
300 
301  /// Returns the RenderIndex owned by this delegate.
302  HdRenderIndex& GetRenderIndex() { return *_index; }
303 
304  /// Returns the ID of this delegate, which is used as a prefix for all
305  /// objects it creates in the RenderIndex.
306  ///
307  /// The default value is SdfPath::AbsoluteRootPath().
308  SdfPath const& GetDelegateID() const { return _delegateID; }
309 
310  /// Synchronizes the delegate state for the given request vector.
311  HD_API
312  virtual void Sync(HdSyncRequestVector* request);
313 
314  /// Opportunity for the delegate to clean itself up after
315  /// performing parrellel work during sync phase
316  HD_API
317  virtual void PostSyncCleanup();
318 
319  // -----------------------------------------------------------------------//
320  /// \name Options
321  // -----------------------------------------------------------------------//
322 
323  /// Returns true if the named option is enabled by the delegate.
324  HD_API
325  virtual bool IsEnabled(TfToken const& option) const;
326 
327 
328  // -----------------------------------------------------------------------//
329  /// \name Rprim Aspects
330  // -----------------------------------------------------------------------//
331 
332  /// Gets the topological mesh data for a given prim.
333  HD_API
334  virtual HdMeshTopology GetMeshTopology(SdfPath const& id);
335 
336  /// Gets the topological curve data for a given prim.
337  HD_API
339 
340  /// Gets the subdivision surface tags (sharpness, holes, etc).
341  HD_API
342  virtual PxOsdSubdivTags GetSubdivTags(SdfPath const& id);
343 
344 
345  /// Gets the axis aligned bounds of a prim.
346  /// The returned bounds are in the local space of the prim
347  /// (transform is yet to be applied) and should contain the
348  /// bounds of any child prims.
349  ///
350  /// The returned bounds does not include any displacement that
351  /// might occur as the result of running shaders on the prim.
352  HD_API
353  virtual GfRange3d GetExtent(SdfPath const & id);
354 
355  /// Returns the object space transform, including all parent transforms.
356  HD_API
357  virtual GfMatrix4d GetTransform(SdfPath const & id);
358 
359  /// Returns the authored visible state of the prim.
360  HD_API
361  virtual bool GetVisible(SdfPath const & id);
362 
363  /// Returns the doubleSided state for the given prim.
364  HD_API
365  virtual bool GetDoubleSided(SdfPath const & id);
366 
367  /// Returns the cullstyle for the given prim.
368  HD_API
369  virtual HdCullStyle GetCullStyle(SdfPath const &id);
370 
371  /// Returns the shading style for the given prim.
372  HD_API
373  virtual VtValue GetShadingStyle(SdfPath const &id);
374 
375  /// Returns the refinement level for the given prim in the range [0,8].
376  ///
377  /// The refinement level indicates how many iterations to apply when
378  /// subdividing subdivision surfaces or other refinable primitives.
379  HD_API
380  virtual HdDisplayStyle GetDisplayStyle(SdfPath const& id);
381 
382  /// Returns a named value.
383  HD_API
384  virtual VtValue Get(SdfPath const& id, TfToken const& key);
385 
386  /// Returns the authored repr (if any) for the given prim.
387  HD_API
388  virtual HdReprSelector GetReprSelector(SdfPath const &id);
389 
390  /// Returns the render tag that will be used to bucket prims during
391  /// render pass bucketing.
392  HD_API
393  virtual TfToken GetRenderTag(SdfPath const& id);
394 
395  /// Returns the prim categories.
396  HD_API
397  virtual VtArray<TfToken> GetCategories(SdfPath const& id);
398 
399  /// Returns the categories for all instances in the instancer.
400  HD_API
401  virtual std::vector<VtArray<TfToken>>
402  GetInstanceCategories(SdfPath const &instancerId);
403 
404  /// Returns the coordinate system bindings, or a nullptr if none are bound.
405  HD_API
407 
408  // -----------------------------------------------------------------------//
409  /// \name Motion samples
410  // -----------------------------------------------------------------------//
411 
412  /// Store up to \a maxSampleCount transform samples in \a *sampleValues.
413  /// Returns the union of the authored samples and the boundaries
414  /// of the current camera shutter interval. If this number is greater
415  /// than maxSampleCount, you might want to call this function again
416  /// to get all the authored data.
417  /// Sample times are relative to the scene delegate's current time.
418  /// \see GetTransform()
419  HD_API
420  virtual size_t
421  SampleTransform(SdfPath const & id,
422  size_t maxSampleCount,
423  float *sampleTimes,
424  GfMatrix4d *sampleValues);
425 
426  /// Convenience form of SampleTransform() that takes an HdTimeSampleArray.
427  /// This function returns the union of the authored transform samples
428  /// and the boundaries of the current camera shutter interval.
429  template <unsigned int CAPACITY>
430  void
433  size_t authoredSamples =
434  SampleTransform(id, CAPACITY, sa->times.data(), sa->values.data());
435  if (authoredSamples > CAPACITY) {
436  sa->Resize(authoredSamples);
437  size_t authoredSamplesSecondAttempt =
439  id,
440  authoredSamples,
441  sa->times.data(),
442  sa->values.data());
443  // Number of samples should be consisntent through multiple
444  // invokations of the sampling function.
445  TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
446  }
447  sa->count = authoredSamples;
448  }
449 
450  /// Store up to \a maxSampleCount transform samples in \a *sampleValues.
451  /// Returns the union of the authored samples and the boundaries
452  /// of the current camera shutter interval. If this number is greater
453  /// than maxSampleCount, you might want to call this function again
454  /// to get all the authored data.
455  /// Sample times are relative to the scene delegate's current time.
456  /// \see GetInstancerTransform()
457  HD_API
458  virtual size_t
459  SampleInstancerTransform(SdfPath const &instancerId,
460  size_t maxSampleCount,
461  float *sampleTimes,
462  GfMatrix4d *sampleValues);
463 
464  /// Convenience form of SampleInstancerTransform()
465  /// that takes an HdTimeSampleArray.
466  /// This function returns the union of the authored samples
467  /// and the boundaries of the current camera shutter interval.
468  template <unsigned int CAPACITY>
469  void
470  SampleInstancerTransform(SdfPath const &instancerId,
472  size_t authoredSamples =
474  instancerId,
475  CAPACITY,
476  sa->times.data(),
477  sa->values.data());
478  if (authoredSamples > CAPACITY) {
479  sa->Resize(authoredSamples);
480  size_t authoredSamplesSecondAttempt =
482  instancerId,
483  authoredSamples,
484  sa->times.data(),
485  sa->values.data());
486  // Number of samples should be consisntent through multiple
487  // invokations of the sampling function.
488  TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
489  }
490  sa->count = authoredSamples;
491  }
492 
493  /// Store up to \a maxSampleCount primvar samples in \a *samplesValues.
494  /// Returns the union of the authored samples and the boundaries
495  /// of the current camera shutter interval. If this number is greater
496  /// than maxSampleCount, you might want to call this function again
497  /// to get all the authored data.
498  ///
499  /// Sample values that are array-valued will have a size described
500  /// by the HdPrimvarDescriptor as applied to the toplogy.
501  ///
502  /// For example, this means that a mesh that is fracturing over time
503  /// will return samples with the same number of points; the number
504  /// of points will change as the scene delegate is resynchronzied
505  /// to represent the scene at a time with different topology.
506  ///
507  /// Sample times are relative to the scene delegate's current time.
508  ///
509  /// \see Get()
510  HD_API
511  virtual size_t
512  SamplePrimvar(SdfPath const& id,
513  TfToken const& key,
514  size_t maxSampleCount,
515  float *sampleTimes,
516  VtValue *sampleValues);
517 
518  /// Convenience form of SamplePrimvar() that takes an HdTimeSampleArray.
519  /// This function returns the union of the authored samples
520  /// and the boundaries of the current camera shutter interval.
521  template <unsigned int CAPACITY>
522  void
523  SamplePrimvar(SdfPath const &id,
524  TfToken const& key,
526  size_t authoredSamples =
528  id,
529  key,
530  CAPACITY,
531  sa->times.data(),
532  sa->values.data());
533  if (authoredSamples > CAPACITY) {
534  sa->Resize(authoredSamples);
535  size_t authoredSamplesSecondAttempt =
537  id,
538  key,
539  authoredSamples,
540  sa->times.data(),
541  sa->values.data());
542  // Number of samples should be consisntent through multiple
543  // invokations of the sampling function.
544  TF_VERIFY(authoredSamples == authoredSamplesSecondAttempt);
545  }
546  sa->count = authoredSamples;
547  }
548 
549  // -----------------------------------------------------------------------//
550  /// \name Instancer prototypes
551  // -----------------------------------------------------------------------//
552 
553  /// Gets the extracted indices array of the prototype id used in the
554  /// instancer.
555  ///
556  /// example
557  /// instances: 0, 1, 2, 3, 4, 5
558  /// protoypes: A, B, A, A, B, C
559  ///
560  /// GetInstanceIndices(A) : [0, 2, 3]
561  /// GetInstanceIndices(B) : [1, 4]
562  /// GetInstanceIndices(C) : [5]
563  /// GetInstanceIndices(D) : []
564  ///
565  HD_API
566  virtual VtIntArray GetInstanceIndices(SdfPath const &instancerId,
567  SdfPath const &prototypeId);
568 
569  /// Returns the instancer transform.
570  HD_API
571  virtual GfMatrix4d GetInstancerTransform(SdfPath const &instancerId);
572 
573 
574  /// Resolves a \p protoRprimId and \p protoIndex back to original
575  /// instancer path by backtracking nested instancer hierarchy.
576  ///
577  /// It will be an empty path if the given protoRprimId is not
578  /// instanced.
579  ///
580  /// (Note: see usdImaging/delegate.h for details specific to USD
581  /// instancing)
582  ///
583  /// If the instancer instances heterogeneously, the instance index of the
584  /// prototype rprim doesn't match the instance index in the instancer.
585  ///
586  /// For example, if we have:
587  ///
588  /// instancer {
589  /// prototypes = [ A, B, A, B, B ]
590  /// }
591  ///
592  /// ...then the indices would be:
593  ///
594  /// protoIndex instancerIndex
595  /// A: [0, 1] [0, 2]
596  /// B: [0, 1, 2] [1, 3, 5]
597  ///
598  /// To track this mapping, the \p instancerIndex is returned which
599  /// corresponds to the given protoIndex.
600  ///
601  /// Also, note if there are nested instancers, the returned path will
602  /// be the top-level instancer, and the \p instancerIndex will be for
603  /// that top-level instancer. This can lead to situations where, contrary
604  /// to the previous scenario, the instancerIndex has fewer possible values
605  /// than the \p protoIndex:
606  ///
607  /// For example, if we have:
608  ///
609  /// instancerBottom {
610  /// prototypes = [ A, A, B ]
611  /// }
612  /// instancerTop {
613  /// prototypes = [ instancerBottom, instancerBottom ]
614  /// }
615  ///
616  /// ...then the indices might be:
617  ///
618  /// protoIndex instancerIndex (for instancerTop)
619  /// A: [0, 1, 2, 3] [0, 0, 1, 1]
620  /// B: [0, 1] [0, 1]
621  ///
622  /// because \p instancerIndex are indices for instancerTop, which only has
623  /// two possible indices.
624  ///
625  /// If \p masterCachePath is not NULL, then it may be set to the cache path
626  /// corresponding instance master prim, if there is one. Otherwise, it will
627  /// be set to null.
628  ///
629  /// If \p instanceContext is not NULL, it is populated with the list of
630  /// instance roots that must be traversed to get to the rprim. If this
631  /// list is non-empty, the last prim is always the forwarded rprim.
632  HD_API
633  virtual SdfPath GetPathForInstanceIndex(const SdfPath &protoRprimId,
634  int protoIndex,
635  int *instancerIndex,
636  SdfPath *masterCachePath=NULL,
637  SdfPathVector *instanceContext=NULL);
638 
639  // -----------------------------------------------------------------------//
640  /// \name Material Aspects
641  // -----------------------------------------------------------------------//
642 
643  /// Returns the material ID bound to the rprim \p rprimId.
644  HD_API
645  virtual SdfPath GetMaterialId(SdfPath const &rprimId);
646 
647  /// Returns the surface shader source code for the given material ID.
648  HD_API
649  virtual std::string GetSurfaceShaderSource(SdfPath const &materialId);
650 
651  /// Returns the displacement shader source code for the given material ID.
652  HD_API
653  virtual std::string GetDisplacementShaderSource(SdfPath const &materialId);
654 
655  /// Returns a single value for the given material and named parameter.
656  HD_API
657  virtual VtValue GetMaterialParamValue(SdfPath const &materialId,
658  TfToken const &paramName);
659 
660  /// Returns the material params for the given material ID.
661  HD_API
662  virtual HdMaterialParamVector GetMaterialParams(SdfPath const& materialId);
663 
664  // Returns a material resource which contains the information
665  // needed to create a material.
666  HD_API
667  virtual VtValue GetMaterialResource(SdfPath const &materialId);
668 
669  // Returns the metadata dictionary for the given material ID.
670  HD_API
671  virtual VtDictionary GetMaterialMetadata(SdfPath const &materialId);
672 
673  // -----------------------------------------------------------------------//
674  /// \name Texture Aspects
675  // -----------------------------------------------------------------------//
676 
677  /// Returns the texture resource ID for a given texture ID.
678  HD_API
679  virtual HdTextureResource::ID GetTextureResourceID(SdfPath const& textureId);
680 
681  /// Returns the texture resource for a given texture ID.
682  HD_API
683  virtual HdTextureResourceSharedPtr GetTextureResource(SdfPath const& textureId);
684 
685  // -----------------------------------------------------------------------//
686  /// \name Renderbuffer Aspects
687  // -----------------------------------------------------------------------//
688 
689  /// Returns the allocation descriptor for a given render buffer prim.
690  HD_API
692 
693  // -----------------------------------------------------------------------//
694  /// \name Light Aspects
695  // -----------------------------------------------------------------------//
696 
697  // Returns a single value for a given light and parameter.
698  HD_API
699  virtual VtValue GetLightParamValue(SdfPath const &id,
700  TfToken const &paramName);
701 
702  // -----------------------------------------------------------------------//
703  /// \name Camera Aspects
704  // -----------------------------------------------------------------------//
705 
706  /// Returns a single value for a given camera and parameter.
707  /// See HdCameraTokens for the list of paramters.
708  HD_API
709  virtual VtValue GetCameraParamValue(SdfPath const& cameraId,
710  TfToken const& paramName);
711 
712  // -----------------------------------------------------------------------//
713  /// \name Volume Aspects
714  // -----------------------------------------------------------------------//
715 
716  HD_API
718  GetVolumeFieldDescriptors(SdfPath const &volumeId);
719 
720  // -----------------------------------------------------------------------//
721  /// \name ExtComputation Aspects
722  // -----------------------------------------------------------------------//
723 
724  ///
725  /// For the given computation id, returns a list of inputs which
726  /// will be requested from the scene delegate using the Get() method.
727  ///
728  /// See GetExtComputationInputDescriptors and
729  /// GetExtComputationOutpuDescriptors for descriptions of other
730  /// computation inputs and outputs.
731  HD_API
732  virtual TfTokenVector
733  GetExtComputationSceneInputNames(SdfPath const& computationId);
734 
735  ///
736  /// For the given computation id, returns a list of computation
737  /// input descriptors.
738  ///
739  /// See HdExtComputationInputDecriptor
740  HD_API
742  GetExtComputationInputDescriptors(SdfPath const& computationId);
743 
744  /// For the given computation id, returns a list of computation
745  /// output descriptors.
746  ///
747  /// See HdExtComputationOutputDescriptor
748  HD_API
750  GetExtComputationOutputDescriptors(SdfPath const& computationId);
751 
752 
753  /// Returns a list of primvar names that should be bound to
754  /// a generated output from an ExtComputation for the given prim id and
755  /// interpolation mode. Binding information is obtained through
756  /// GetExtComputationPrimvarDesc()
757  /// Returns a structure describing source information for a primvar
758  /// that is bound to an ExtComputation. See HdExtComputationPrimvarDesc
759  /// for the expected information to be returned.
760  HD_API
763  HdInterpolation interpolationMode);
764 
765  /// Returns a single value for a given computation id and input token.
766  /// The token may be a computation input or a computation config parameter.
767  HD_API
768  virtual VtValue GetExtComputationInput(SdfPath const& computationId,
769  TfToken const& input);
770 
771  /// Returns the kernel source assigned to the computation at the path id.
772  /// If the string is empty the computation has no GPU kernel and the
773  /// CPU callback should be used.
774  HD_API
775  virtual std::string GetExtComputationKernel(SdfPath const& computationId);
776 
777  /// Requests the scene delegate run the ExtComputation with the given id.
778  /// The context contains the input values that delegate requested through
779  /// GetExtComputationInputNames().
780  ///
781  /// The scene delegate is expected to set each output identified by
782  /// GetExtComputationOutputNames() on the context.
783  ///
784  /// Hydra may invoke the computation on a different thread from
785  /// what HdEngine::Execute() was called on. It may also invoke
786  /// many computations in parallel.
787  HD_API
788  virtual void InvokeExtComputation(SdfPath const& computationId,
790 
791  // -----------------------------------------------------------------------//
792  /// \name Primitive Variables
793  // -----------------------------------------------------------------------//
794 
795  /// Returns descriptors for all primvars of the given interpolation type.
796  HD_API
798  GetPrimvarDescriptors(SdfPath const& id, HdInterpolation interpolation);
799 
800  // -----------------------------------------------------------------------//
801  /// \name Task Aspects
802  // -----------------------------------------------------------------------//
803  HD_API
804  virtual TfTokenVector GetTaskRenderTags(SdfPath const& taskId);
805 
806 private:
807  HdRenderIndex *_index;
808  SdfPath _delegateID;
809 
810  HdSceneDelegate() = delete;
811  HdSceneDelegate(HdSceneDelegate &) = delete;
812  HdSceneDelegate &operator=(HdSceneDelegate &) = delete;
813 };
814 
815 
817 
818 #endif //HD_SCENE_DELEGATE_H
std::shared_ptr< SdfPathVector > HdIdVectorSharedPtr
A shared pointer to a vector of id's.
Definition: sceneDelegate.h:56
void SampleInstancerTransform(SdfPath const &instancerId, HdTimeSampleArray< GfMatrix4d, CAPACITY > *sa)
virtual HD_API VtValue GetExtComputationInput(SdfPath const &computationId, TfToken const &input)
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
bool operator==(HdExtComputationOutputDescriptor const &rhs) const
virtual HD_API size_t SamplePrimvar(SdfPath const &id, TfToken const &key, size_t maxSampleCount, float *sampleTimes, VtValue *sampleValues)
GLenum GLenum GLenum input
Definition: glew.h:13879
HdCullStyle
Definition: enums.h:122
virtual HD_API void PostSyncCleanup()
GLuint const GLchar * name
Definition: glew.h:1814
bool operator!=(HdExtComputationInputDescriptor const &rhs) const
virtual HD_API void InvokeExtComputation(SdfPath const &computationId, HdExtComputationContext *context)
TfSmallVector< float, CAPACITY > times
virtual HD_API bool GetVisible(SdfPath const &id)
Returns the authored visible state of the prim.
bool operator!=(HdPrimvarDescriptor const &rhs) const
~HdDisplayStyle()=default
bool operator!=(HdExtComputationPrimvarDescriptor const &rhs) const
std::vector< HdExtComputationInputDescriptor > HdExtComputationInputDescriptorVector
#define TF_CODING_ERROR
virtual HD_API HdVolumeFieldDescriptorVector GetVolumeFieldDescriptors(SdfPath const &volumeId)
virtual HD_API HdExtComputationInputDescriptorVector GetExtComputationInputDescriptors(SdfPath const &computationId)
GLuint GLenum option
Definition: glew.h:3288
bool operator!=(HdExtComputationOutputDescriptor const &rhs) const
virtual HD_API std::string GetExtComputationKernel(SdfPath const &computationId)
#define HD_API
Definition: api.h:40
virtual HD_API bool IsEnabled(TfToken const &option) const
Returns true if the named option is enabled by the delegate.
HdVolumeFieldDescriptor(TfToken const &fieldName_, TfToken const &fieldPrimType_, SdfPath const &fieldId_)
int refineLevel
The prim refine level, in the range [0, 8].
Definition: sceneDelegate.h:81
std::vector< HdExtComputationOutputDescriptor > HdExtComputationOutputDescriptorVector
virtual HD_API GfMatrix4d GetInstancerTransform(SdfPath const &instancerId)
Returns the instancer transform.
HdExtComputationInputDescriptor(TfToken const &name_, SdfPath const &sourceComputationId_, TfToken const &sourceComputationOutputName_)
virtual HD_API HdBasisCurvesTopology GetBasisCurvesTopology(SdfPath const &id)
Gets the topological curve data for a given prim.
bool operator==(HdExtComputationInputDescriptor const &rhs) const
virtual HD_API PxOsdSubdivTags GetSubdivTags(SdfPath const &id)
Gets the subdivision surface tags (sharpness, holes, etc).
virtual HD_API HdIdVectorSharedPtr GetCoordSysBindings(SdfPath const &id)
Returns the coordinate system bindings, or a nullptr if none are bound.
HdExtComputationPrimvarDescriptor(TfToken const &name_, HdInterpolation interp_, TfToken const &role_, SdfPath const &sourceComputationId_, TfToken const &sourceComputationOutputName_, HdTupleType const &valueType_)
virtual HD_API VtValue GetMaterialResource(SdfPath const &materialId)
Returns the material ID bound to the rprim rprimId.
Definition: token.h:89
virtual HD_API HdDisplayStyle GetDisplayStyle(SdfPath const &id)
virtual HD_API VtArray< TfToken > GetCategories(SdfPath const &id)
Returns the prim categories.
HdInterpolation interpolation
Interpolation (data-sampling rate) of the primvar.
void SamplePrimvar(SdfPath const &id, TfToken const &key, HdTimeSampleArray< VtValue, CAPACITY > *sa)
void Resize(unsigned int newSize)
Resize the internal buffers.
virtual HD_API VtValue GetLightParamValue(SdfPath const &id, TfToken const &paramName)
virtual HD_API HdTextureResourceSharedPtr GetTextureResource(SdfPath const &textureId)
Returns the texture resource for a given texture ID.
TfToken name
Name of the primvar.
HdRenderIndex & GetRenderIndex()
Returns the RenderIndex owned by this delegate.
bool operator==(HdDisplayStyle const &rhs) const
virtual HD_API VtValue GetMaterialParamValue(SdfPath const &materialId, TfToken const &paramName)
Returns a single value for the given material and named parameter.
hboost::shared_ptr< class HdTextureResource > HdTextureResourceSharedPtr
Definition: texture.h:46
virtual HD_API HdPrimvarDescriptorVector GetPrimvarDescriptors(SdfPath const &id, HdInterpolation interpolation)
Returns descriptors for all primvars of the given interpolation type.
virtual HD_API std::string GetDisplacementShaderSource(SdfPath const &materialId)
Returns the displacement shader source code for the given material ID.
virtual HD_API GfMatrix4d GetTransform(SdfPath const &id)
Returns the object space transform, including all parent transforms.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
bool displacementEnabled
Is the prim displacement shaded.
Definition: sceneDelegate.h:87
virtual HD_API GfRange3d GetExtent(SdfPath const &id)
std::vector< HdDirtyBits > dirtyBits
Definition: sceneDelegate.h:72
virtual HD_API TfToken GetRenderTag(SdfPath const &id)
HdPrimvarDescriptor(TfToken const &name_, HdInterpolation interp_, TfToken const &role_=HdPrimvarRoleTokens->none)
virtual HD_API std::string GetSurfaceShaderSource(SdfPath const &materialId)
Returns the surface shader source code for the given material ID.
bool operator==(HdExtComputationPrimvarDescriptor const &rhs) const
Definition: path.h:287
virtual HD_API size_t SampleTransform(SdfPath const &id, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues)
std::vector< HdVolumeFieldDescriptor > HdVolumeFieldDescriptorVector
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:208
TfSmallVector< TYPE, CAPACITY > values
virtual HD_API SdfPath GetPathForInstanceIndex(const SdfPath &protoRprimId, int protoIndex, int *instancerIndex, SdfPath *masterCachePath=NULL, SdfPathVector *instanceContext=NULL)
virtual HD_API SdfPath GetMaterialId(SdfPath const &rprimId)
Returns the material ID bound to the rprim rprimId.
PXR_NAMESPACE_OPEN_SCOPE typedef std::vector< class HdMaterialParam > HdMaterialParamVector
Definition: materialParam.h:43
SdfPath const & GetDelegateID() const
GLsizei const GLchar *const * string
Definition: glew.h:1844
virtual HD_API void Sync(HdSyncRequestVector *request)
Synchronizes the delegate state for the given request vector.
virtual HD_API VtValue Get(SdfPath const &id, TfToken const &key)
Returns a named value.
virtual HD_API VtValue GetCameraParamValue(SdfPath const &cameraId, TfToken const &paramName)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1245
bool operator!=(HdDisplayStyle const &rhs) const
bool flatShadingEnabled
Is the prim flat shaded.
Definition: sceneDelegate.h:84
HdDisplayStyle(int refineLevel_, bool flatShading=false, bool displacement=true)
virtual HD_API HdMeshTopology GetMeshTopology(SdfPath const &id)
Gets the topological mesh data for a given prim.
virtual HD_API ~HdSceneDelegate()
virtual HD_API HdTextureResource::ID GetTextureResourceID(SdfPath const &textureId)
Returns the texture resource ID for a given texture ID.
HdExtComputationOutputDescriptor(TfToken const &name_, HdTupleType const &valueType_)
virtual HD_API TfTokenVector GetExtComputationSceneInputNames(SdfPath const &computationId)
HdInterpolation
Definition: enums.h:255
virtual HD_API TfTokenVector GetTaskRenderTags(SdfPath const &taskId)
virtual HD_API HdReprSelector GetReprSelector(SdfPath const &id)
Returns the authored repr (if any) for the given prim.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:83
virtual HD_API size_t SampleInstancerTransform(SdfPath const &instancerId, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues)
virtual HD_API std::vector< VtArray< TfToken > > GetInstanceCategories(SdfPath const &instancerId)
Returns the categories for all instances in the instancer.
virtual HD_API HdCullStyle GetCullStyle(SdfPath const &id)
Returns the cullstyle for the given prim.
SdfPathVector IDs
Definition: sceneDelegate.h:69
void SampleTransform(SdfPath const &id, HdTimeSampleArray< GfMatrix4d, CAPACITY > *sa)
virtual HD_API HdRenderBufferDescriptor GetRenderBufferDescriptor(SdfPath const &id)
Returns the allocation descriptor for a given render buffer prim.
virtual HD_API HdExtComputationPrimvarDescriptorVector GetExtComputationPrimvarDescriptors(SdfPath const &id, HdInterpolation interpolationMode)
virtual HD_API VtValue GetShadingStyle(SdfPath const &id)
Returns the shading style for the given prim.
std::vector< HdPrimvarDescriptor > HdPrimvarDescriptorVector
bool operator==(HdPrimvarDescriptor const &rhs) const
virtual HD_API HdExtComputationOutputDescriptorVector GetExtComputationOutputDescriptors(SdfPath const &computationId)
virtual HD_API VtDictionary GetMaterialMetadata(SdfPath const &materialId)
Returns the material ID bound to the rprim rprimId.
virtual HD_API HdMaterialParamVector GetMaterialParams(SdfPath const &materialId)
Returns the material params for the given material ID.
Definition: value.h:182
virtual HD_API VtIntArray GetInstanceIndices(SdfPath const &instancerId, SdfPath const &prototypeId)
virtual HD_API bool GetDoubleSided(SdfPath const &id)
Returns the doubleSided state for the given prim.
std::vector< HdExtComputationPrimvarDescriptor > HdExtComputationPrimvarDescriptorVector
value_type * data()
Definition: smallVector.h:746