-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathGPUError.h
More file actions
45 lines (33 loc) · 1.03 KB
/
Copy pathGPUError.h
File metadata and controls
45 lines (33 loc) · 1.03 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
#pragma once
#include <memory>
#include <utility>
#include <string>
#include "webgpu/webgpu_cpp.h"
#include "RNFEnumMapper.h"
#include "RNFJSIConverter.h"
namespace rnwgpu {
class GPUError {
public:
GPUError(wgpu::ErrorType aType, std::string aMessage)
: type(aType), message(std::move(aMessage)) {}
wgpu::ErrorType type;
std::string message;
};
} // namespace rnwgpu
namespace margelo {
using namespace rnwgpu; // NOLINT(build/namespaces)
template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUError>> {
static std::shared_ptr<rnwgpu::GPUBindGroupEntry>
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
throw std::runtime_error("Invalid GPUBindGroupEntry::fromJSI()");
}
static jsi::Value toJSI(jsi::Runtime &runtime,
std::shared_ptr<rnwgpu::GPUError> arg) {
jsi::Object result(runtime);
result.setProperty(
runtime, "message",
jsi::String::createFromUtf8(runtime, arg->message.c_str()));
return result;
}
};
} // namespace margelo