HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
device.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_HGIGL_DEVICE_H
8 #define PXR_IMAGING_HGIGL_DEVICE_H
9 
10 #include "pxr/pxr.h"
12 #include "pxr/imaging/hgiGL/api.h"
14 #include "pxr/imaging/hgiGL/hgi.h"
15 
16 #include <fstream>
17 #include <ostream>
18 
20 
21 class HgiGraphicsCmdDesc;
22 
23 /// \class HgiGLDevice
24 ///
25 /// OpenGL implementation of GPU device.
26 /// Note: HgiGL does not concern itself with GL context management.
27 /// See notes in hgiGL/hgi.h
28 ///
29 class HgiGLDevice final {
30 public:
31  HGIGL_API
32  HgiGLDevice();
33 
34  HGIGL_API
35  ~HgiGLDevice();
36 
37  /// Execute the provided functions / ops. This will emit the GL calls.
38  HGIGL_API
39  void SubmitOps(HgiGLOpsVector const& ops);
40 
41  /// Sets the active arena to use when submitting commands. This is used
42  /// for management of resources tied to a GL context such as FBOs.
43  /// The default arena is used if a valid handle isn't provided.
44  HGIGL_API
45  void SetCurrentArena(HgiGLContextArenaHandle const& arenaHandle);
46 
47  /// Returns a framebuffer object id that is managed by the active arena.
48  HGIGL_API
49  uint32_t AcquireFramebuffer(
50  HgiGraphicsCmdsDesc const& desc,
51  bool resolved = false);
52 
53  /// Garbage collect resources in the active arena.
54  HGIGL_API
55  void GarbageCollect();
56 
57 private:
58  HgiGLContextArena const * _GetArena() const;
59  HgiGLContextArena * _GetArena();
60 
61  HgiGLDevice & operator=(const HgiGLDevice&) = delete;
62  HgiGLDevice(const HgiGLDevice&) = delete;
63 
64  friend std::ofstream& operator<<(
65  std::ofstream& out,
66  const HgiGLDevice& dev);
67 
68  // The default arena is used in the absence of a user provided arena.
69  HgiGLContextArena _defaultArena;
70  HgiGLContextArena *_activeArena;
71 };
72 
73 
75 
76 #endif
HGIGL_API void SubmitOps(HgiGLOpsVector const &ops)
Execute the provided functions / ops. This will emit the GL calls.
std::ofstream ofstream
Definition: filesystem.h:58
friend std::ofstream & operator<<(std::ofstream &out, const HgiGLDevice &dev)
HGIGL_API HgiGLDevice()
HGIGL_API uint32_t AcquireFramebuffer(HgiGraphicsCmdsDesc const &desc, bool resolved=false)
Returns a framebuffer object id that is managed by the active arena.
#define HGIGL_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HGIGL_API ~HgiGLDevice()
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
std::vector< HgiGLOpsFn > HgiGLOpsVector
Definition: hgi.h:26
HGIGL_API void GarbageCollect()
Garbage collect resources in the active arena.
HGIGL_API void SetCurrentArena(HgiGLContextArenaHandle const &arenaHandle)