27 #ifndef PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H
28 #define PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H
31 #include "pxr/usdImaging/usdImagingGL/api.h"
32 #include "pxr/usdImaging/usdImagingGL/version.h"
33 #include "pxr/usdImaging/usdImaging/version.h"
36 #include "pxr/usdImaging/usdImagingGL/rendererSettings.h"
38 #include "pxr/imaging/cameraUtil/conformWindow.h"
40 #include "pxr/imaging/hd/driver.h"
41 #include "pxr/imaging/hd/engine.h"
42 #include "pxr/imaging/hd/rprimCollection.h"
43 #include "pxr/imaging/hd/pluginRenderDelegateUniqueHandle.h"
45 #include "pxr/imaging/hdx/selectionTracker.h"
46 #include "pxr/imaging/hdx/renderSetupTask.h"
48 #include "pxr/imaging/hgi/hgi.h"
53 #include "pxr/imaging/hgi/hgi.h"
55 #include "pxr/usd/sdf/path.h"
56 #include "pxr/usd/usd/timeCode.h"
68 PXR_NAMESPACE_OPEN_SCOPE
72 class HdxTaskController;
74 class UsdImagingGLLegacyEngine;
110 const SdfPathVector& excludedPaths,
111 const SdfPathVector& invisedPaths=SdfPathVector(),
112 const SdfPath& sceneDelegateID =
118 UsdImagingGLEngine& operator=(
const UsdImagingGLEngine&) =
delete;
121 ~UsdImagingGLEngine();
135 void RenderBatch(
const SdfPathVector& paths,
192 const std::pair<bool, CameraUtilConformWindowPolicy> &policy);
249 GlfSimpleMaterial
const &material,
312 SdfPath *outHitPrimPath = NULL,
313 SdfPath *outHitInstancerPath = NULL,
314 int *outHitInstanceIndex = NULL,
315 HdInstancerContext *outInstancerContext = NULL);
321 unsigned char const primIdColor[4],
322 unsigned char const instanceIdColor[4],
323 SdfPath *outHitPrimPath = NULL,
324 SdfPath *outHitInstancerPath = NULL,
325 int *outHitInstanceIndex = NULL,
326 HdInstancerContext *outInstancerContext = NULL);
506 friend class UsdImagingGL_UnitTestGLDrawing;
515 HdTaskSharedPtrVector tasks);
518 bool _CanPrepare(
const UsdPrim& root);
531 SdfPathVector
const& roots,
541 void _InitializeHgiIfNecessary();
544 void _SetRenderDelegateAndRestoreState(
554 static TfToken _GetDefaultRendererPluginId();
563 HdxTaskController *_GetTaskController()
const;
566 bool _IsUsingLegacyImpl()
const;
569 HdSelectionSharedPtr _GetSelection()
const;
586 std::unique_ptr<HdRenderIndex> _renderIndex;
588 SdfPath const _sceneDelegateId;
590 std::unique_ptr<HdxTaskController> _taskController;
592 HdxSelectionTrackerSharedPtr _selTracker;
596 GlfSimpleLightingContextRefPtr _lightingContextForOpenGLState;
602 SdfPathVector _excludedPrimPaths;
603 SdfPathVector _invisedPrimPaths;
611 std::unique_ptr<UsdImagingGLLegacyEngine> _legacyImpl;
614 void _DestroyHydraObjects();
616 std::unique_ptr<UsdImagingDelegate> _sceneDelegate;
617 std::unique_ptr<HdEngine> _engine;
621 PXR_NAMESPACE_CLOSE_SCOPE
623 #endif // PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H
static USDIMAGINGGL_API bool IsHydraEnabled()
Returns true if Hydra is enabled for GL drawing.
USDIMAGINGGL_API void SetColorCorrectionSettings(TfToken const &id)
Set id to one of the HdxColorCorrectionTokens.
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
USDIMAGINGGL_API HgiTextureHandle GetAovTexture(TfToken const &name) const
Returns an AOV texture handle for the given token.
static USDIMAGINGGL_API bool IsColorCorrectionCapable()
Returns true if the platform is color correction capable.
A (movable) handle for a render delegate that was created using a a plugin.
USDIMAGINGGL_API void SetRendererSetting(TfToken const &id, VtValue const &value)
Sets a renderer setting's value.
Basic type for a vector of 2 int components.
Standard pointer typedefs.
USDIMAGINGGL_API void SetCameraPath(SdfPath const &id)
Scene camera API Set the scene camera path to use for rendering.
USDIMAGINGGL_API bool IsPauseRendererSupported() const
Query the renderer as to whether it supports pausing and resuming.
USDIMAGINGGL_API HdRenderIndex * _GetRenderIndex() const
Returns the render index of the engine, if any.
A map with string keys and VtValue values.
static USDIMAGINGGL_API TfTokenVector GetRendererPlugins()
Return the vector of available render-graph delegate plugins.
USDIMAGINGGL_API Hgi * GetHgi()
Returns the HGI interface.
Basic type for a vector of 4 double components.
USDIMAGINGGL_API bool RestartRenderer()
Restart the renderer.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
USDIMAGINGGL_API void SetPresentationOutput(TfToken const &api, VtValue const &framebuffer)
The destination API (e.g., OpenGL, see hgiInterop for details) and framebuffer that the AOVs are pres...
USDIMAGINGGL_API VtDictionary GetRenderStats() const
Returns render statistics.
USDIMAGINGGL_API UsdImagingGLRendererSettingsList GetRendererSettingsList() const
Returns the list of renderer settings.
USDIMAGINGGL_API void SetFraming(CameraUtilFraming const &framing)
Determines how the filmback of the camera is mapped into the pixels of the render buffer and what pix...
USDIMAGINGGL_API bool StopRenderer()
Stop the renderer.
Token for efficient comparison, assignment, and hashing of known strings.
USDIMAGINGGL_API void SetRenderViewport(GfVec4d const &viewport)
Set the viewport to use for rendering as (x,y,w,h), where (x,y) represents the lower left corner of t...
USDIMAGINGGL_API void SetWindowPolicy(CameraUtilConformWindowPolicy policy)
Set the window policy to use.
HdDriver represents a device object, commonly a render device, that is owned by the application and p...
RenderTask parameters (renderpass state).
USDIMAGINGGL_API void SetRenderBufferSize(GfVec2i const &size)
Set the size of the render buffers baking the AOVs.
USDIMAGINGGL_API void SetSelected(SdfPathVector const &paths)
Sets (replaces) the list of prim paths that should be included in selection highlighting.
Stores a 4x4 matrix of double elements.
The application-facing entry point top-level entry point for accessing Hydra.
USDIMAGINGGL_API void SetCameraState(const GfMatrix4d &viewMatrix, const GfMatrix4d &projectionMatrix)
Free camera API Set camera framing state directly (without pointing to a camera on the USD stage)...
USDIMAGINGGL_API HdCommandDescriptors GetRendererCommandDescriptors() const
Return command deescriptors for commands supported by the active render delegate. ...
USDIMAGINGGL_API bool IsConverged() const
Returns true if the resulting image is fully converged.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
std::vector< TfToken > TfTokenVector
Convenience types.
A named, semantic collection of objects.
USDIMAGINGGL_API bool TestIntersection(const GfMatrix4d &viewMatrix, const GfMatrix4d &projectionMatrix, const UsdPrim &root, const UsdImagingGLRenderParams ¶ms, GfVec3d *outHitPoint, GfVec3d *outHitNormal, SdfPath *outHitPrimPath=NULL, SdfPath *outHitInstancerPath=NULL, int *outHitInstanceIndex=NULL, HdInstancerContext *outInstancerContext=NULL)
Finds closest point of intersection with a frustum by rendering.
A path value used to locate objects in layers or scenegraphs.
USDIMAGINGGL_API void SetLightingStateFromOpenGL()
Helper function to extract lighting state from opengl and then call SetLights.
USDIMAGINGGL_API void PrepareBatch(const UsdPrim &root, const UsdImagingGLRenderParams ¶ms)
Support for batched drawing.
USDIMAGINGGL_API bool ResumeRenderer()
Resume the renderer.
USDIMAGINGGL_API void SetOverrideWindowPolicy(const std::pair< bool, CameraUtilConformWindowPolicy > &policy)
Specifies whether to force a window policy when conforming the frustum of the camera to match the dis...
Basic type for a vector of 4 float components.
USDIMAGINGGL_API UsdImagingGLEngine(const HdDriver &driver=HdDriver())
A HdDriver, containing the Hgi of your choice, can be optionally passed in during construction...
Hydra Graphics Interface.
USDIMAGINGGL_API void SetCameraStateFromOpenGL()
Helper function to extract camera and viewport state from opengl and then call SetCameraState and Set...
Used as an arguments class for various methods in UsdImagingGLEngine.
USDIMAGINGGL_API void AddSelected(SdfPath const &path, int instanceIndex)
Add a path with instanceIndex to the list of prim paths that should be included in selection highligh...
USDIMAGINGGL_API TfTokenVector GetRendererAovs() const
Return the vector of available renderer AOV settings.
static SDF_API const SdfPath & AbsoluteRootPath()
The absolute path representing the top of the namespace hierarchy.
USDIMAGINGGL_API bool PauseRenderer()
Pause the renderer.
USDIMAGINGGL_API TfToken GetCurrentRendererId() const
Return the id of the currently used renderer plugin.
Basic type for a vector of 3 double components.
USDIMAGINGGL_API void SetSelectionColor(GfVec4f const &color)
Sets the selection highlighting color.
USDIMAGINGGL_API void ClearSelected()
Clear the list of prim paths that should be included in selection highlighting.
USDIMAGINGGL_API void SetRootVisibility(bool isVisible)
Sets the root visibility.
static USDIMAGINGGL_API std::string GetRendererDisplayName(TfToken const &id)
Return the user-friendly description of a renderer plugin.
USDIMAGINGGL_API void SetEnablePresentation(bool enabled)
Enable / disable presenting the render to bound framebuffer.
USDIMAGINGGL_API bool SetRendererAov(TfToken const &id)
Set the current renderer AOV to id.
The UsdImagingGLEngine is the main entry point API for rendering USD scenes.
USDIMAGINGGL_API void SetLightingState(GlfSimpleLightingContextPtr const &src)
Copy lighting state from another lighting context.
USDIMAGINGGL_API void Render(const UsdPrim &root, const UsdImagingGLRenderParams ¶ms)
Entry point for kicking off a render.
USDIMAGINGGL_API bool InvokeRendererCommand(const TfToken &command, const HdCommandArgs &args=HdCommandArgs()) const
Invokes command on the active render delegate.
USDIMAGINGGL_API bool IsStopRendererSupported() const
Query the renderer as to whether it supports stopping and restarting.
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
USDIMAGINGGL_API VtValue GetRendererSetting(TfToken const &id) const
Gets a renderer setting's current value.
USDIMAGINGGL_API void SetRootTransform(GfMatrix4d const &xf)
Sets the root transform.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
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)
Decodes a pick result given hydra prim ID/instance ID (like you'd get from an ID render).
USDIMAGINGGL_API bool SetRendererPlugin(TfToken const &id)
Set the current render-graph delegate to id.