HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hgiInterop.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 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_HGIINTEROP_HGIINTEROP_H
8 #define PXR_IMAGING_HGIINTEROP_HGIINTEROP_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/base/tf/token.h"
12 #include "pxr/base/gf/vec4i.h"
15 
16 #include <memory>
17 
19 
20 class Hgi;
21 class VtValue;
22 
23 struct HgiInteropImpl;
24 
25 /// \class HgiInterop
26 ///
27 /// Hydra Graphics Interface Interop.
28 ///
29 /// HgiInterop provides functionality to transfer render targets between
30 /// supported APIs as efficiently as possible.
31 ///
32 class HgiInterop final
33 {
34 public:
36  HgiInterop();
37 
39  ~HgiInterop();
40 
41  /// Composite the provided textures over the application / viewer's
42  /// framebuffer contents.
43  /// `srcHgi`:
44  /// Determines the source format/platform of the textures.
45  /// Eg. if hgi is of type HgiMetal, the textures are HgiMetalTexture.
46  /// `srcColor`: is the source color aov texture to composite to screen.
47  /// `srcDepth`: (optional) is the depth aov texture to composite to screen.
48  /// `dstApi`:
49  /// Determines what target format/platform the application is using.
50  /// E.g. If hgi==HgiMetal and dstApi==OpenGL then TransferToApp
51  /// will present the metal textures to the gl application.
52  /// `dstFramebuffer`:
53  /// The framebuffer that the source textures are presented into. This
54  /// is a VtValue that encoding a framebuffer in a dstApi specific way.
55  /// E.g., a uint32_t (aka GLuint) for framebuffer object for
56  /// dstApi==OpenGL. For backwards compatibility, the currently bound
57  /// framebuffer is used when the VtValue is empty.
58  ///
59  /// `dstRegion`:
60  /// Subrect region of the framebuffer over which to composite.
61  /// Coordinates are (left, BOTTOM, width, height) which is the same
62  /// convention as OpenGL viewport coordinates.
63  ///
64  /// Note:
65  /// To composite correctly, blending is enabled.
66  /// If `srcDepth` is provided, depth testing is enabled.
67  /// As a result, the contents of the application framebuffer matter.
68  /// In order to use the contents of `srcColor` and `srcDepth` as-is
69  /// (i.e., blit), the color attachment should be cleared to (0,0,0,0) and
70  /// the depth attachment needs to be cleared to 1.
71  ///
73  void TransferToApp(
74  Hgi *srcHgi,
75  HgiTextureHandle const &srcColor,
77  TfToken const &dstApi,
78  VtValue const &dstFramebuffer,
79  GfVec4i const &dstRegion);
80 
81 private:
82  HgiInterop & operator=(const HgiInterop&) = delete;
83  HgiInterop(const HgiInterop&) = delete;
84 
85  std::unique_ptr<HgiInteropImpl> _hgiInteropImpl;
86 };
87 
88 
90 
91 #endif
Definition: vec4i.h:43
#define HGIINTEROP_API
Definition: api.h:23
int HgiHandle< class HgiTexture > HgiTextureHandle
Definition: token.h:70
HGIINTEROP_API void TransferToApp(Hgi *srcHgi, HgiTextureHandle const &srcColor, HgiTextureHandle const &srcDepth, TfToken const &dstApi, VtValue const &dstFramebuffer, GfVec4i const &dstRegion)
GLenum GLint GLint GLint GLint GLuint GLenum GLint GLint GLint GLint GLsizei GLsizei GLsizei srcDepth
Definition: glcorearb.h:2510
Definition: hgi.h:93
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HGIINTEROP_API ~HgiInterop()
HGIINTEROP_API HgiInterop()
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: value.h:146