use render thread method for creating grid overlay & reinstate overlay tests

This commit is contained in:
Nick Fisher
2025-06-27 13:34:01 +08:00
parent 1bbf9d26ac
commit feeb757a10
6 changed files with 82 additions and 14 deletions

View File

@@ -23,10 +23,10 @@ jobs:
test/geometry_tests.dart \
test/view_tests.dart \
test/postprocessing_tests.dart \
test/scene_tests.dart
test/picking_tests.dart
test/scene_tests.dart \
test/picking_tests.dart \
test/overlay_tests.dart \
--concurrency=1
# test/overlay_tests.dart
- name: Zip output
run: zip -r output.zip ./thermion_dart/test/output
- name: Upload test output

View File

@@ -1390,6 +1390,15 @@ external void RenderTicker_setRenderable(
int numViews,
);
@ffi.Native<
ffi.Void Function(ffi.Pointer<TRenderTicker>, ffi.Pointer<TView>,
ffi.Pointer<TMaterialInstance>)>(isLeaf: true)
external void RenderTicker_foo(
ffi.Pointer<TRenderTicker> tRenderTicker,
ffi.Pointer<TView> tOverlayView,
ffi.Pointer<TMaterialInstance> tMaterialInstance,
);
@ffi.Native<
ffi.Pointer<TEngine> Function(ffi.UnsignedInt, ffi.Pointer<ffi.Void>,
ffi.Pointer<ffi.Void>, ffi.Uint8, ffi.Bool)>(isLeaf: true)
@@ -2216,6 +2225,21 @@ external void View_setCameraRenderThread(
VoidCallback onComplete,
);
@ffi.Native<
ffi.Void Function(
ffi.Pointer<TEngine>,
ffi.Pointer<TMaterial>,
ffi.Pointer<
ffi
.NativeFunction<ffi.Void Function(ffi.Pointer<TSceneAsset>)>>)>(
isLeaf: true)
external void SceneAsset_createGridRenderThread(
ffi.Pointer<TEngine> tEngine,
ffi.Pointer<TMaterial> tMaterial,
ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<TSceneAsset>)>>
callback,
);
@ffi.Native<
ffi.Void Function(
ffi.Pointer<TSceneAsset>, ffi.Uint32, VoidCallback)>(isLeaf: true)

View File

