capabilities.h
1 //
2 // Copyright 2021 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HGI_CAPABILITIES_H
25 #define PXR_IMAGING_HGI_CAPABILITIES_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hgi/api.h"
29 #include "pxr/imaging/hgi/enums.h"
30 
31 #include <cstddef>
32 
33 PXR_NAMESPACE_OPEN_SCOPE
34 
40 {
41 public:
42  HGI_API
43  virtual ~HgiCapabilities() = 0;
44 
45  bool IsSet(HgiDeviceCapabilities mask) const {
46  return (_flags & mask) != 0;
47  }
48 
49  HGI_API
50  virtual int GetAPIVersion() const = 0;
51 
52  HGI_API
53  virtual int GetShaderVersion() const = 0;
54 
55  HGI_API
56  size_t GetMaxUniformBlockSize() const {
57  return _maxUniformBlockSize;
58  }
59 
60  HGI_API
61  size_t GetMaxShaderStorageBlockSize() const {
62  return _maxShaderStorageBlockSize;
63  }
64 
65  HGI_API
66  size_t GetUniformBufferOffsetAlignment() const {
67  return _uniformBufferOffsetAlignment;
68  }
69 
70  HGI_API
71  size_t GetMaxClipDistances() const {
72  return _maxClipDistances;
73  }
74 
75  HGI_API
76  size_t GetPageSizeAlignment() const {
77  return _pageSizeAlignment;
78  }
79 
80 protected:
82  : _maxUniformBlockSize(0)
83  , _maxShaderStorageBlockSize(0)
84  , _uniformBufferOffsetAlignment(0)
85  , _maxClipDistances(0)
86  , _pageSizeAlignment(1)
87  , _flags(0)
88  {}
89 
90  void _SetFlag(HgiDeviceCapabilities mask, bool value) {
91  if (value) {
92  _flags |= mask;
93  } else {
94  _flags &= ~mask;
95  }
96  }
97 
98  size_t _maxUniformBlockSize;
99  size_t _maxShaderStorageBlockSize;
100  size_t _uniformBufferOffsetAlignment;
101  size_t _maxClipDistances;
102  size_t _pageSizeAlignment;
103 
104 private:
105  HgiCapabilities & operator=(const HgiCapabilities&) = delete;
106  HgiCapabilities(const HgiCapabilities&) = delete;
107 
108  HgiDeviceCapabilities _flags;
109 };
110 
111 PXR_NAMESPACE_CLOSE_SCOPE
112 
113 #endif
Reports the capabilities of the Hgi device.
Definition: capabilities.h:39