-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathGPU.h
More file actions
62 lines (43 loc) · 1.55 KB
/
Copy pathGPU.h
File metadata and controls
62 lines (43 loc) · 1.55 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
62
#pragma once
#include <memory>
#include <string>
#include <unordered_set>
#include <variant>
#include "Unions.h"
#include "NativeObject.h"
#include "rnwgpu/async/AsyncTaskHandle.h"
#include "rnwgpu/async/RuntimeContext.h"
#include "webgpu/webgpu_cpp.h"
#include "GPUAdapter.h"
#include "GPURequestAdapterOptions.h"
#include <webgpu/webgpu.h>
namespace facebook::react {
class CallInvoker;
} // namespace facebook::react
namespace rnwgpu {
namespace jsi = facebook::jsi;
class GPU : public NativeObject<GPU> {
public:
static constexpr const char *CLASS_NAME = "GPU";
GPU(jsi::Runtime &runtime,
std::shared_ptr<facebook::react::CallInvoker> callInvoker);
public:
std::string getBrand() { return CLASS_NAME; }
async::AsyncTaskHandle requestAdapter(
std::optional<std::shared_ptr<GPURequestAdapterOptions>> options);
wgpu::TextureFormat getPreferredCanvasFormat();
std::unordered_set<std::string> getWgslLanguageFeatures();
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
installGetter(runtime, prototype, "__brand", &GPU::getBrand);
installMethod(runtime, prototype, "requestAdapter", &GPU::requestAdapter);
installMethod(runtime, prototype, "getPreferredCanvasFormat",
&GPU::getPreferredCanvasFormat);
installGetter(runtime, prototype, "wgslLanguageFeatures",
&GPU::getWgslLanguageFeatures);
}
inline const wgpu::Instance get() { return _instance; }
private:
wgpu::Instance _instance;
std::shared_ptr<async::RuntimeContext> _async;
};
} // namespace rnwgpu