@@ -1181,6 +1181,11 @@ extension type NativeLibrary(JSObject _) implements JSObject {
Pointer<self.PointerClass<TView>> views,
int numViews,
);
external void _RenderTicker_foo(
Pointer<TRenderTicker> tRenderTicker,
Pointer<TView> tOverlayView,
Pointer<TMaterialInstance> tMaterialInstance,
);
external Pointer<TEngine> _Engine_create(
int backend,
Pointer<Void> platform,
@@ -1605,6 +1610,12 @@ extension type NativeLibrary(JSObject _) implements JSObject {
int requestId,
VoidCallback onComplete,
);
external void _SceneAsset_createGridRenderThread(
Pointer<TEngine> tEngine,
Pointer<TMaterial> tMaterial,
Pointer<self.NativeFunction<void Function(PointerClass<TSceneAsset>)>>
callback,
);
external void _SceneAsset_destroyRenderThread(
Pointer<TSceneAsset> tSceneAsset,
int requestId,
@@ -3886,6 +3897,16 @@ void RenderTicker_setRenderable(
return result;
}
void RenderTicker_foo(
self.Pointer<TRenderTicker> tRenderTicker,
self.Pointer<TView> tOverlayView,
self.Pointer<TMaterialInstance> tMaterialInstance,
) {
final result = _lib._RenderTicker_foo(
tRenderTicker.cast(), tOverlayView.cast(), tMaterialInstance.cast());
return result;
}
self.Pointer<TEngine> Engine_create(
int backend,
self.Pointer<Void> platform,
@@ -4787,6 +4808,17 @@ void View_setCameraRenderThread(
return result;
}
void SceneAsset_createGridRenderThread(
self.Pointer<TEngine> tEngine,
self.Pointer<TMaterial> tMaterial,
self.Pointer<self.NativeFunction<void Function(Pointer<TSceneAsset>)>>
callback,
) {
final result = _lib._SceneAsset_createGridRenderThread(
tEngine.cast(), tMaterial.cast(), callback.cast());
return result;
}
void SceneAsset_destroyRenderThread(
self.Pointer<TSceneAsset> tSceneAsset,
int requestId,
@@ -7560,7 +7592,7 @@ extension NativeFunctionPointer20<T extends NativeType> on void Function(
}
}
extension NativeFunctionPointer26<T extends NativeType> on void Function(
extension NativeFunctionPointer27<T extends NativeType> on void Function(
self.Pointer<TLinearImage>) {
// orignal type void Function(self.Pointer<TLinearImage> ) void Function(Pointer<TLinearImage> ) dart type void Function(self.Pointer<TLinearImage> )
@@ -7573,7 +7605,7 @@ extension NativeFunctionPointer26<T extends NativeType> on void Function(
}
}
extension NativeFunctionPointer28<T extends NativeType> on void Function(
extension NativeFunctionPointer29<T extends NativeType> on void Function(
self.Pointer<Float32>) {
// orignal type void Function(self.Pointer<Float32> ) void Function(Pointer<Float32> ) dart type void Function(self.Pointer<Float32> )
@@ -7584,7 +7616,7 @@ extension NativeFunctionPointer28<T extends NativeType> on void Function(
}
}
extension NativeFunctionPointer29<T extends NativeType> on void Function(int) {
extension NativeFunctionPointer30<T extends NativeType> on void Function(int) {
// orignal type void Function(int ) void Function(int ) dart type void Function(int )
Pointer<NativeFunction<void Function(int)>> addFunction() {
@@ -7594,7 +7626,7 @@ extension NativeFunctionPointer29<T extends NativeType> on void Function(int) {
}
}
extension NativeFunctionPointer35<T extends NativeType> on void Function(
extension NativeFunctionPointer36<T extends NativeType> on void Function(
self.Pointer<TRenderTarget>) {
// orignal type void Function(self.Pointer<TRenderTarget> ) void Function(Pointer<TRenderTarget> ) dart type void Function(self.Pointer<TRenderTarget> )
@@ -7607,7 +7639,7 @@ extension NativeFunctionPointer35<T extends NativeType> on void Function(
}
}
extension NativeFunctionPointer36<T extends NativeType> on void Function(
extension NativeFunctionPointer37<T extends NativeType> on void Function(
self.Pointer<TTextureSampler>) {
// orignal type void Function(self.Pointer<TTextureSampler> ) void Function(Pointer<TTextureSampler> ) dart type void Function(self.Pointer<TTextureSampler> )
@@ -7621,7 +7653,7 @@ extension NativeFunctionPointer36<T extends NativeType> on void Function(
}
}
extension NativeFunctionPointer40<T extends NativeType> on void Function(
extension NativeFunctionPointer41<T extends NativeType> on void Function(
self.Pointer<TGltfAssetLoader>) {
// orignal type void Function(self.Pointer<TGltfAssetLoader> ) void Function(Pointer<TGltfAssetLoader> ) dart type void Function(self.Pointer<TGltfAssetLoader> )
@@ -7635,7 +7667,7 @@ extension NativeFunctionPointer40<T extends NativeType> on void Function(
}
}
extension NativeFunctionPointer41<T extends NativeType> on void Function(
extension NativeFunctionPointer42<T extends NativeType> on void Function(
self.Pointer<TGltfResourceLoader>) {
// orignal type void Function(self.Pointer<TGltfResourceLoader> ) void Function(Pointer<TGltfResourceLoader> ) dart type void Function(self.Pointer<TGltfResourceLoader> )
@@ -7650,7 +7682,7 @@ extension NativeFunctionPointer41<T extends NativeType> on void Function(
}
}
extension NativeFunctionPointer44<T extends NativeType> on void Function(
extension NativeFunctionPointer45<T extends NativeType> on void Function(
double) {
// orignal type void Function(double ) void Function(double ) dart type void Function(double )
@@ -7661,7 +7693,7 @@ extension NativeFunctionPointer44<T extends NativeType> on void Function(
}
}
extension NativeFunctionPointer45<T extends NativeType> on void Function(
extension NativeFunctionPointer46<T extends NativeType> on void Function(
self.Pointer<TFilamentAsset>) {
// orignal type void Function(self.Pointer<TFilamentAsset> ) void Function(Pointer<TFilamentAsset> ) dart type void Function(self.Pointer<TFilamentAsset> )
@@ -7674,7 +7706,7 @@ extension NativeFunctionPointer45<T extends NativeType> on void Function(
}
}
extension NativeFunctionPointer46<T extends NativeType> on void Function(
extension NativeFunctionPointer47<T extends NativeType> on void Function(
self.Pointer<TGizmo>) {
// orignal type void Function(self.Pointer<TGizmo> ) void Function(Pointer<TGizmo> ) dart type void Function(self.Pointer<TGizmo> )

View File

@@ -8,7 +8,7 @@ class GridOverlay extends FFIAsset {
static Future<GridOverlay> create(FFIFilamentApp app, Pointer<TAnimationManager> animationManager) async {
final gridMaterial = await app.gridMaterial;
final asset = SceneAsset_createGrid(app.engine, gridMaterial.pointer);
final asset = await withPointerCallback<TSceneAsset>((cb) => SceneAsset_createGridRenderThread(app.engine, gridMaterial.pointer, cb));
return GridOverlay(asset, app, animationManager);
}
}

View File

@@ -97,6 +97,8 @@ namespace thermion
void View_setBloomRenderThread(TView *tView, bool enabled, double strength, uint32_t requestId, VoidCallback onComplete);
void View_setCameraRenderThread(TView *tView, TCamera *tCamera, uint32_t requestId, VoidCallback onComplete);
void SceneAsset_createGridRenderThread(TEngine *tEngine, TMaterial * tMaterial, void (*callback)(TSceneAsset *));
void SceneAsset_destroyRenderThread(TSceneAsset *tSceneAsset, uint32_t requestId, VoidCallback onComplete);
void SceneAsset_createFromFilamentAssetRenderThread(
TEngine *tEngine,

View File

@@ -524,6 +524,16 @@ extern "C"
auto fut = _renderThread->add_task(lambda);
}
EMSCRIPTEN_KEEPALIVE void SceneAsset_createGridRenderThread(TEngine *tEngine, TMaterial * tMaterial, void (*onComplete)(TSceneAsset *)) {
std::packaged_task<void()> lambda(
[=]() mutable
{
auto *asset = SceneAsset_createGrid(tEngine, tMaterial);
PROXY(onComplete(asset));
});
auto fut = _renderThread->add_task(lambda);
}
EMSCRIPTEN_KEEPALIVE void SceneAsset_destroyRenderThread(TSceneAsset *tSceneAsset, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda(