|
3 | 3 | #include <memory> |
4 | 4 | #include <vector> |
5 | 5 | #include <unordered_set> |
| 6 | +#include <common/utility.hpp> |
6 | 7 | #include <common/command_buffers/gpu/gpu_adapter.hpp> |
7 | 8 | #include <common/command_buffers/gpu/gpu_device.hpp> |
8 | 9 |
|
9 | 10 | namespace commandbuffers |
10 | 11 | { |
| 12 | + namespace gpu |
| 13 | + { |
| 14 | + class BackendConnection; |
| 15 | + } |
| 16 | + |
11 | 17 | struct GPUInstanceDescriptor |
12 | 18 | { |
13 | 19 | size_t requiredFeatureCount = 0; |
14 | 20 | GPUFeatureName const *requiredFeatures = nullptr; |
15 | 21 | GPUSupportedLimits *requiredLimits = nullptr; |
16 | 22 | }; |
17 | 23 |
|
18 | | - class GPUInstanceBase |
| 24 | + class GPUInstance final |
19 | 25 | { |
20 | | - private: |
21 | | - // Custom deleter for `unique_ptr<GPUInstanceBase>` |
22 | | - struct Deleter |
23 | | - { |
24 | | - void operator()(GPUInstanceBase *ptr) |
25 | | - { |
26 | | - delete ptr; |
27 | | - } |
28 | | - }; |
29 | | - |
30 | 26 | public: |
31 | | - static std::unique_ptr<GPUInstanceBase, Deleter> Create(const GPUInstanceDescriptor *descriptor = nullptr); |
| 27 | + static Ref<GPUInstance> Create(const GPUInstanceDescriptor *descriptor = nullptr); |
| 28 | + |
| 29 | + void registerBackend(gpu::BackendConnection *backend); |
32 | 30 |
|
33 | | - void addDevice(std::shared_ptr<GPUDeviceBase>); |
34 | | - void removeDevice(std::shared_ptr<GPUDeviceBase>); |
| 31 | + void addDevice(Ref<GPUDeviceBase>); |
| 32 | + void removeDevice(Ref<GPUDeviceBase>); |
35 | 33 |
|
36 | 34 | bool hasFeature(GPUFeatureName feature) const; |
37 | 35 |
|
38 | 36 | private: |
39 | | - explicit GPUInstanceBase(); |
40 | | - virtual ~GPUInstanceBase() = default; |
| 37 | + explicit GPUInstance(); |
| 38 | + virtual ~GPUInstance() = default; |
41 | 39 |
|
42 | 40 | void initialize(const GPUInstanceDescriptor &descriptor); |
43 | | - std::shared_ptr<GPUAdapterBase> createAdapter(); |
| 41 | + Ref<GPUAdapterBase> createAdapter(Ref<GPUPhysicalDeviceBase> physicalDevice, |
| 42 | + GPUFeatureLevel featureLevel, |
| 43 | + GPUPowerPreference powerPreference); |
| 44 | + |
| 45 | + gpu::BackendConnection *getBackendConnection() const; |
44 | 46 |
|
45 | 47 | private: |
46 | 48 | std::unordered_set<GPUFeatureName> instance_features_; |
47 | 49 | std::vector<std::shared_ptr<GPUDeviceBase>> devices_list_; |
| 50 | + Ref<gpu::BackendConnection> backend_ = nullptr; |
48 | 51 | }; |
49 | 52 | } |
0 commit comments