HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
contextCaps.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 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_GLF_CONTEXT_CAPS_H
8 #define PXR_IMAGING_GLF_CONTEXT_CAPS_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/glf/api.h"
12 #include "pxr/base/tf/singleton.h"
13 
14 
16 
17 
18 /// \class GlfContextCaps
19 ///
20 /// This class is intended to be a cache of the capabilites
21 /// (resource limits and features) of the underlying
22 /// GL context.
23 ///
24 /// It serves two purposes. Firstly to reduce driver
25 /// transition overhead of querying these values.
26 /// Secondly to provide access to these values from other
27 /// threads that don't have the context bound.
28 ///
29 /// In the event of failure (InitInstance() wasn't called
30 /// or an issue accessing the GL context), a reasonable
31 /// set of defaults, based on GL minimums, is provided.
32 ///
33 ///
34 /// TO DO (bug #124971):
35 /// - LoadCaps() should be called whenever the context
36 /// changes.
37 /// - Provide a mechanism where other Hd systems can
38 /// subscribe to when the caps changes, so they can
39 /// update and invalidate.
40 ///
42 {
43 public:
44 
45  /// InitInstance queries the GL context for its capabilities.
46  /// It should be called by the application before using systems
47  /// that depend on the caps, such as Hydra. A good example would be
48  /// to pair the call to initialize after a call to initialize GL
49  GLF_API
50  static void InitInstance();
51 
52  /// GetInstance() returns the filled capabilities structure.
53  /// This function will not populate the caps and will issue a
54  /// coding error if it hasn't been filled.
55  GLF_API
56  static const GlfContextCaps &GetInstance();
57 
58  // GL version
59  int glVersion; // 400 (4.0), 410 (4.1), ...
60 
61  // Whether or not we are running with core profile
63 
64  // Max constants
66 
67 private:
68  void _LoadCaps();
70  ~GlfContextCaps() = default;
71 
72  // Disallow copies
73  GlfContextCaps(const GlfContextCaps&) = delete;
74  GlfContextCaps& operator=(const GlfContextCaps&) = delete;
75 
76  friend class TfSingleton<GlfContextCaps>;
77 };
78 
80 
82 
83 #endif // PXR_IMAGING_GLF_CONTEXT_CAPS_H
84 
static GLF_API const GlfContextCaps & GetInstance()
#define GLF_API
Definition: api.h:23
static GLF_API void InitInstance()
GLF_API_TEMPLATE_CLASS(TfSingleton< GlfContextCaps >)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
int maxArrayTextureLayers
Definition: contextCaps.h:65