-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathGPUAdapterInfo.h
More file actions
61 lines (46 loc) · 1.75 KB
/
GPUAdapterInfo.h
File metadata and controls
61 lines (46 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include <string>
#include <utility>
#include "Unions.h"
#include "RNFHybridObject.h"
#include "Convertors.h"
#include "webgpu/webgpu_cpp.h"
namespace rnwgpu {
namespace m = margelo;
class GPUAdapterInfo : public m::HybridObject {
public:
explicit GPUAdapterInfo(wgpu::AdapterInfo &info)
: HybridObject("GPUAdapterInfo"), _vendor(info.vendor),
_architecture(info.architecture), _device(info.device),
_description(info.description),
_isFallbackAdapter(info.adapterType == wgpu::AdapterType::CPU) {}
public:
std::string getBrand() { return _name; }
std::string getVendor() { return _vendor; }
std::string getArchitecture() { return _architecture; }
std::string getDevice() { return _device; }
std::string getDescription() { return _description; }
bool getIsFallbackAdapter() { return _isFallbackAdapter; }
void loadHybridMethods() override {
registerHybridGetter("__brand", &GPUAdapterInfo::getBrand, this);
registerHybridGetter("vendor", &GPUAdapterInfo::getVendor, this);
registerHybridGetter("architecture", &GPUAdapterInfo::getArchitecture,
this);
registerHybridGetter("device", &GPUAdapterInfo::getDevice, this);
registerHybridGetter("description", &GPUAdapterInfo::getDescription, this);
registerHybridGetter("isFallbackAdapter",
&GPUAdapterInfo::getIsFallbackAdapter, this);
}
size_t getMemoryPressure() override {
return sizeof(GPUAdapterInfo) + _vendor.capacity() +
_architecture.capacity() + _device.capacity() +
_description.capacity();
}
private:
std::string _vendor;
std::string _architecture;
std::string _device;
std::string _description;
bool _isFallbackAdapter;
};
} // namespace rnwgpu