Skip to content

Commit e47eb4e

Browse files
committed
🔧
1 parent a4d6e42 commit e47eb4e

78 files changed

Lines changed: 266 additions & 519 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/webgpu/android/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ add_library(${PACKAGE_NAME} SHARED
4444
../cpp/rnwgpu/api/GPUComputePipeline.cpp
4545
../cpp/rnwgpu/api/GPUCanvasContext.cpp
4646
../cpp/rnwgpu/RNWebGPUManager.cpp
47-
../cpp/jsi/RNFPromise.cpp
48-
../cpp/jsi/RNFRuntimeState.cpp
47+
../cpp/jsi/Promise.cpp
4948
../cpp/rnwgpu/async/AsyncRunner.cpp
5049
../cpp/rnwgpu/async/AsyncTaskHandle.cpp
5150
../cpp/rnwgpu/async/JSIMicrotaskDispatcher.cpp
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
//
2-
// Created by Marc Rousavy on 22.02.24.
3-
//
4-
51
#pragma once
62

73
#include <stdexcept>
84
#include <string>
95

10-
namespace margelo {
6+
namespace rnwgpu {
117

128
namespace EnumMapper {
139
// Add these two methods in namespace "EnumMapper" to allow parsing a custom enum:
@@ -46,4 +42,4 @@ namespace EnumMapper {
4642
}
4743
} // namespace EnumMapper
4844

49-
} // namespace margelo
45+
} // namespace rnwgpu
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by Marc Rousavy on 21.02.24.
3-
//
4-
51
#pragma once
62

73
#include <memory>
@@ -16,8 +12,8 @@
1612

1713
#include <jsi/jsi.h>
1814

19-
#include "RNFEnumMapper.h"
20-
#include "RNFPromise.h"
15+
#include "EnumMapper.h"
16+
#include "Promise.h"
2117

2218
#include "Unions.h"
2319

@@ -30,7 +26,7 @@
3026
#include <cxxabi.h>
3127
#endif
3228

33-
namespace margelo {
29+
namespace rnwgpu {
3430

3531
namespace jsi = facebook::jsi;
3632

@@ -208,8 +204,8 @@ template <> struct JSIConverter<rnwgpu::async::AsyncTaskHandle> {
208204
}
209205

210206
static jsi::Value toJSI(jsi::Runtime& runtime, rnwgpu::async::AsyncTaskHandle&& handle) {
211-
return Promise::createPromise(runtime, [handle = std::move(handle)](jsi::Runtime& runtime,
212-
std::shared_ptr<Promise> promise) mutable {
207+
return rnwgpu::Promise::createPromise(runtime, [handle = std::move(handle)](jsi::Runtime& runtime,
208+
std::shared_ptr<rnwgpu::Promise> promise) mutable {
213209
if (!handle.valid()) {
214210
promise->resolve(jsi::Value::undefined());
215211
return;
@@ -466,4 +462,4 @@ struct JSIConverter<std::unordered_set<std::string>> {
466462
}
467463
};
468464

469-
} // namespace margelo
465+
} // namespace rnwgpu

packages/webgpu/cpp/jsi/NativeObject.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
#include "WGPULogger.h"
1818

1919
// Forward declare to avoid circular dependency
20-
namespace margelo {
20+
namespace rnwgpu {
2121
template <typename ArgType, typename SFINAE> struct JSIConverter;
22-
} // namespace margelo
22+
} // namespace rnwgpu
2323

2424
// Include the converter - must come after forward declaration
25-
#include "RNFJSIConverter.h"
25+
#include "JSIConverter.h"
2626

2727
namespace rnwgpu {
2828

@@ -272,7 +272,7 @@ class NativeObject : public jsi::NativeState,
272272
return jsi::Value::undefined();
273273
} else {
274274
ReturnType result = (native.get()->*getter)();
275-
return margelo::JSIConverter<std::decay_t<ReturnType>>::toJSI(
275+
return rnwgpu::JSIConverter<std::decay_t<ReturnType>>::toJSI(
276276
rt, std::move(result));
277277
}
278278
});
@@ -305,7 +305,7 @@ class NativeObject : public jsi::NativeState,
305305
const jsi::Value *args, size_t count) -> jsi::Value {
306306
auto native = Derived::fromValue(rt, thisVal);
307307
auto value =
308-
margelo::JSIConverter<std::decay_t<ValueType>>::fromJSI(rt, args[0], false);
308+
rnwgpu::JSIConverter<std::decay_t<ValueType>>::fromJSI(rt, args[0], false);
309309
(native.get()->*setter)(std::move(value));
310310
return jsi::Value::undefined();
311311
});
@@ -352,7 +352,7 @@ class NativeObject : public jsi::NativeState,
352352
const jsi::Value *args, size_t count) -> jsi::Value {
353353
auto native = Derived::fromValue(rt, thisVal);
354354
ReturnType result = (native.get()->*getter)();
355-
return margelo::JSIConverter<std::decay_t<ReturnType>>::toJSI(rt,
355+
return rnwgpu::JSIConverter<std::decay_t<ReturnType>>::toJSI(rt,
356356
std::move(result));
357357
});
358358

@@ -363,7 +363,7 @@ class NativeObject : public jsi::NativeState,
363363
const jsi::Value *args, size_t count) -> jsi::Value {
364364
auto native = Derived::fromValue(rt, thisVal);
365365
auto value =
366-
margelo::JSIConverter<std::decay_t<ValueType>>::fromJSI(rt, args[0], false);
366+
rnwgpu::JSIConverter<std::decay_t<ValueType>>::fromJSI(rt, args[0], false);
367367
(native.get()->*setter)(std::move(value));
368368
return jsi::Value::undefined();
369369
});
@@ -390,17 +390,17 @@ class NativeObject : public jsi::NativeState,
390390
jsi::Runtime &runtime, const jsi::Value *args,
391391
std::index_sequence<Is...>, size_t count) {
392392
if constexpr (std::is_same_v<ReturnType, void>) {
393-
(obj->*method)(margelo::JSIConverter<std::decay_t<Args>>::fromJSI(
393+
(obj->*method)(rnwgpu::JSIConverter<std::decay_t<Args>>::fromJSI(
394394
runtime, args[Is], Is >= count)...);
395395
return jsi::Value::undefined();
396396
} else if constexpr (std::is_same_v<ReturnType, jsi::Value>) {
397397
// Special case: if return type is jsi::Value, method has full control
398398
// This requires the method signature to match HostFunction
399399
return (obj->*method)(runtime, jsi::Value::undefined(), args, count);
400400
} else {
401-
ReturnType result = (obj->*method)(margelo::JSIConverter<std::decay_t<Args>>::fromJSI(
401+
ReturnType result = (obj->*method)(rnwgpu::JSIConverter<std::decay_t<Args>>::fromJSI(
402402
runtime, args[Is], Is >= count)...);
403-
return margelo::JSIConverter<std::decay_t<ReturnType>>::toJSI(runtime,
403+
return rnwgpu::JSIConverter<std::decay_t<ReturnType>>::toJSI(runtime,
404404
std::move(result));
405405
}
406406
}
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
//
2-
// Created by Marc Rousavy on 22.02.24.
3-
//
4-
#include "RNFPromise.h"
1+
#include "Promise.h"
52
#include <future>
63
#include <jsi/jsi.h>
74
#include <memory>
85
#include <string>
96
#include <utility>
107
#include <vector>
118

12-
namespace margelo {
9+
namespace rnwgpu {
1310

1411
namespace jsi = facebook::jsi;
1512

@@ -44,4 +41,4 @@ void Promise::reject(std::string message) {
4441
_rejecter.call(runtime, error.value());
4542
}
4643

47-
} // namespace margelo
44+
} // namespace rnwgpu
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//
2-
// Created by Marc Rousavy on 22.02.24.
3-
//
41
#pragma once
52

63
#include <jsi/jsi.h>
@@ -9,7 +6,7 @@
96
#include <string>
107
#include <memory>
118

12-
namespace margelo {
9+
namespace rnwgpu {
1310

1411
namespace jsi = facebook::jsi;
1512

@@ -35,4 +32,4 @@ class Promise {
3532
static jsi::Value createPromise(jsi::Runtime& runtime, RunPromise run);
3633
};
3734

38-
} // namespace margelo
35+
} // namespace rnwgpu

packages/webgpu/cpp/jsi/RNFRuntimeState.cpp

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/webgpu/cpp/jsi/RNFRuntimeState.h

Lines changed: 0 additions & 130 deletions
This file was deleted.

packages/webgpu/cpp/rnwgpu/ArrayBuffer.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <memory>
55

6-
#include "RNFJSIConverter.h"
6+
#include "JSIConverter.h"
77

88
namespace rnwgpu {
99

@@ -24,21 +24,17 @@ struct ArrayBuffer : jsi::MutableBuffer {
2424
size_t _bytesPerElement;
2525
};
2626

27-
} // namespace rnwgpu
28-
29-
namespace margelo {
30-
31-
static std::shared_ptr<rnwgpu::ArrayBuffer>
27+
static std::shared_ptr<ArrayBuffer>
3228
createArrayBufferFromJSI(jsi::Runtime &runtime,
3329
const jsi::ArrayBuffer &arrayBuffer,
3430
size_t bytesPerElement) {
3531
auto size = arrayBuffer.size(runtime);
36-
return std::make_shared<rnwgpu::ArrayBuffer>(arrayBuffer.data(runtime), size,
37-
bytesPerElement);
32+
return std::make_shared<ArrayBuffer>(arrayBuffer.data(runtime), size,
33+
bytesPerElement);
3834
}
3935

40-
template <> struct JSIConverter<std::shared_ptr<rnwgpu::ArrayBuffer>> {
41-
static std::shared_ptr<rnwgpu::ArrayBuffer>
36+
template <> struct JSIConverter<std::shared_ptr<ArrayBuffer>> {
37+
static std::shared_ptr<ArrayBuffer>
4238
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBound) {
4339
if (arg.isObject()) {
4440
auto obj = arg.getObject(runtime);
@@ -64,9 +60,9 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::ArrayBuffer>> {
6460
}
6561

6662
static jsi::Value toJSI(jsi::Runtime &runtime,
67-
std::shared_ptr<rnwgpu::ArrayBuffer> arg) {
63+
std::shared_ptr<ArrayBuffer> arg) {
6864
return jsi::ArrayBuffer(runtime, arg);
6965
}
7066
};
7167

72-
} // namespace margelo
68+
} // namespace rnwgpu

0 commit comments

Comments
 (0)