HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
engine.h
Go to the documentation of this file.
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 
8 /// \file usdImagingGL/engine.h
9 
10 #ifndef PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H
11 #define PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H
12 
13 #include "pxr/pxr.h"
18 
21 
23 
24 #include "pxr/imaging/hd/driver.h"
25 #include "pxr/imaging/hd/engine.h"
29 
32 
33 #include "pxr/imaging/hgi/hgi.h"
34 
37 
38 #include "pxr/imaging/hgi/hgi.h"
39 
40 #include "pxr/usd/sdf/path.h"
41 #include "pxr/usd/usd/timeCode.h"
42 
43 #include "pxr/base/gf/frustum.h"
44 #include "pxr/base/gf/matrix4d.h"
45 #include "pxr/base/gf/vec4d.h"
46 #include "pxr/base/gf/vec4f.h"
47 #include "pxr/base/gf/vec4i.h"
48 
49 #include "pxr/base/vt/dictionary.h"
50 
52 
54 
55 class UsdPrim;
56 class HdRenderIndex;
57 class HdxTaskController;
58 class UsdImagingDelegate;
59 
72 
74 
75 namespace UsdImagingGLEngine_Impl
76 {
77  using _AppSceneIndicesSharedPtr = std::shared_ptr<struct _AppSceneIndices>;
78 }
79 
80 /// \class UsdImagingGLEngine
81 ///
82 /// The UsdImagingGLEngine is the main entry point API for rendering USD scenes.
83 ///
85 {
86 public:
87  /// Parameters to construct UsdImagingGLEngine.
88  struct Parameters
89  {
94  /// An HdDriver, containing the Hgi of your choice, can be optionally passed
95  /// in during construction. This can be helpful if your application creates
96  /// multiple UsdImagingGLEngine's that wish to use the same HdDriver / Hgi.
98  /// The \p rendererPluginId argument indicates the renderer plugin that
99  /// Hydra should use. If the empty token is passed in, a default renderer
100  /// plugin will be chosen depending on the value of \p gpuEnabled.
102  /// The \p gpuEnabled argument determines if this instance will allow Hydra
103  /// to use the GPU to produce images.
104  bool gpuEnabled = true;
105  /// \p displayUnloadedPrimsWithBounds draws bounding boxes for unloaded
106  /// prims if they have extents/extentsHint authored.
108  /// \p allowAsynchronousSceneProcessing indicates to constructed hydra
109  /// scene indices that asynchronous processing is allowow. Applications
110  /// should perodically call PollForAsynchronousUpdates on the engine.
112  /// \p enableUsdDrawModes enables the UsdGeomModelAPI draw mode
113  /// feature.
114  bool enableUsdDrawModes = true;
115  };
116 
117  // ---------------------------------------------------------------------
118  /// \name Construction
119  /// @{
120  // ---------------------------------------------------------------------
121 
124 
125  /// An HdDriver, containing the Hgi of your choice, can be optionally passed
126  /// in during construction. This can be helpful if you application creates
127  /// multiple UsdImagingGLEngine that wish to use the same HdDriver / Hgi.
128  /// The \p rendererPluginId argument indicates the renderer plugin that
129  /// Hyrda should use. If the empty token is passed in, a default renderer
130  /// plugin will be chosen depending on the value of \p gpuEnabled.
131  /// The \p gpuEnabled argument determines if this instance will allow Hydra
132  /// to use the GPU to produce images.
134  UsdImagingGLEngine(const HdDriver& driver = HdDriver(),
135  const TfToken& rendererPluginId = TfToken(),
136  bool gpuEnabled = true);
137 
139  UsdImagingGLEngine(const SdfPath& rootPath,
140  const SdfPathVector& excludedPaths,
141  const SdfPathVector& invisedPaths = SdfPathVector(),
142  const SdfPath& sceneDelegateID =
144  const HdDriver& driver = HdDriver(),
145  const TfToken& rendererPluginId = TfToken(),
146  const bool gpuEnabled = true,
147  const bool displayUnloadedPrimsWithBounds = false,
148  const bool allowAsynchronousSceneProcessing = false,
149  const bool enableUsdDrawModes = true);
150 
151  // Disallow copies
152  UsdImagingGLEngine(const UsdImagingGLEngine&) = delete;
154 
157 
158  /// @}
159 
160  // ---------------------------------------------------------------------
161  /// \name Rendering
162  /// @{
163  // ---------------------------------------------------------------------
164 
165  /// Support for batched drawing
167  void PrepareBatch(const UsdPrim& root,
170  void RenderBatch(const SdfPathVector& paths,
172 
173  /// Entry point for kicking off a render
175  void Render(const UsdPrim& root,
177 
178  /// Returns true if the resulting image is fully converged.
179  /// (otherwise, caller may need to call Render() again to refine the result)
181  bool IsConverged() const;
182 
183  /// @}
184 
185  // ---------------------------------------------------------------------
186  /// \name Root Transform and Visibility
187  /// @{
188  // ---------------------------------------------------------------------
189 
190  /// Sets the root transform.
192  void SetRootTransform(GfMatrix4d const& xf);
193 
194  /// Sets the root visibility.
196  void SetRootVisibility(bool isVisible);
197 
198  /// @}
199 
200  // ---------------------------------------------------------------------
201  /// \name Camera State
202  /// @{
203  // ---------------------------------------------------------------------
204 
205  /// Scene camera API
206  /// Set the scene camera path to use for rendering.
208  void SetCameraPath(SdfPath const& id);
209 
210  /// Determines how the filmback of the camera is mapped into
211  /// the pixels of the render buffer and what pixels of the render
212  /// buffer will be rendered into.
214  void SetFraming(CameraUtilFraming const& framing);
215 
216  /// Specifies whether to force a window policy when conforming
217  /// the frustum of the camera to match the display window of
218  /// the camera framing.
219  ///
220  /// If set to {false, ...}, the window policy of the specified camera
221  /// will be used.
222  ///
223  /// Note: std::pair<bool, ...> is used instead of std::optional<...>
224  /// because the latter is only available in C++17 or later.
227  const std::optional<CameraUtilConformWindowPolicy> &policy);
228 
229  /// Set the size of the render buffers baking the AOVs.
230  /// GUI applications should set this to the size of the window.
231  ///
233  void SetRenderBufferSize(GfVec2i const& size);
234 
235  /// Set the viewport to use for rendering as (x,y,w,h), where (x,y)
236  /// represents the lower left corner of the viewport rectangle, and (w,h)
237  /// is the width and height of the viewport in pixels.
238  ///
239  /// \deprecated Use SetFraming and SetRenderBufferSize instead.
241  void SetRenderViewport(GfVec4d const& viewport);
242 
243  /// Set the window policy to use.
244  /// XXX: This is currently used for scene cameras set via SetCameraPath.
245  /// See comment in SetCameraState for the free cam.
248 
249  /// Free camera API
250  /// Set camera framing state directly (without pointing to a camera on the
251  /// USD stage). The projection matrix is expected to be pre-adjusted for the
252  /// window policy.
254  void SetCameraState(const GfMatrix4d& viewMatrix,
255  const GfMatrix4d& projectionMatrix);
256 
257  /// @}
258 
259  // ---------------------------------------------------------------------
260  /// \name Light State
261  /// @{
262  // ---------------------------------------------------------------------
263 
264  /// Copy lighting state from another lighting context.
266  void SetLightingState(GlfSimpleLightingContextPtr const &src);
267 
268  /// Set lighting state
269  /// Derived classes should ensure that passing an empty lights
270  /// vector disables lighting.
271  /// \param lights is the set of lights to use, or empty to disable lighting.
273  void SetLightingState(GlfSimpleLightVector const &lights,
274  GlfSimpleMaterial const &material,
275  GfVec4f const &sceneAmbient);
276 
277  /// @}
278 
279  // ---------------------------------------------------------------------
280  /// \name Selection Highlighting
281  /// @{
282  // ---------------------------------------------------------------------
283 
284  /// Sets (replaces) the list of prim paths that should be included in
285  /// selection highlighting. These paths may include root paths which will
286  /// be expanded internally.
288  void SetSelected(SdfPathVector const& paths);
289 
290  /// Clear the list of prim paths that should be included in selection
291  /// highlighting.
293  void ClearSelected();
294 
295  /// Add a path with instanceIndex to the list of prim paths that should be
296  /// included in selection highlighting. UsdImagingDelegate::ALL_INSTANCES
297  /// can be used for highlighting all instances if path is an instancer.
299  void AddSelected(SdfPath const &path, int instanceIndex);
300 
301  /// Sets the selection highlighting color.
303  void SetSelectionColor(GfVec4f const& color);
304 
305  /// @}
306 
307  // ---------------------------------------------------------------------
308  /// \name Picking
309  /// @{
310  // ---------------------------------------------------------------------
311 
312  /// Finds closest point of intersection with a frustum by rendering.
313  ///
314  /// This method uses a PickRender and a customized depth buffer to find an
315  /// approximate point of intersection by rendering. This is less accurate
316  /// than implicit methods or rendering with GL_SELECT, but leverages any
317  /// data already cached in the renderer.
318  ///
319  /// Returns whether a hit occurred and if so, \p outHitPoint will contain
320  /// the intersection point in world space (i.e. \p projectionMatrix and
321  /// \p viewMatrix factored back out of the result), and \p outHitNormal
322  /// will contain the world space normal at that point.
323  ///
324  /// \p outHitPrimPath will point to the gprim selected by the pick.
325  /// \p outHitInstancerPath will point to the point instancer (if applicable)
326  /// of that gprim. For nested instancing, outHitInstancerPath points to
327  /// the closest instancer.
328  ///
329  /// \deprecated Please use the override of TestIntersection that takes
330  /// PickParams and returns an IntersectionResultVector instead!
332  bool TestIntersection(
333  const GfMatrix4d &viewMatrix,
334  const GfMatrix4d &projectionMatrix,
335  const UsdPrim& root,
337  GfVec3d *outHitPoint,
338  GfVec3d *outHitNormal,
339  SdfPath *outHitPrimPath = NULL,
340  SdfPath *outHitInstancerPath = NULL,
341  int *outHitInstanceIndex = NULL,
342  HdInstancerContext *outInstancerContext = NULL);
343 
344  // Pick result
346  {
353  };
354 
355  typedef std::vector<struct IntersectionResult> IntersectionResultVector;
356 
357  // Pick params
358  struct PickParams
359  {
361  };
362 
363  /// Perform picking by finding the intersection of objects in the scene with a renderered frustum.
364  /// Depending on the resolve mode it may find all objects intersecting the frustum or the closest
365  /// point of intersection within the frustum.
366  ///
367  /// If resolve mode is set to resolveDeep it uses Deep Selection to gather all paths within
368  /// the frustum even if obscured by other visible objects.
369  /// If resolve mode is set to resolveNearestToCenter it uses a PickRender and
370  /// a customized depth buffer to find all approximate points of intersection by rendering.
371  /// This is less accurate than implicit methods or rendering with GL_SELECT, but leverages any
372  /// data already cached in the renderer.
373  ///
374  /// Returns whether a hit occurred and if so, \p outResults will point to all the
375  /// gprims selected by the pick as determined by the resolve mode.
376  /// \p outHitPoint will contain the intersection point in world space
377  /// (i.e. \p projectionMatrix and \p viewMatrix factored back out of the result)
378  /// \p outHitNormal will contain the world space normal at that point.
379  /// \p hitPrimPath will point to the gprim selected by the pick.
380  /// \p hitInstancerPath will point to the point instancer (if applicable) of each gprim.
381  ///
383  bool TestIntersection(
384  const PickParams& pickParams,
385  const GfMatrix4d& viewMatrix,
386  const GfMatrix4d& projectionMatrix,
387  const UsdPrim& root,
389  IntersectionResultVector* outResults);
390 
391  /// Decodes a pick result given hydra prim ID/instance ID (like you'd get
392  /// from an ID render), where ID is represented as a vec4 color.
394  bool DecodeIntersection(
395  unsigned char const primIdColor[4],
396  unsigned char const instanceIdColor[4],
397  SdfPath *outHitPrimPath = NULL,
398  SdfPath *outHitInstancerPath = NULL,
399  int *outHitInstanceIndex = NULL,
400  HdInstancerContext *outInstancerContext = NULL);
401 
402  /// Decodes a pick result given hydra prim ID/instance ID (like you'd get
403  /// from an ID render), where ID is represented as a int.
405  bool DecodeIntersection(
406  int primIdx,
407  int instanceIdx,
408  SdfPath *outHitPrimPath = NULL,
409  SdfPath *outHitInstancerPath = NULL,
410  int *outHitInstanceIndex = NULL,
411  HdInstancerContext *outInstancerContext = NULL);
412 
413  /// @}
414 
415  // ---------------------------------------------------------------------
416  /// \name Renderer Plugin Management
417  /// @{
418  // ---------------------------------------------------------------------
419 
420  /// Return the vector of available render-graph delegate plugins.
423 
424  /// Return the user-friendly name of a renderer plugin.
426  static std::string GetRendererDisplayName(TfToken const &id);
427 
428  /// Return the user-friendly name of the Hgi implementation.
429  /// For example: OpenGL, Metal, Vulkan. This is only available
430  /// if a render plugin was set and it uses Hgi.
432  std::string GetRendererHgiDisplayName() const;
433 
434  /// Return if the GPU is enabled and can be used for any rendering tasks.
436  bool GetGPUEnabled() const;
437 
438  /// Return the id of the currently used renderer plugin.
441 
442  /// Set the current render-graph delegate to \p id.
443  /// the plugin will be loaded if it's not yet.
445  bool SetRendererPlugin(TfToken const &id);
446 
447  /// @}
448 
449  // ---------------------------------------------------------------------
450  /// \name AOVs
451  /// @{
452  // ---------------------------------------------------------------------
453 
454  /// Return the vector of available renderer AOV settings.
457 
458  /// Set the current renderer AOV to \p id.
460  bool SetRendererAov(TfToken const& id);
461 
462  /// Set the current renderer AOVs to a list of \p ids.
464  bool SetRendererAovs(TfTokenVector const &ids);
465 
466  /// Returns an AOV texture handle for the given token.
469 
470  /// Returns the AOV render buffer for the given token.
473 
474  // ---------------------------------------------------------------------
475  /// \name Render Settings (Legacy)
476  /// @{
477  // ---------------------------------------------------------------------
478 
479  /// Returns the list of renderer settings.
482 
483  /// Gets a renderer setting's current value.
485  VtValue GetRendererSetting(TfToken const& id) const;
486 
487  /// Sets a renderer setting's value.
489  void SetRendererSetting(TfToken const& id,
490  VtValue const& value);
491 
492  /// @}
493 
494  // ---------------------------------------------------------------------
495  /// \name Scene-defined Render Pass and Render Settings
496  /// \note Support is WIP.
497  /// @{
498  // ---------------------------------------------------------------------
499 
500  /// Returns the active render pass prim path by querying the terminal scene
501  /// index. Returns an empty path if none was found.
504 
505  /// Returns the active render settings prim path by querying the terminal
506  /// scene index. Returns an empty path if none was found.
509 
510  /// Utility method to query available render settings prims.
512  static SdfPathVector
514 
515  /// Set active render pass prim to use to drive rendering.
517  void SetActiveRenderPassPrimPath(SdfPath const &);
518 
519  /// Set active render settings prim to use to drive rendering.
522 
523 
524  /// @}
525 
526  // ---------------------------------------------------------------------
527  /// \name Presentation
528  /// @{
529  // ---------------------------------------------------------------------
530 
531  /// Enable / disable presenting the render to bound framebuffer.
532  /// An application may choose to manage the AOVs that are rendered into
533  /// itself and skip the engine's presentation.
535  void SetEnablePresentation(bool enabled);
536 
537  /// The destination API (e.g., OpenGL, see hgiInterop for details) and
538  /// framebuffer that the AOVs are presented into. The framebuffer
539  /// is a VtValue that encoding a framebuffer in a destination API
540  /// specific way.
541  /// E.g., a uint32_t (aka GLuint) for framebuffer object for OpenGL.
543  void SetPresentationOutput(TfToken const &api, VtValue const &framebuffer);
544 
545  /// @}
546 
547  // ---------------------------------------------------------------------
548  /// \name Renderer Command API
549  /// @{
550  // ---------------------------------------------------------------------
551 
552  /// Return command deescriptors for commands supported by the active
553  /// render delegate.
554  ///
557 
558  /// Invokes command on the active render delegate. If successful, returns
559  /// \c true, returns \c false otherwise. Note that the command will not
560  /// succeeed if it is not among those returned by
561  /// GetRendererCommandDescriptors() for the same active render delegate.
562  ///
565  const TfToken &command,
566  const HdCommandArgs &args = HdCommandArgs()) const;
567 
568  // ---------------------------------------------------------------------
569  /// \name Control of background rendering threads.
570  /// @{
571  // ---------------------------------------------------------------------
572 
573  /// Query the renderer as to whether it supports pausing and resuming.
575  bool IsPauseRendererSupported() const;
576 
577  /// Pause the renderer.
578  ///
579  /// Returns \c true if successful.
581  bool PauseRenderer();
582 
583  /// Resume the renderer.
584  ///
585  /// Returns \c true if successful.
587  bool ResumeRenderer();
588 
589  /// Query the renderer as to whether it supports stopping and restarting.
591  bool IsStopRendererSupported() const;
592 
593  /// Stop the renderer.
594  ///
595  /// Returns \c true if successful.
597  bool StopRenderer();
598 
599  /// Restart the renderer.
600  ///
601  /// Returns \c true if successful.
603  bool RestartRenderer();
604 
605  /// @}
606 
607  // ---------------------------------------------------------------------
608  /// \name Color Correction
609  /// @{
610  // ---------------------------------------------------------------------
611 
612  /// Set \p ccType to one of the HdxColorCorrectionTokens:
613  /// {disabled, sRGB, openColorIO}
614  ///
615  /// If 'openColorIO' is used, \p ocioDisplay, \p ocioView, \p ocioColorSpace
616  /// and \p ocioLook are options the client may supply to configure OCIO.
617  /// \p ocioColorSpace refers to the input (source) color space.
618  /// The default value is substituted if an option isn't specified.
619  /// You can find the values for these strings inside the
620  /// profile/config .ocio file. For example:
621  ///
622  /// displays:
623  /// rec709g22:
624  /// !<View> {name: studio, colorspace: linear, looks: studio_65_lg2}
625  ///
628  TfToken const& ccType,
629  TfToken const& ocioDisplay = {},
630  TfToken const& ocioView = {},
631  TfToken const& ocioColorSpace = {},
632  TfToken const& ocioLook = {});
633 
634  /// @}
635 
636  /// Returns true if the platform is color correction capable.
638  static bool IsColorCorrectionCapable();
639 
640  // ---------------------------------------------------------------------
641  /// \name Render Statistics
642  /// @{
643  // ---------------------------------------------------------------------
644 
645  /// Returns render statistics.
646  ///
647  /// The contents of the dictionary will depend on the current render
648  /// delegate.
649  ///
652 
653  /// @}
654 
655  // ---------------------------------------------------------------------
656  /// \name HGI
657  /// @{
658  // ---------------------------------------------------------------------
659 
660  /// Returns the HGI interface.
661  ///
663  Hgi* GetHgi();
664 
665  /// @}
666 
667  // ---------------------------------------------------------------------
668  /// \name Asynchronous
669  /// @{
670  // ---------------------------------------------------------------------
671 
672  /// If \p allowAsynchronousSceneProcessing is true within the Parameters
673  /// provided to the UsdImagingGLEngine constructor, an application can
674  /// periodically call this from the main thread.
675  ///
676  /// A return value of true indicates that the scene has changed and the
677  /// render should be updated.
679  bool PollForAsynchronousUpdates() const;
680 
681  /// @}
682 
683 
684  // ---------------------------------------------------------------------
685  /// \name Miscellaneous
686  /// @{
687  // ---------------------------------------------------------------------
688 
689  /// Returns true if using the UsdImaging scene index.
691  static bool UseUsdImagingSceneIndex();
692  /// @}
693 
694 protected:
695 
696  /// Open some protected methods for whitebox testing.
698 
699  /// Returns the render index of the engine, if any. This is only used for
700  /// whitebox testing.
703 
706  const SdfPathVector &taskPaths);
707 
709  bool _CanPrepare(const UsdPrim& root);
714 
717 
720 
723 
726 
727  using BBoxVector = std::vector<GfBBox3d>;
728 
730  void _SetBBoxParams(
731  const BBoxVector& bboxes,
732  const GfVec4f& bboxLineColor,
733  float bboxLineDashSize);
734 
735  // Create a hydra collection given root paths and render params.
736  // Returns true if the collection was updated.
738  static bool _UpdateHydraCollection(HdRprimCollection *collection,
739  SdfPathVector const& roots,
746  TfTokenVector *renderTags);
747 
750 
754  HdContainerDataSourceHandle const &sceneIndexInputArgs);
755 
757  void _SetRenderDelegate(
759  HdContainerDataSourceHandle const &sceneIndexInputArgs);
760 
762  SdfPath _ComputeControllerPath(const TfToken &pluginId);
763 
766 
769 
770  /// Get a direct pointer to the scene delegate.
771  /// \deprecated Existing instances of this call will be replaced with new
772  /// APIs on this class, to support multiplexing between the
773  /// scene delegate and scene index. This API is scheduled for
774  /// deletion.
777 
780 
781  /// \deprecated The HdxTaskController is replaced by the
782  /// HdxTaskControllerSceneIndex.
785 
788 
789  // Create UsdImagingStageSceneIndex and subsequent scene indices.
790  void
791  _CreateUsdImagingSceneIndices(HdContainerDataSourceHandle const &inputArgs);
792 
793 protected:
794 
795  // Note that any of the fields below might become private
796  // in the future and subclasses should use the above getters
797  // to access them instead.
798 
800  // Similar for HdDriver.
802 
804 
805 protected:
808 
809  /* Hydra 2.0 */
810 
812  HdxTaskControllerSceneIndexRefPtr _taskControllerSceneIndex;
813 
814  /* Hydra 1.0 */
816  std::unique_ptr<HdRenderIndex> _renderIndex;
817  std::unique_ptr<HdxTaskController> _taskController;
818 
820 
824 
825  GlfSimpleLightingContextRefPtr _lightingContextForOpenGLState;
826 
827  // Data we want to live across render plugin switches:
830 
835 
836 private:
837  bool _HasRenderer() const;
838  HdSceneIndexBaseRefPtr _GetTerminalSceneIndex() const;
839 
840  HdSceneIndexBaseRefPtr
841  _AppendOverridesSceneIndices(
842  const HdSceneIndexBaseRefPtr &inputScene);
843 
845 
846  bool _CreateSceneIndicesAndRenderer(
847  HdRendererPluginHandle const &plugin,
848  HdContainerDataSourceHandle const &sceneIndexInputArgs);
849 
850  void _DestroyHydraObjects();
851 
852  SdfPath _GetInstancerForPrim(const SdfPath &sceneIndexPath) const;
853 
854  // Note that we'll only ever use one of _sceneIndex/_sceneDelegate
855  // at a time.
856  UsdImagingStageSceneIndexRefPtr _stageSceneIndex;
857  HdNoticeBatchingSceneIndexRefPtr _postInstancingNoticeBatchingSceneIndex;
858  UsdImagingSelectionSceneIndexRefPtr _selectionSceneIndex;
859  UsdImagingRootOverridesSceneIndexRefPtr _rootOverridesSceneIndex;
860  UsdImagingLegacyRenderSettingsSceneIndexRefPtr _legacyRenderSettingsSceneIndex;
861  HdsiLegacyDisplayStyleOverrideSceneIndexRefPtr _displayStyleSceneIndex;
862  HdsiPrimTypeAndPathPruningSceneIndexRefPtr _lightPruningSceneIndex;
863  // State of the _lightPruningSceneIndex.
864  bool _lightPruningSceneIndexEnableSceneLights;
865  HdSceneIndexBaseRefPtr _usdImagingFinalSceneIndex;
866 
867  HdMergingSceneIndexRefPtr _mergingSceneIndex;
868  HdCachingSceneIndexRefPtr _cachingSceneIndex;
869  HdSceneIndexBaseRefPtr _terminalSceneIndex;
870 
871  /* Hydra 1.0 */
872  std::unique_ptr<UsdImagingDelegate> _sceneDelegate;
873  std::unique_ptr<HdEngine> _engine;
874 
875  bool _allowAsynchronousSceneProcessing = false;
876  bool _enableUsdDrawModes = true;
877 };
878 
880 
881 #endif // PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H
USDIMAGINGGL_API void SetRenderViewport(GfVec4d const &viewport)
USDIMAGINGGL_API bool GetGPUEnabled() const
Return if the GPU is enabled and can be used for any rendering tasks.
USDIMAGINGGL_API TfToken GetCurrentRendererId() const
Return the id of the currently used renderer plugin.
static SDF_API const SdfPath & AbsoluteRootPath()
GlfSimpleLightingContextRefPtr _lightingContextForOpenGLState
Definition: engine.h:825
HdRprimCollection _intersectCollection
Definition: engine.h:823
USDIMAGINGGL_API void SetSelectionColor(GfVec4f const &color)
Sets the selection highlighting color.
Definition: vec2i.h:43
USDIMAGINGGL_API HdSelectionSharedPtr _GetSelection() const
USDIMAGINGGL_API void SetOverrideWindowPolicy(const std::optional< CameraUtilConformWindowPolicy > &policy)
TF_DECLARE_REF_PTRS(HdNoticeBatchingSceneIndex)
TF_DECLARE_WEAK_AND_REF_PTRS(GlfSimpleLightingContext)
USDIMAGINGGL_API bool _CanPrepare(const UsdPrim &root)
GT_API const UT_StringHolder time
SdfPath const _sceneDelegateId
Definition: engine.h:819
HdPluginRenderDelegateUniqueHandle _renderDelegate
Definition: engine.h:815
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
static USDIMAGINGGL_API HdxRenderTaskParams _MakeHydraUsdImagingGLRenderParams(UsdImagingGLRenderParams const &params)
GLsizei const GLfloat * value
Definition: glcorearb.h:824
USDIMAGINGGL_API bool TestIntersection(const GfMatrix4d &viewMatrix, const GfMatrix4d &projectionMatrix, const UsdPrim &root, const UsdImagingGLRenderParams &params, GfVec3d *outHitPoint, GfVec3d *outHitNormal, SdfPath *outHitPrimPath=NULL, SdfPath *outHitInstancerPath=NULL, int *outHitInstanceIndex=NULL, HdInstancerContext *outInstancerContext=NULL)
USDIMAGINGGL_API void SetCameraPath(SdfPath const &id)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDIMAGINGGL_API bool _UpdateHydraCollection(HdRprimCollection *collection, SdfPathVector const &roots, UsdImagingGLRenderParams const &params)
SdfPathVector invisedPaths
Definition: engine.h:92
USDIMAGINGGL_API Hgi * GetHgi()
SdfPathVector excludedPaths
Definition: engine.h:91
USDIMAGINGGL_API void _InitializeHgiIfNecessary()
USDIMAGINGGL_API bool PauseRenderer()
USDIMAGINGGL_API void SetActiveRenderSettingsPrimPath(SdfPath const &)
Set active render settings prim to use to drive rendering.
UsdImagingGLEngine & operator=(const UsdImagingGLEngine &)=delete
Definition: vec4d.h:45
USDIMAGINGGL_API void _Execute(const UsdImagingGLRenderParams &params, const SdfPathVector &taskPaths)
int HgiHandle< class HgiTexture > HgiTextureHandle
bool _domeLightCameraVisibility
Definition: engine.h:829
static USDIMAGINGGL_API bool IsColorCorrectionCapable()
Returns true if the platform is color correction capable.
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2539
USDIMAGINGGL_API SdfPath GetActiveRenderSettingsPrimPath() const
void _CreateUsdImagingSceneIndices(HdContainerDataSourceHandle const &inputArgs)
USDIMAGINGGL_API bool SetRendererAovs(TfTokenVector const &ids)
Set the current renderer AOVs to a list of ids.
bool _displayUnloadedPrimsWithBounds
Definition: engine.h:806
GLenum const GLfloat * params
Definition: glcorearb.h:105
UsdStagePtr UsdStageWeakPtr
Definition: common.h:38
USDIMAGINGGL_API bool IsPauseRendererSupported() const
Query the renderer as to whether it supports pausing and resuming.
USDIMAGINGGL_API void _PreSetTime(const UsdImagingGLRenderParams &params)
USDIMAGINGGL_API bool PollForAsynchronousUpdates() const
USDIMAGINGGL_API UsdImagingDelegate * _GetSceneDelegate() const
std::shared_ptr< class HdxSelectionTracker > HdxSelectionTrackerSharedPtr
std::vector< std::pair< SdfPath, int > > HdInstancerContext
Instancer context: a pair of instancer paths and instance indices.
Definition: sceneDelegate.h:44
USDIMAGINGGL_API void SetCameraState(const GfMatrix4d &viewMatrix, const GfMatrix4d &projectionMatrix)
USDIMAGINGGL_API bool SetRendererPlugin(TfToken const &id)
USDIMAGINGGL_API void SetFraming(CameraUtilFraming const &framing)
Parameters to construct UsdImagingGLEngine.
Definition: engine.h:88
USDIMAGINGGL_API void SetRenderBufferSize(GfVec2i const &size)
friend class UsdImagingGL_UnitTestGLDrawing
Open some protected methods for whitebox testing.
Definition: engine.h:697
static USDIMAGINGGL_API bool UseUsdImagingSceneIndex()
Returns true if using the UsdImaging scene index.
Definition: token.h:70
VtValue _userFramebuffer
Definition: engine.h:803
GLuint framebuffer
Definition: glcorearb.h:1287
#define USDIMAGINGGL_API
Definition: api.h:23
static USDIMAGINGGL_API void _ComputeRenderTags(UsdImagingGLRenderParams const &params, TfTokenVector *renderTags)
USDIMAGINGGL_API void _PostSetTime(const UsdImagingGLRenderParams &params)
USDIMAGINGGL_API void AddSelected(SdfPath const &path, int instanceIndex)
GfVec4f _selectionColor
Definition: engine.h:828
HdRprimCollection _renderCollection
Definition: engine.h:822
USDIMAGINGGL_API void _SetBBoxParams(const BBoxVector &bboxes, const GfVec4f &bboxLineColor, float bboxLineDashSize)
USDIMAGINGGL_API HgiTextureHandle GetAovTexture(TfToken const &name) const
Returns an AOV texture handle for the given token.
std::vector< class SdfPath > SdfPathVector
std::vector< struct IntersectionResult > IntersectionResultVector
Definition: engine.h:355
std::vector< HdCommandDescriptor > HdCommandDescriptors
Definition: command.h:91
USDIMAGINGGL_API void SetSelected(SdfPathVector const &paths)
USDIMAGINGGL_API HdRenderIndex * _GetRenderIndex() const
static USDIMAGINGGL_API TfTokenVector GetRendererPlugins()
Return the vector of available render-graph delegate plugins.
USDIMAGINGGL_API void _SetRenderDelegateAndRestoreState(HdPluginRenderDelegateUniqueHandle &&, HdContainerDataSourceHandle const &sceneIndexInputArgs)
USDIMAGINGGL_API void SetRootTransform(GfMatrix4d const &xf)
Sets the root transform.
USDIMAGINGGL_API void SetWindowPolicy(CameraUtilConformWindowPolicy policy)
USDIMAGINGGL_API ~UsdImagingGLEngine()
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
USDIMAGINGGL_API bool SetRendererAov(TfToken const &id)
Set the current renderer AOV to id.
USDIMAGINGGL_API bool InvokeRendererCommand(const TfToken &command, const HdCommandArgs &args=HdCommandArgs()) const
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:280
USDIMAGINGGL_API void _SetSceneGlobalsCurrentFrame(UsdTimeCode const &time)
USDIMAGINGGL_API SdfPath GetActiveRenderPassPrimPath() const
HdxSelectionTrackerSharedPtr _selTracker
Definition: engine.h:821
HdxTaskControllerSceneIndexRefPtr _taskControllerSceneIndex
Definition: engine.h:812
USDIMAGINGGL_API UsdImagingGLRendererSettingsList GetRendererSettingsList() const
Returns the list of renderer settings.
std::unique_ptr< HdRenderIndex > _renderIndex
Definition: engine.h:816
USDIMAGINGGL_API bool IsConverged() const
USDIMAGINGGL_API void SetRendererSetting(TfToken const &id, VtValue const &value)
Sets a renderer setting's value.
Definition: vec4f.h:45
CameraUtilConformWindowPolicy
Definition: conformWindow.h:27
USDIMAGINGGL_API void Render(const UsdPrim &root, const UsdImagingGLRenderParams &params)
Entry point for kicking off a render.
SdfPathVector _invisedPrimPaths
Definition: engine.h:833
Definition: hgi.h:94
GLsizeiptr size
Definition: glcorearb.h:664
USDIMAGINGGL_API void _SetActiveRenderSettingsPrimFromStageMetadata(UsdStageWeakPtr stage)
std::unique_ptr< HdxTaskController > _taskController
Definition: engine.h:817
USDIMAGINGGL_API void PrepareBatch(const UsdPrim &root, const UsdImagingGLRenderParams &params)
Support for batched drawing.
USDIMAGINGGL_API void _PrepareRender(const UsdImagingGLRenderParams &params)
GLuint color
Definition: glcorearb.h:1261
VtDictionary HdCommandArgs
Definition: command.h:54
USDIMAGINGGL_API bool StopRenderer()
USDIMAGINGGL_API bool RestartRenderer()
USDIMAGINGGL_API HdRenderBuffer * GetAovRenderBuffer(TfToken const &name) const
Returns the AOV render buffer for the given token.
USDIMAGINGGL_API void ClearSelected()
HgiUniquePtr _hgi
Definition: engine.h:799
std::vector< GfBBox3d > BBoxVector
Definition: engine.h:727
USDIMAGINGGL_API bool IsStopRendererSupported() const
Query the renderer as to whether it supports stopping and restarting.
std::vector< UsdImagingGLRendererSetting > UsdImagingGLRendererSettingsList
USDIMAGINGGL_API void SetLightingState(GlfSimpleLightingContextPtr const &src)
Copy lighting state from another lighting context.
HdDriver _hgiDriver
Definition: engine.h:801
Definition: vec3d.h:45
USDIMAGINGGL_API void RenderBatch(const SdfPathVector &paths, const UsdImagingGLRenderParams &params)
Support for batched drawing.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDIMAGINGGL_API UsdImagingGLEngine(const Parameters &params)
USDIMAGINGGL_API TfTokenVector GetRendererAovs() const
Return the vector of available renderer AOV settings.
USDIMAGINGGL_API void SetColorCorrectionSettings(TfToken const &ccType, TfToken const &ocioDisplay={}, TfToken const &ocioView={}, TfToken const &ocioColorSpace={}, TfToken const &ocioLook={})
**If you just want to fire and args
Definition: thread.h:618
USDIMAGINGGL_API VtValue GetRendererSetting(TfToken const &id) const
Gets a renderer setting's current value.
USDIMAGINGGL_API bool ResumeRenderer()
SdfPathVector _excludedPrimPaths
Definition: engine.h:832
static USDIMAGINGGL_API std::string GetRendererDisplayName(TfToken const &id)
Return the user-friendly name of a renderer plugin.
std::shared_ptr< struct _AppSceneIndices > _AppSceneIndicesSharedPtr
Definition: engine.h:77
USDIMAGINGGL_API HdEngine * _GetHdEngine()
USDIMAGINGGL_API void _UpdateDomeLightCameraVisibility()
USDIMAGINGGL_API void SetActiveRenderPassPrimPath(SdfPath const &)
Set active render pass prim to use to drive rendering.
USDIMAGINGGL_API SdfPath _ComputeControllerPath(const TfToken &pluginId)
USDIMAGINGGL_API VtDictionary GetRenderStats() const
USDIMAGINGGL_API HdCommandDescriptors GetRendererCommandDescriptors() const
std::shared_ptr< class HdSelection > HdSelectionSharedPtr
Definition: selection.h:23
HdInstancerContext instancerContext
Definition: engine.h:352
USDIMAGINGGL_API void _SetRenderDelegate(HdPluginRenderDelegateUniqueHandle &&, HdContainerDataSourceHandle const &sceneIndexInputArgs)
GLuint * ids
Definition: glcorearb.h:652
USDIMAGINGGL_API bool DecodeIntersection(unsigned char const primIdColor[4], unsigned char const instanceIdColor[4], SdfPath *outHitPrimPath=NULL, SdfPath *outHitInstancerPath=NULL, int *outHitInstanceIndex=NULL, HdInstancerContext *outInstancerContext=NULL)
Definition: value.h:89
static USDIMAGINGGL_API TfToken _GetDefaultRendererPluginId()
USDIMAGINGGL_API void SetRootVisibility(bool isVisible)
Sets the root visibility.
std::vector< class GlfSimpleLight > GlfSimpleLightVector
Definition: simpleLight.h:254
USDIMAGINGGL_API HdxTaskController * _GetTaskController() const
USDIMAGINGGL_API void SetEnablePresentation(bool enabled)
SdfPath _rootPath
Definition: engine.h:831
USDIMAGINGGL_API void SetPresentationOutput(TfToken const &api, VtValue const &framebuffer)
std::unique_ptr< class Hgi > HgiUniquePtr
Definition: hgi.h:38
HdPluginRendererUniqueHandle _renderer
Definition: engine.h:811
static USDIMAGINGGL_API SdfPathVector GetAvailableRenderSettingsPrimPaths(UsdPrim const &root)
Utility method to query available render settings prims.
GLenum src
Definition: glcorearb.h:1793
USDIMAGINGGL_API std::string GetRendererHgiDisplayName() const