-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathGPUAdapter.h
More file actions
59 lines (42 loc) · 1.63 KB
/
Copy pathGPUAdapter.h
File metadata and controls
59 lines (42 loc) · 1.63 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
#pragma once
#include <memory>
#include <string>
#include <unordered_set>
#include "Unions.h"
#include "NativeObject.h"
#include "rnwgpu/async/AsyncTaskHandle.h"
#include "rnwgpu/async/RuntimeContext.h"
#include "webgpu/webgpu_cpp.h"
#include "GPUAdapterInfo.h"
#include "GPUDevice.h"
#include "GPUDeviceDescriptor.h"
#include "GPUSupportedLimits.h"
namespace rnwgpu {
namespace jsi = facebook::jsi;
class GPUAdapter : public NativeObject<GPUAdapter> {
public:
static constexpr const char *CLASS_NAME = "GPUAdapter";
explicit GPUAdapter(wgpu::Adapter instance,
std::shared_ptr<async::RuntimeContext> async)
: NativeObject(CLASS_NAME), _instance(instance), _async(async) {}
public:
std::string getBrand() { return CLASS_NAME; }
async::AsyncTaskHandle
requestDevice(std::optional<std::shared_ptr<GPUDeviceDescriptor>> descriptor);
std::unordered_set<std::string> getFeatures();
std::shared_ptr<GPUSupportedLimits> getLimits();
std::shared_ptr<GPUAdapterInfo> getInfo();
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
installGetter(runtime, prototype, "__brand", &GPUAdapter::getBrand);
installMethod(runtime, prototype, "requestDevice",
&GPUAdapter::requestDevice);
installGetter(runtime, prototype, "features", &GPUAdapter::getFeatures);
installGetter(runtime, prototype, "limits", &GPUAdapter::getLimits);
installGetter(runtime, prototype, "info", &GPUAdapter::getInfo);
}
inline const wgpu::Adapter get() { return _instance; }
private:
wgpu::Adapter _instance;
std::shared_ptr<async::RuntimeContext> _async;
};
} // namespace rnwgpu