remove TMaterialKey struct and pass directly as function params

This commit is contained in:
Nick Fisher
2025-05-14 08:15:09 +08:00
parent d392daa2e6
commit 11ff6c9053
10 changed files with 1196 additions and 754 deletions

View File

@@ -887,11 +887,86 @@ external void Gizmo_unhighlight(
); );
@ffi.Native< @ffi.Native<
ffi.Pointer<TMaterialInstance> Function(ffi.Pointer<TMaterialProvider>, ffi.Pointer<TMaterialInstance> Function(
ffi.Pointer<TMaterialKey>)>(isLeaf: true) ffi.Pointer<TMaterialProvider>,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Int,
ffi.Bool,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Uint8,
ffi.Uint8,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Bool,
ffi.Bool)>(isLeaf: true)
external ffi.Pointer<TMaterialInstance> MaterialProvider_createMaterialInstance( external ffi.Pointer<TMaterialInstance> MaterialProvider_createMaterialInstance(
ffi.Pointer<TMaterialProvider> provider, ffi.Pointer<TMaterialProvider> provider,
ffi.Pointer<TMaterialKey> key, bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
); );
@ffi.Native< @ffi.Native<
@@ -2121,14 +2196,88 @@ external void SceneAsset_createGeometryRenderThread(
@ffi.Native< @ffi.Native<
ffi.Void Function( ffi.Void Function(
ffi.Pointer<TMaterialProvider>, ffi.Pointer<TMaterialProvider>,
ffi.Pointer<TMaterialKey>, ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Int,
ffi.Bool,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Uint8,
ffi.Uint8,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Pointer< ffi.Pointer<
ffi.NativeFunction< ffi.NativeFunction<
ffi.Void Function( ffi.Void Function(
ffi.Pointer<TMaterialInstance>)>>)>(isLeaf: true) ffi.Pointer<TMaterialInstance>)>>)>(isLeaf: true)
external void MaterialProvider_createMaterialInstanceRenderThread( external void MaterialProvider_createMaterialInstanceRenderThread(
ffi.Pointer<TMaterialProvider> tMaterialProvider, ffi.Pointer<TMaterialProvider> tMaterialProvider,
ffi.Pointer<TMaterialKey> tKey, bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
ffi.Pointer< ffi.Pointer<
ffi.NativeFunction<ffi.Void Function(ffi.Pointer<TMaterialInstance>)>> ffi.NativeFunction<ffi.Void Function(ffi.Pointer<TMaterialInstance>)>>
callback, callback,
@@ -3323,134 +3472,6 @@ final class TFilamentAsset extends ffi.Opaque {}
final class TColorGrading extends ffi.Opaque {} final class TColorGrading extends ffi.Opaque {}
final class UnnamedStruct1 extends ffi.Struct {
@ffi.Bool()
external bool hasMetallicRoughnessTexture;
@ffi.Uint8()
external int metallicRoughnessUV;
}
final class UnnamedStruct2 extends ffi.Struct {
@ffi.Bool()
external bool hasSpecularGlossinessTexture;
@ffi.Uint8()
external int specularGlossinessUV;
}
final class UnnamedUnion1 extends ffi.Union {
external UnnamedStruct1 unnamed;
external UnnamedStruct2 unnamed$1;
}
final class TMaterialKey extends ffi.Struct {
@ffi.Bool()
external bool doubleSided;
@ffi.Bool()
external bool unlit;
@ffi.Bool()
external bool hasVertexColors;
@ffi.Bool()
external bool hasBaseColorTexture;
@ffi.Bool()
external bool hasNormalTexture;
@ffi.Bool()
external bool hasOcclusionTexture;
@ffi.Bool()
external bool hasEmissiveTexture;
@ffi.Bool()
external bool useSpecularGlossiness;
@ffi.Int()
external int alphaMode;
@ffi.Bool()
external bool enableDiagnostics;
external UnnamedUnion1 unnamed;
@ffi.Uint8()
external int baseColorUV;
@ffi.Bool()
external bool hasClearCoatTexture;
@ffi.Uint8()
external int clearCoatUV;
@ffi.Bool()
external bool hasClearCoatRoughnessTexture;
@ffi.Uint8()
external int clearCoatRoughnessUV;
@ffi.Bool()
external bool hasClearCoatNormalTexture;
@ffi.Uint8()
external int clearCoatNormalUV;
@ffi.Bool()
external bool hasClearCoat;
@ffi.Bool()
external bool hasTransmission;
@ffi.Bool()
external bool hasTextureTransforms;
@ffi.Uint8()
external int emissiveUV;
@ffi.Uint8()
external int aoUV;
@ffi.Uint8()
external int normalUV;
@ffi.Bool()
external bool hasTransmissionTexture;
@ffi.Uint8()
external int transmissionUV;
@ffi.Bool()
external bool hasSheenColorTexture;
@ffi.Uint8()
external int sheenColorUV;
@ffi.Bool()
external bool hasSheenRoughnessTexture;
@ffi.Uint8()
external int sheenRoughnessUV;
@ffi.Bool()
external bool hasVolumeThicknessTexture;
@ffi.Uint8()
external int volumeThicknessUV;
@ffi.Bool()
external bool hasSheen;
@ffi.Bool()
external bool hasIOR;
@ffi.Bool()
external bool hasVolume;
}
final class double3 extends ffi.Struct { final class double3 extends ffi.Struct {
@ffi.Double() @ffi.Double()
external double x; external double x;

View File

@@ -901,7 +901,44 @@ extension type NativeLibrary(JSObject _) implements JSObject {
); );
external Pointer<TMaterialInstance> _MaterialProvider_createMaterialInstance( external Pointer<TMaterialInstance> _MaterialProvider_createMaterialInstance(
Pointer<TMaterialProvider> provider, Pointer<TMaterialProvider> provider,
Pointer<TMaterialKey> key, bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
); );
external Pointer<TRenderTarget> _RenderTarget_create( external Pointer<TRenderTarget> _RenderTarget_create(
Pointer<TEngine> tEngine, Pointer<TEngine> tEngine,
@@ -1558,7 +1595,44 @@ extension type NativeLibrary(JSObject _) implements JSObject {
); );
external void _MaterialProvider_createMaterialInstanceRenderThread( external void _MaterialProvider_createMaterialInstanceRenderThread(
Pointer<TMaterialProvider> tMaterialProvider, Pointer<TMaterialProvider> tMaterialProvider,
Pointer<TMaterialKey> tKey, bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
Pointer<self.NativeFunction<void Function(PointerClass<TMaterialInstance>)>> Pointer<self.NativeFunction<void Function(PointerClass<TMaterialInstance>)>>
callback, callback,
); );
@@ -3143,10 +3217,85 @@ void Gizmo_unhighlight(
self.Pointer<TMaterialInstance> MaterialProvider_createMaterialInstance( self.Pointer<TMaterialInstance> MaterialProvider_createMaterialInstance(
self.Pointer<TMaterialProvider> provider, self.Pointer<TMaterialProvider> provider,
self.Pointer<TMaterialKey> key, bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
) { ) {
final result = _lib._MaterialProvider_createMaterialInstance( final result = _lib._MaterialProvider_createMaterialInstance(
provider.cast(), key.cast()); provider.cast(),
doubleSided,
unlit,
hasVertexColors,
hasBaseColorTexture,
hasNormalTexture,
hasOcclusionTexture,
hasEmissiveTexture,
useSpecularGlossiness,
alphaMode,
enableDiagnostics,
hasMetallicRoughnessTexture,
metallicRoughnessUV,
hasSpecularGlossinessTexture,
specularGlossinessUV,
baseColorUV,
hasClearCoatTexture,
clearCoatUV,
hasClearCoatRoughnessTexture,
clearCoatRoughnessUV,
hasClearCoatNormalTexture,
clearCoatNormalUV,
hasClearCoat,
hasTransmission,
hasTextureTransforms,
emissiveUV,
aoUV,
normalUV,
hasTransmissionTexture,
transmissionUV,
hasSheenColorTexture,
sheenColorUV,
hasSheenRoughnessTexture,
sheenRoughnessUV,
hasVolumeThicknessTexture,
volumeThicknessUV,
hasSheen,
hasIOR,
hasVolume);
return self.Pointer<TMaterialInstance>(result); return self.Pointer<TMaterialInstance>(result);
} }
@@ -4493,12 +4642,88 @@ void SceneAsset_createGeometryRenderThread(
void MaterialProvider_createMaterialInstanceRenderThread( void MaterialProvider_createMaterialInstanceRenderThread(
self.Pointer<TMaterialProvider> tMaterialProvider, self.Pointer<TMaterialProvider> tMaterialProvider,
self.Pointer<TMaterialKey> tKey, bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
self.Pointer<self.NativeFunction<void Function(Pointer<TMaterialInstance>)>> self.Pointer<self.NativeFunction<void Function(Pointer<TMaterialInstance>)>>
callback, callback,
) { ) {
final result = _lib._MaterialProvider_createMaterialInstanceRenderThread( final result = _lib._MaterialProvider_createMaterialInstanceRenderThread(
tMaterialProvider.cast(), tKey.cast(), callback.cast()); tMaterialProvider.cast(),
doubleSided,
unlit,
hasVertexColors,
hasBaseColorTexture,
hasNormalTexture,
hasOcclusionTexture,
hasEmissiveTexture,
useSpecularGlossiness,
alphaMode,
enableDiagnostics,
hasMetallicRoughnessTexture,
metallicRoughnessUV,
hasSpecularGlossinessTexture,
specularGlossinessUV,
baseColorUV,
hasClearCoatTexture,
clearCoatUV,
hasClearCoatRoughnessTexture,
clearCoatRoughnessUV,
hasClearCoatNormalTexture,
clearCoatNormalUV,
hasClearCoat,
hasTransmission,
hasTextureTransforms,
emissiveUV,
aoUV,
normalUV,
hasTransmissionTexture,
transmissionUV,
hasSheenColorTexture,
sheenColorUV,
hasSheenRoughnessTexture,
sheenRoughnessUV,
hasVolumeThicknessTexture,
volumeThicknessUV,
hasSheen,
hasIOR,
hasVolume,
callback.cast());
return result; return result;
} }
@@ -6415,22 +6640,6 @@ sealed class TGizmoAxis {
static const Z = 2; static const Z = 2;
} }
extension TMaterialKeyExt on Pointer<TMaterialKey> {
TMaterialKey toDart() {
return TMaterialKey(this);
}
void setFrom(TMaterialKey dartType) {}
}
final class TMaterialKey extends self.Struct {
TMaterialKey(super._address);
static Pointer<TMaterialKey> stackAlloc() {
return Pointer<TMaterialKey>(_lib._stackAlloc<TMaterialKey>(0));
}
}
extension TSkyboxExt on Pointer<TSkybox> { extension TSkyboxExt on Pointer<TSkybox> {
TSkybox toDart() { TSkybox toDart() {
return TSkybox(this); return TSkybox(this);

View File

@@ -1,6 +1,5 @@
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:thermion_dart/src/bindings/src/js_interop.dart';
import 'package:thermion_dart/src/utils/src/matrix.dart'; import 'package:thermion_dart/src/utils/src/matrix.dart';
import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart'; import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart';
import 'package:thermion_dart/src/filament/src/implementation/ffi_material.dart'; import 'package:thermion_dart/src/filament/src/implementation/ffi_material.dart';
@@ -224,33 +223,33 @@ class FFIAsset extends ThermionAsset {
.setStencilOpDepthStencilPass(StencilOperation.REPLACE); .setStencilOpDepthStencilPass(StencilOperation.REPLACE);
await sourceMaterialInstance.setStencilReferenceValue(1); await sourceMaterialInstance.setStencilReferenceValue(1);
throw Exception("TODO");
// final materialInstancePtr =
// await withPointerCallback<TMaterialInstance>((cb) {
final materialInstancePtr = // MaterialProvider_createMaterialInstanceRenderThread(
await withPointerCallback<TMaterialInstance>((cb) { // app.ubershaderMaterialProvider, , cb);
final key = Struct.create<TMaterialKey>(); // });
MaterialProvider_createMaterialInstanceRenderThread( // final highlightMaterialInstance =
app.ubershaderMaterialProvider, key.address, cb); // FFIMaterialInstance(materialInstancePtr, app);
}); // await highlightMaterialInstance
final highlightMaterialInstance = // .setStencilCompareFunction(SamplerCompareFunction.NE);
FFIMaterialInstance(materialInstancePtr, app); // await highlightMaterialInstance.setStencilReferenceValue(1);
await highlightMaterialInstance
.setStencilCompareFunction(SamplerCompareFunction.NE);
await highlightMaterialInstance.setStencilReferenceValue(1);
await highlightMaterialInstance.setDepthCullingEnabled(false); // await highlightMaterialInstance.setDepthCullingEnabled(false);
await highlightMaterialInstance.setParameterFloat4( // await highlightMaterialInstance.setParameterFloat4(
"baseColorFactor", r, g, b, 1.0); // "baseColorFactor", r, g, b, 1.0);
var highlightInstance = await this // var highlightInstance = await this
.createInstance(materialInstances: [highlightMaterialInstance]); // .createInstance(materialInstances: [highlightMaterialInstance]);
_highlight = highlightInstance; // _highlight = highlightInstance;
await highlightMaterialInstance.setStencilReferenceValue(1); // await highlightMaterialInstance.setStencilReferenceValue(1);
RenderableManager_setPriority(app.renderableManager, targetEntity, 0); // RenderableManager_setPriority(app.renderableManager, targetEntity, 0);
TransformManager_setParent( // TransformManager_setParent(
app.transformManager, _highlight!.entity, entity, false); // app.transformManager, _highlight!.entity, entity, false);
} }
var targetHighlightEntity = _highlight!.entity; var targetHighlightEntity = _highlight!.entity;
@@ -365,9 +364,47 @@ class FFIAsset extends ThermionAsset {
// Create unlit material instance for the wireframe // Create unlit material instance for the wireframe
final materialInstancePtr = final materialInstancePtr =
await withPointerCallback<TMaterialInstance>((cb) { await withPointerCallback<TMaterialInstance>((cb) {
final key = Struct.create<TMaterialKey>();
MaterialProvider_createMaterialInstanceRenderThread( MaterialProvider_createMaterialInstanceRenderThread(
app.ubershaderMaterialProvider, key.address, cb); app.ubershaderMaterialProvider,
false,
true,
false,
false,
false,
false,
false,
false,
0,
false,
false,
0,
false,
0,
0,
false,
0,
false,
0,
false,
0,
false,
false,
false,
0,
0,
0,
false,
0,
false,
0,
false,
0,
false,
0,
false,
false,
false,
cb);
}); });
final material = FFIMaterialInstance(materialInstancePtr, app); final material = FFIMaterialInstance(materialInstancePtr, app);

View File

@@ -247,8 +247,8 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
/// ///
/// ///
Future destroyAsset(covariant FFIAsset asset) async { Future destroyAsset(covariant FFIAsset asset) async {
await withVoidCallback( await withVoidCallback((requestId, cb) =>
(requestId, cb) => SceneAsset_destroyRenderThread(asset.asset, requestId, cb)); SceneAsset_destroyRenderThread(asset.asset, requestId, cb));
await asset.dispose(); await asset.dispose();
} }
@@ -414,6 +414,8 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
bool enableDiagnostics = false, bool enableDiagnostics = false,
bool hasMetallicRoughnessTexture = false, bool hasMetallicRoughnessTexture = false,
int metallicRoughnessUV = 0, int metallicRoughnessUV = 0,
bool hasSpecularGlossiness = false,
int specularGlossinessUV = 0,
int baseColorUV = 0, int baseColorUV = 0,
bool hasClearCoatTexture = false, bool hasClearCoatTexture = false,
int clearCoatUV = 0, int clearCoatUV = 0,
@@ -438,54 +440,48 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
bool hasSheen = false, bool hasSheen = false,
bool hasIOR = false, bool hasIOR = false,
bool hasVolume = false}) async { bool hasVolume = false}) async {
late Pointer stackPtr;
if (FILAMENT_WASM) {
//stackPtr = stackSave();
}
final key = Struct.create<TMaterialKey>();
key.doubleSided = doubleSided;
key.unlit = unlit;
key.hasVertexColors = hasVertexColors;
key.hasBaseColorTexture = hasBaseColorTexture;
key.hasNormalTexture = hasNormalTexture;
key.hasOcclusionTexture = hasOcclusionTexture;
key.hasEmissiveTexture = hasEmissiveTexture;
key.useSpecularGlossiness = useSpecularGlossiness;
key.alphaMode = alphaMode.index;
key.enableDiagnostics = enableDiagnostics;
key.unnamed.unnamed.hasMetallicRoughnessTexture =
hasMetallicRoughnessTexture;
key.unnamed.unnamed.metallicRoughnessUV = 0;
key.baseColorUV = baseColorUV;
key.hasClearCoatTexture = hasClearCoatTexture;
key.clearCoatUV = clearCoatUV;
key.hasClearCoatRoughnessTexture = hasClearCoatRoughnessTexture;
key.clearCoatRoughnessUV = clearCoatRoughnessUV;
key.hasClearCoatNormalTexture = hasClearCoatNormalTexture;
key.clearCoatNormalUV = clearCoatNormalUV;
key.hasClearCoat = hasClearCoat;
key.hasTransmission = hasTransmission;
key.hasTextureTransforms = hasTextureTransforms;
key.emissiveUV = emissiveUV;
key.aoUV = aoUV;
key.normalUV = normalUV;
key.hasTransmissionTexture = hasTransmissionTexture;
key.transmissionUV = transmissionUV;
key.hasSheenColorTexture = hasSheenColorTexture;
key.sheenColorUV = sheenColorUV;
key.hasSheenRoughnessTexture = hasSheenRoughnessTexture;
key.sheenRoughnessUV = sheenRoughnessUV;
key.hasVolumeThicknessTexture = hasVolumeThicknessTexture;
key.volumeThicknessUV = volumeThicknessUV;
key.hasSheen = hasSheen;
key.hasIOR = hasIOR;
key.hasVolume = hasVolume;
final materialInstance = await withPointerCallback<TMaterialInstance>((cb) { final materialInstance = await withPointerCallback<TMaterialInstance>((cb) {
MaterialProvider_createMaterialInstanceRenderThread( MaterialProvider_createMaterialInstanceRenderThread(
ubershaderMaterialProvider, key.address, cb); ubershaderMaterialProvider,
doubleSided,
unlit,
hasVertexColors,
hasBaseColorTexture,
hasNormalTexture,
hasOcclusionTexture,
hasEmissiveTexture,
useSpecularGlossiness,
alphaMode.index,
enableDiagnostics,
hasMetallicRoughnessTexture,
metallicRoughnessUV,
hasSpecularGlossiness,
specularGlossinessUV,
baseColorUV,
hasClearCoatTexture,
clearCoatUV,
hasClearCoatRoughnessTexture,
clearCoatRoughnessUV,
hasClearCoatNormalTexture,
clearCoatNormalUV,
hasClearCoat,
hasTransmission,
hasTextureTransforms,
emissiveUV,
aoUV,
normalUV,
hasTransmissionTexture,
transmissionUV,
hasSheenColorTexture,
sheenColorUV,
hasSheenRoughnessTexture,
sheenRoughnessUV,
hasVolumeThicknessTexture,
volumeThicknessUV,
hasSheen,
hasIOR,
hasVolume,
cb);
}); });
if (FILAMENT_WASM) { if (FILAMENT_WASM) {
@@ -549,10 +545,11 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
}); });
if (FILAMENT_SINGLE_THREADED) { if (FILAMENT_SINGLE_THREADED) {
await withVoidCallback((requestId, cb) => Engine_executeRenderThread(engine, requestId, cb));
} else {
await withVoidCallback( await withVoidCallback(
(requestId, cb) => Engine_flushAndWaitRenderThread(engine, requestId, cb)); (requestId, cb) => Engine_executeRenderThread(engine, requestId, cb));
} else {
await withVoidCallback((requestId, cb) =>
Engine_flushAndWaitRenderThread(engine, requestId, cb));
} }
} }
@@ -868,7 +865,8 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
SceneAsset_createFromFilamentAssetRenderThread(engine, SceneAsset_createFromFilamentAssetRenderThread(engine,
gltfAssetLoader, nameComponentManager, filamentAsset, cb)); gltfAssetLoader, nameComponentManager, filamentAsset, cb));
await withVoidCallback((requestId, cb) => GltfResourceLoader_destroyRenderThread( await withVoidCallback((requestId, cb) =>
GltfResourceLoader_destroyRenderThread(
engine, gltfResourceLoader, requestId, cb)); engine, gltfResourceLoader, requestId, cb));
return FFIAsset(asset, this, animationManager.cast<TAnimationManager>()); return FFIAsset(asset, this, animationManager.cast<TAnimationManager>());
@@ -886,11 +884,12 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
Future destroyView(covariant FFIView view) async { Future destroyView(covariant FFIView view) async {
View_setColorGrading(view.view, nullptr); View_setColorGrading(view.view, nullptr);
for (final cg in view.colorGrading.entries) { for (final cg in view.colorGrading.entries) {
await withVoidCallback( await withVoidCallback((requestId, cb) =>
(requestId, cb) => Engine_destroyColorGradingRenderThread(engine, cg.value, requestId, cb)); Engine_destroyColorGradingRenderThread(
engine, cg.value, requestId, cb));
} }
await withVoidCallback( await withVoidCallback((requestId, cb) =>
(requestId, cb) => Engine_destroyViewRenderThread(engine, view.view, requestId, cb)); Engine_destroyViewRenderThread(engine, view.view, requestId, cb));
for (final swapchain in _swapChains.keys) { for (final swapchain in _swapChains.keys) {
if (_swapChains[swapchain]!.contains(view)) { if (_swapChains[swapchain]!.contains(view)) {
_swapChains[swapchain]!.remove(view); _swapChains[swapchain]!.remove(view);
@@ -901,8 +900,8 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
} }
Future destroyScene(covariant FFIScene scene) async { Future destroyScene(covariant FFIScene scene) async {
await withVoidCallback( await withVoidCallback((requestId, cb) =>
(requestId, cb) => Engine_destroySceneRenderThread(engine, scene.scene, requestId, cb)); Engine_destroySceneRenderThread(engine, scene.scene, requestId, cb));
} }
Future<Pointer<TColorGrading>> createColorGrading(ToneMapper mapper) async { Future<Pointer<TColorGrading>> createColorGrading(ToneMapper mapper) async {
@@ -1028,10 +1027,11 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
/// ///
Future flush() async { Future flush() async {
if (FILAMENT_SINGLE_THREADED) { if (FILAMENT_SINGLE_THREADED) {
await withVoidCallback((requestId, cb) => Engine_executeRenderThread(engine, requestId, cb));
} else {
await withVoidCallback( await withVoidCallback(
(requestId, cb) => Engine_flushAndWaitRenderThread(engine, requestId, cb)); (requestId, cb) => Engine_executeRenderThread(engine, requestId, cb));
} else {
await withVoidCallback((requestId, cb) =>
Engine_flushAndWaitRenderThread(engine, requestId, cb));
} }
} }

View File

@@ -1,6 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:thermion_dart/src/bindings/src/js_interop.dart';
import 'package:thermion_dart/src/filament/src/interface/scene.dart'; import 'package:thermion_dart/src/filament/src/interface/scene.dart';
import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart'; import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart';
import 'package:thermion_dart/src/filament/src/implementation/ffi_render_target.dart'; import 'package:thermion_dart/src/filament/src/implementation/ffi_render_target.dart';

View File

@@ -45,68 +45,6 @@ extern "C"
typedef struct TFilamentAsset TFilamentAsset; typedef struct TFilamentAsset TFilamentAsset;
typedef struct TColorGrading TColorGrading; typedef struct TColorGrading TColorGrading;
struct TMaterialKey {
bool doubleSided;
bool unlit;
bool hasVertexColors;
bool hasBaseColorTexture;
bool hasNormalTexture;
bool hasOcclusionTexture;
bool hasEmissiveTexture;
bool useSpecularGlossiness;
int alphaMode;
bool enableDiagnostics;
union {
#ifdef __cplusplus
struct {
bool hasMetallicRoughnessTexture;
uint8_t metallicRoughnessUV;
};
struct {
bool hasSpecularGlossinessTexture;
uint8_t specularGlossinessUV;
};
#else
struct {
bool hasMetallicRoughnessTexture;
uint8_t metallicRoughnessUV;
};
struct {
bool hasSpecularGlossinessTexture;
uint8_t specularGlossinessUV;
};
#endif
};
uint8_t baseColorUV;
// -- 32 bit boundary --
bool hasClearCoatTexture;
uint8_t clearCoatUV;
bool hasClearCoatRoughnessTexture;
uint8_t clearCoatRoughnessUV;
bool hasClearCoatNormalTexture;
uint8_t clearCoatNormalUV;
bool hasClearCoat;
bool hasTransmission;
bool hasTextureTransforms;
// -- 32 bit boundary --
uint8_t emissiveUV;
uint8_t aoUV;
uint8_t normalUV;
bool hasTransmissionTexture;
uint8_t transmissionUV;
// -- 32 bit boundary --
bool hasSheenColorTexture;
uint8_t sheenColorUV;
bool hasSheenRoughnessTexture;
uint8_t sheenRoughnessUV;
bool hasVolumeThicknessTexture;
uint8_t volumeThicknessUV ;
bool hasSheen;
bool hasIOR;
bool hasVolume;
} ;
typedef struct TMaterialKey TMaterialKey;
typedef struct { typedef struct {
double x; double x;
double y; double y;

View File

@@ -9,7 +9,47 @@ extern "C"
#endif #endif
// EMSCRIPTEN_KEEPALIVE TMaterialProvider *MaterialProvider_create(TEngine *tEngine, uint8_t* data, size_t length); // EMSCRIPTEN_KEEPALIVE TMaterialProvider *MaterialProvider_create(TEngine *tEngine, uint8_t* data, size_t length);
EMSCRIPTEN_KEEPALIVE TMaterialInstance *MaterialProvider_createMaterialInstance(TMaterialProvider *provider, TMaterialKey *key); EMSCRIPTEN_KEEPALIVE TMaterialInstance *MaterialProvider_createMaterialInstance(
TMaterialProvider *provider,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
uint8_t metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
uint8_t specularGlossinessUV,
uint8_t baseColorUV,
bool hasClearCoatTexture,
uint8_t clearCoatUV,
bool hasClearCoatRoughnessTexture,
uint8_t clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
uint8_t clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
uint8_t emissiveUV,
uint8_t aoUV,
uint8_t normalUV,
bool hasTransmissionTexture,
uint8_t transmissionUV,
bool hasSheenColorTexture,
uint8_t sheenColorUV,
bool hasSheenRoughnessTexture,
uint8_t sheenRoughnessUV,
bool hasVolumeThicknessTexture,
uint8_t volumeThicknessUV ,
bool hasSheen,
bool hasIOR,
bool hasVolume
);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -116,7 +116,47 @@ namespace thermion
int materialInstanceCount, int materialInstanceCount,
void (*callback)(TSceneAsset *) void (*callback)(TSceneAsset *)
); );
void MaterialProvider_createMaterialInstanceRenderThread(TMaterialProvider *tMaterialProvider, TMaterialKey *tKey, void (*callback)(TMaterialInstance *)); void MaterialProvider_createMaterialInstanceRenderThread(
TMaterialProvider *tMaterialProvider,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
uint8_t metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
uint8_t specularGlossinessUV,
uint8_t baseColorUV,
bool hasClearCoatTexture,
uint8_t clearCoatUV,
bool hasClearCoatRoughnessTexture,
uint8_t clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
uint8_t clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
uint8_t emissiveUV,
uint8_t aoUV,
uint8_t normalUV,
bool hasTransmissionTexture,
uint8_t transmissionUV,
bool hasSheenColorTexture,
uint8_t sheenColorUV,
bool hasSheenRoughnessTexture,
uint8_t sheenRoughnessUV,
bool hasVolumeThicknessTexture,
uint8_t volumeThicknessUV ,
bool hasSheen,
bool hasIOR,
bool hasVolume,
void (*callback)(TMaterialInstance *));
void AnimationManager_updateBoneMatricesRenderThread( void AnimationManager_updateBoneMatricesRenderThread(
TAnimationManager *tAnimationManager, TAnimationManager *tAnimationManager,

View File

@@ -20,41 +20,81 @@ namespace thermion
{ {
#endif #endif
EMSCRIPTEN_KEEPALIVE TMaterialInstance *MaterialProvider_createMaterialInstance(TMaterialProvider *tMaterialProvider, TMaterialKey *materialConfig) EMSCRIPTEN_KEEPALIVE TMaterialInstance *MaterialProvider_createMaterialInstance(
TMaterialProvider *tMaterialProvider,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
uint8_t metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
uint8_t specularGlossinessUV,
uint8_t baseColorUV,
bool hasClearCoatTexture,
uint8_t clearCoatUV,
bool hasClearCoatRoughnessTexture,
uint8_t clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
uint8_t clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
uint8_t emissiveUV,
uint8_t aoUV,
uint8_t normalUV,
bool hasTransmissionTexture,
uint8_t transmissionUV,
bool hasSheenColorTexture,
uint8_t sheenColorUV,
bool hasSheenRoughnessTexture,
uint8_t sheenRoughnessUV,
bool hasVolumeThicknessTexture,
uint8_t volumeThicknessUV ,
bool hasSheen,
bool hasIOR,
bool hasVolume)
{ {
gltfio::MaterialKey config; gltfio::MaterialKey config;
gltfio::UvMap uvMap; gltfio::UvMap uvMap;
memset(&config, 0, sizeof(gltfio::MaterialKey)); memset(&config, 0, sizeof(gltfio::MaterialKey));
// Set and log each field // Set and log each field
config.unlit = materialConfig->unlit; config.unlit = unlit;
config.doubleSided = materialConfig->doubleSided; config.doubleSided = doubleSided;
config.useSpecularGlossiness = materialConfig->useSpecularGlossiness; config.useSpecularGlossiness = useSpecularGlossiness;
config.alphaMode = static_cast<filament::gltfio::AlphaMode>(materialConfig->alphaMode); config.alphaMode = static_cast<filament::gltfio::AlphaMode>(alphaMode);
config.hasBaseColorTexture = materialConfig->hasBaseColorTexture; config.hasBaseColorTexture = hasBaseColorTexture;
config.hasClearCoat = materialConfig->hasClearCoat; config.hasClearCoat = hasClearCoat;
config.hasClearCoatNormalTexture = materialConfig->hasClearCoatNormalTexture; config.hasClearCoatNormalTexture = hasClearCoatNormalTexture;
config.hasClearCoatRoughnessTexture = materialConfig->hasClearCoatRoughnessTexture; config.hasClearCoatRoughnessTexture = hasClearCoatRoughnessTexture;
config.hasEmissiveTexture = materialConfig->hasEmissiveTexture; config.hasEmissiveTexture = hasEmissiveTexture;
config.hasIOR = materialConfig->hasIOR; config.hasIOR = hasIOR;
config.hasMetallicRoughnessTexture = materialConfig->hasMetallicRoughnessTexture; config.hasMetallicRoughnessTexture = hasMetallicRoughnessTexture;
config.hasNormalTexture = materialConfig->hasNormalTexture; config.hasNormalTexture = hasNormalTexture;
config.hasOcclusionTexture = materialConfig->hasOcclusionTexture; config.hasOcclusionTexture = hasOcclusionTexture;
config.hasSheen = materialConfig->hasSheen; config.hasSheen = hasSheen;
config.hasSheenColorTexture = materialConfig->hasSheenColorTexture; config.hasSheenColorTexture = hasSheenColorTexture;
config.hasSheenRoughnessTexture = materialConfig->hasSheenRoughnessTexture; config.hasSheenRoughnessTexture = hasSheenRoughnessTexture;
config.hasTextureTransforms = materialConfig->hasTextureTransforms; config.hasTextureTransforms = hasTextureTransforms;
config.hasTransmission = materialConfig->hasTransmission; config.hasTransmission = hasTransmission;
config.hasTransmissionTexture = materialConfig->hasTransmissionTexture; config.hasTransmissionTexture = hasTransmissionTexture;
config.hasVolume = materialConfig->hasVolume; config.hasVolume = hasVolume;
config.hasVolumeThicknessTexture = materialConfig->hasVolumeThicknessTexture; config.hasVolumeThicknessTexture = hasVolumeThicknessTexture;
config.baseColorUV = materialConfig->baseColorUV; config.baseColorUV = baseColorUV;
config.hasVertexColors = materialConfig->hasVertexColors; config.hasVertexColors = hasVertexColors;
auto *materialProvider = reinterpret_cast<gltfio::MaterialProvider *>(tMaterialProvider); auto *materialProvider = reinterpret_cast<gltfio::MaterialProvider *>(tMaterialProvider);
auto materialInstance = materialProvider->createMaterialInstance(&config, &uvMap); auto materialInstance = materialProvider->createMaterialInstance(&config, &uvMap);
return reinterpret_cast<TMaterialInstance *>(materialInstance); return reinterpret_cast<TMaterialInstance *>(materialInstance);
} }
#ifdef __cplusplus #ifdef __cplusplus
} }
} }

View File

@@ -54,9 +54,7 @@ using namespace std::chrono_literals;
#define PROXY(call) \ #define PROXY(call) \
auto startTime = std::chrono::high_resolution_clock::now(); \ auto startTime = std::chrono::high_resolution_clock::now(); \
TRACE("PROXYING"); \ TRACE("PROXYING"); \
_renderThread->queue.proxySync(_renderThread->outer, [=]() { \ _renderThread->queue.proxySync(_renderThread->outer, [=]() { call; });
call; \
});
#else #else
#define PROXY(call) call #define PROXY(call) call
#endif #endif
@@ -65,7 +63,8 @@ extern "C"
static std::unique_ptr<RenderThread> _renderThread; static std::unique_ptr<RenderThread> _renderThread;
EMSCRIPTEN_KEEPALIVE void RenderThread_create() { EMSCRIPTEN_KEEPALIVE void RenderThread_create()
{
TRACE("RenderThread_create"); TRACE("RenderThread_create");
if (_renderThread) if (_renderThread)
{ {
@@ -75,7 +74,8 @@ extern "C"
TRACE("RenderThread created"); TRACE("RenderThread created");
} }
EMSCRIPTEN_KEEPALIVE void RenderThread_destroy() { EMSCRIPTEN_KEEPALIVE void RenderThread_destroy()
{
TRACE("RenderThread_destroy"); TRACE("RenderThread_destroy");
if (_renderThread) if (_renderThread)
{ {
@@ -83,7 +83,8 @@ extern "C"
} }
} }
EMSCRIPTEN_KEEPALIVE void RenderThread_addTask(void (*task)()) { EMSCRIPTEN_KEEPALIVE void RenderThread_addTask(void (*task)())
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -92,16 +93,19 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void RenderThread_setRenderTicker(TRenderTicker *tRenderTicker) { EMSCRIPTEN_KEEPALIVE void RenderThread_setRenderTicker(TRenderTicker *tRenderTicker)
{
auto *renderTicker = reinterpret_cast<RenderTicker *>(tRenderTicker); auto *renderTicker = reinterpret_cast<RenderTicker *>(tRenderTicker);
_renderThread->setRenderTicker(renderTicker); _renderThread->setRenderTicker(renderTicker);
} }
EMSCRIPTEN_KEEPALIVE void RenderThread_requestFrameAsync() { EMSCRIPTEN_KEEPALIVE void RenderThread_requestFrameAsync()
{
_renderThread->requestFrame(); _renderThread->requestFrame();
} }
EMSCRIPTEN_KEEPALIVE void RenderTicker_renderRenderThread(TRenderTicker *tRenderTicker, uint64_t frameTimeInNanos, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void RenderTicker_renderRenderThread(TRenderTicker *tRenderTicker, uint64_t frameTimeInNanos, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -117,7 +121,8 @@ extern "C"
void *sharedContext, void *sharedContext,
uint8_t stereoscopicEyeCount, uint8_t stereoscopicEyeCount,
bool disableHandleUseAfterFreeCheck, bool disableHandleUseAfterFreeCheck,
void (*onComplete)(TEngine *)) { void (*onComplete)(TEngine *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
@@ -128,7 +133,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_createRendererRenderThread(TEngine *tEngine, void (*onComplete)(TRenderer *)) { EMSCRIPTEN_KEEPALIVE void Engine_createRendererRenderThread(TEngine *tEngine, void (*onComplete)(TRenderer *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
@@ -139,7 +145,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_createSwapChainRenderThread(TEngine *tEngine, void *window, uint64_t flags, void (*onComplete)(TSwapChain *)) { EMSCRIPTEN_KEEPALIVE void Engine_createSwapChainRenderThread(TEngine *tEngine, void *window, uint64_t flags, void (*onComplete)(TSwapChain *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -149,7 +156,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_createHeadlessSwapChainRenderThread(TEngine *tEngine, uint32_t width, uint32_t height, uint64_t flags, void (*onComplete)(TSwapChain *)) { EMSCRIPTEN_KEEPALIVE void Engine_createHeadlessSwapChainRenderThread(TEngine *tEngine, uint32_t width, uint32_t height, uint64_t flags, void (*onComplete)(TSwapChain *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -159,7 +167,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_destroySwapChainRenderThread(TEngine *tEngine, TSwapChain *tSwapChain, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_destroySwapChainRenderThread(TEngine *tEngine, TSwapChain *tSwapChain, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -169,7 +178,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_destroyViewRenderThread(TEngine *tEngine, TView *tView, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_destroyViewRenderThread(TEngine *tEngine, TView *tView, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -179,7 +189,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_destroySceneRenderThread(TEngine *tEngine, TScene *tScene, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_destroySceneRenderThread(TEngine *tEngine, TScene *tScene, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -189,7 +200,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_createCameraRenderThread(TEngine* tEngine, void (*onComplete)(TCamera *)) { EMSCRIPTEN_KEEPALIVE void Engine_createCameraRenderThread(TEngine *tEngine, void (*onComplete)(TCamera *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -199,7 +211,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_createViewRenderThread(TEngine *tEngine, void (*onComplete)(TView *)) { EMSCRIPTEN_KEEPALIVE void Engine_createViewRenderThread(TEngine *tEngine, void (*onComplete)(TView *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -209,7 +222,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_destroyRenderThread(TEngine *tEngine, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_destroyRenderThread(TEngine *tEngine, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -230,7 +244,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_destroySkyboxRenderThread(TEngine *tEngine, TSkybox *tSkybox, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_destroySkyboxRenderThread(TEngine *tEngine, TSkybox *tSkybox, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -240,7 +255,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_destroyIndirectLightRenderThread(TEngine *tEngine, TIndirectLight *tIndirectLight, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_destroyIndirectLightRenderThread(TEngine *tEngine, TIndirectLight *tIndirectLight, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -261,7 +277,6 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_destroyMaterialRenderThread(TEngine *tEngine, TMaterial *tMaterial, uint32_t requestId, VoidCallback onComplete) EMSCRIPTEN_KEEPALIVE void Engine_destroyMaterialRenderThread(TEngine *tEngine, TMaterial *tMaterial, uint32_t requestId, VoidCallback onComplete)
{ {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
@@ -273,7 +288,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_destroyMaterialInstanceRenderThread(TEngine *tEngine, TMaterialInstance *tMaterialInstance, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_destroyMaterialInstanceRenderThread(TEngine *tEngine, TMaterialInstance *tMaterialInstance, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -283,7 +299,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_createFenceRenderThread(TEngine *tEngine, void (*onComplete)(TFence*)) { EMSCRIPTEN_KEEPALIVE void Engine_createFenceRenderThread(TEngine *tEngine, void (*onComplete)(TFence *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -293,7 +310,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_destroyFenceRenderThread(TEngine *tEngine, TFence *tFence, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_destroyFenceRenderThread(TEngine *tEngine, TFence *tFence, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -303,7 +321,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_flushAndWaitRenderThread(TEngine *tEngine, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_flushAndWaitRenderThread(TEngine *tEngine, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -313,7 +332,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_executeRenderThread(TEngine *tEngine, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Engine_executeRenderThread(TEngine *tEngine, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -323,13 +343,15 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void execute_queue() { EMSCRIPTEN_KEEPALIVE void execute_queue()
{
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
_renderThread->queue.execute(); _renderThread->queue.execute();
#endif #endif
} }
EMSCRIPTEN_KEEPALIVE void Engine_buildSkyboxRenderThread(TEngine *tEngine, uint8_t *skyboxData, size_t length, void (*onComplete)(TSkybox *), void (*onTextureUploadComplete)()) { EMSCRIPTEN_KEEPALIVE void Engine_buildSkyboxRenderThread(TEngine *tEngine, uint8_t *skyboxData, size_t length, void (*onComplete)(TSkybox *), void (*onTextureUploadComplete)())
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -339,7 +361,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Engine_buildIndirectLightRenderThread(TEngine *tEngine, uint8_t *iblData, size_t length, float intensity, void (*onComplete)(TIndirectLight *), void (*onTextureUploadComplete)()) { EMSCRIPTEN_KEEPALIVE void Engine_buildIndirectLightRenderThread(TEngine *tEngine, uint8_t *iblData, size_t length, float intensity, void (*onComplete)(TIndirectLight *), void (*onTextureUploadComplete)())
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -349,7 +372,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Renderer_beginFrameRenderThread(TRenderer *tRenderer, TSwapChain *tSwapChain, uint64_t frameTimeInNanos, void (*onComplete)(bool)) { EMSCRIPTEN_KEEPALIVE void Renderer_beginFrameRenderThread(TRenderer *tRenderer, TSwapChain *tSwapChain, uint64_t frameTimeInNanos, void (*onComplete)(bool))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -358,7 +382,8 @@ extern "C"
}); });
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Renderer_endFrameRenderThread(TRenderer *tRenderer, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Renderer_endFrameRenderThread(TRenderer *tRenderer, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -368,7 +393,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Renderer_renderRenderThread(TRenderer *tRenderer, TView *tView, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Renderer_renderRenderThread(TRenderer *tRenderer, TView *tView, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -378,7 +404,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Renderer_renderStandaloneViewRenderThread(TRenderer *tRenderer, TView *tView, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Renderer_renderStandaloneViewRenderThread(TRenderer *tRenderer, TView *tView, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -396,7 +423,8 @@ extern "C"
double clearA, double clearA,
uint8_t clearStencil, uint8_t clearStencil,
bool clear, bool clear,
bool discard, uint32_t requestId, VoidCallback onComplete) { bool discard, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -414,7 +442,8 @@ extern "C"
TPixelDataType tPixelDataType, TPixelDataType tPixelDataType,
uint8_t *out, uint8_t *out,
size_t outLength, size_t outLength,
uint32_t requestId, VoidCallback onComplete) { uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -424,7 +453,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Material_createImageMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *)) { EMSCRIPTEN_KEEPALIVE void Material_createImageMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -434,7 +464,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Material_createGizmoMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *)) { EMSCRIPTEN_KEEPALIVE void Material_createGizmoMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -444,7 +475,6 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Material_createInstanceRenderThread(TMaterial *tMaterial, void (*onComplete)(TMaterialInstance *)) EMSCRIPTEN_KEEPALIVE void Material_createInstanceRenderThread(TMaterial *tMaterial, void (*onComplete)(TMaterialInstance *))
{ {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
@@ -456,7 +486,8 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void SceneAsset_destroyRenderThread(TSceneAsset *tSceneAsset, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void SceneAsset_destroyRenderThread(TSceneAsset *tSceneAsset, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -466,7 +497,6 @@ extern "C"
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void SceneAsset_createGeometryRenderThread( EMSCRIPTEN_KEEPALIVE void SceneAsset_createGeometryRenderThread(
TEngine *tEngine, TEngine *tEngine,
float *vertices, float *vertices,
@@ -480,8 +510,8 @@ extern "C"
TPrimitiveType tPrimitiveType, TPrimitiveType tPrimitiveType,
TMaterialInstance **materialInstances, TMaterialInstance **materialInstances,
int materialInstanceCount, int materialInstanceCount,
void (*callback)(TSceneAsset *) void (*callback)(TSceneAsset *))
) { {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=] [=]
{ {
@@ -496,8 +526,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
TGltfAssetLoader *tAssetLoader, TGltfAssetLoader *tAssetLoader,
TNameComponentManager *tNameComponentManager, TNameComponentManager *tNameComponentManager,
TFilamentAsset *tFilamentAsset, TFilamentAsset *tFilamentAsset,
void (*onComplete)(TSceneAsset *) void (*onComplete)(TSceneAsset *))
) { {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=] [=]
{ {
@@ -521,12 +551,91 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void MaterialProvider_createMaterialInstanceRenderThread(TMaterialProvider *tMaterialProvider, TMaterialKey *tKey, void (*callback)(TMaterialInstance *)) EMSCRIPTEN_KEEPALIVE void MaterialProvider_createMaterialInstanceRenderThread(
TMaterialProvider *tMaterialProvider,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
uint8_t metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
uint8_t specularGlossinessUV,
uint8_t baseColorUV,
bool hasClearCoatTexture,
uint8_t clearCoatUV,
bool hasClearCoatRoughnessTexture,
uint8_t clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
uint8_t clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
uint8_t emissiveUV,
uint8_t aoUV,
uint8_t normalUV,
bool hasTransmissionTexture,
uint8_t transmissionUV,
bool hasSheenColorTexture,
uint8_t sheenColorUV,
bool hasSheenRoughnessTexture,
uint8_t sheenRoughnessUV,
bool hasVolumeThicknessTexture,
uint8_t volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
void (*callback)(TMaterialInstance *))
{ {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=] [=]
{ {
auto materialInstance = MaterialProvider_createMaterialInstance(tMaterialProvider, tKey); auto materialInstance = MaterialProvider_createMaterialInstance(
tMaterialProvider,
doubleSided,
unlit,
hasVertexColors,
hasBaseColorTexture,
hasNormalTexture,
hasOcclusionTexture,
hasEmissiveTexture,
useSpecularGlossiness,
alphaMode,
enableDiagnostics,
hasMetallicRoughnessTexture,
metallicRoughnessUV,
hasSpecularGlossinessTexture,
specularGlossinessUV,
baseColorUV,
hasClearCoatTexture,
clearCoatUV,
hasClearCoatRoughnessTexture,
clearCoatRoughnessUV,
hasClearCoatNormalTexture,
clearCoatNormalUV,
hasClearCoat,
hasTransmission,
hasTextureTransforms,
emissiveUV,
aoUV,
normalUV,
hasTransmissionTexture,
transmissionUV,
hasSheenColorTexture,
sheenColorUV,
hasSheenRoughnessTexture,
sheenRoughnessUV,
hasVolumeThicknessTexture,
volumeThicknessUV,
hasSheen,
hasIOR,
hasVolume);
PROXY(callback(materialInstance)); PROXY(callback(materialInstance));
}); });
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
@@ -554,11 +663,11 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void View_pickRenderThread(TView *tView, uint32_t requestId, uint32_t x, uint32_t y, PickCallback callback) { EMSCRIPTEN_KEEPALIVE void View_pickRenderThread(TView *tView, uint32_t requestId, uint32_t x, uint32_t y, PickCallback callback)
{
auto *view = reinterpret_cast<View *>(tView); auto *view = reinterpret_cast<View *>(tView);
view->pick(x, y, [=](filament::View::PickingQueryResult const &result) { view->pick(x, y, [=](filament::View::PickingQueryResult const &result)
PROXY(callback(requestId, utils::Entity::smuggle(result.renderable), result.depth, result.fragCoords.x, result.fragCoords.y, result.fragCoords.z)); { PROXY(callback(requestId, utils::Entity::smuggle(result.renderable), result.depth, result.fragCoords.x, result.fragCoords.y, result.fragCoords.z)); });
});
} }
EMSCRIPTEN_KEEPALIVE void View_setColorGradingRenderThread(TView *tView, TColorGrading *tColorGrading, uint32_t requestId, VoidCallback onComplete) EMSCRIPTEN_KEEPALIVE void View_setColorGradingRenderThread(TView *tView, TColorGrading *tColorGrading, uint32_t requestId, VoidCallback onComplete)
@@ -594,7 +703,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void AnimationManager_createRenderThread(TEngine *tEngine, TScene *tScene, void (*onComplete)(TAnimationManager *)) { EMSCRIPTEN_KEEPALIVE void AnimationManager_createRenderThread(TEngine *tEngine, TScene *tScene, void (*onComplete)(TAnimationManager *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -723,7 +833,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
uint16_t tUsage, uint16_t tUsage,
intptr_t import, intptr_t import,
TTextureSamplerType sampler, TTextureSamplerType sampler,
TTextureFormat format, void (*onComplete)(TTexture *)) { TTextureFormat format, void (*onComplete)(TTexture *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -785,8 +896,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
uint32_t depth, uint32_t depth,
uint32_t bufferFormat, uint32_t bufferFormat,
uint32_t pixelDataType, uint32_t pixelDataType,
void (*onComplete)(bool) void (*onComplete)(bool))
) { {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -804,8 +915,7 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
channels, channels,
depth, depth,
bufferFormat, bufferFormat,
pixelDataType pixelDataType);
);
PROXY(onComplete(result)); PROXY(onComplete(result));
}); });
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
@@ -845,8 +955,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
EMSCRIPTEN_KEEPALIVE void RenderTarget_destroyRenderThread( EMSCRIPTEN_KEEPALIVE void RenderTarget_destroyRenderThread(
TEngine *tEngine, TEngine *tEngine,
TRenderTarget *tRenderTarget, TRenderTarget *tRenderTarget,
uint32_t requestId, VoidCallback onComplete uint32_t requestId, VoidCallback onComplete)
) { {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -856,7 +966,6 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void TextureSampler_createRenderThread(void (*onComplete)(TTextureSampler *)) EMSCRIPTEN_KEEPALIVE void TextureSampler_createRenderThread(void (*onComplete)(TTextureSampler *))
{ {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
@@ -1011,7 +1120,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void GltfAssetLoader_createRenderThread(TEngine *tEngine, TMaterialProvider *tMaterialProvider, void (*callback)(TGltfAssetLoader *)) { EMSCRIPTEN_KEEPALIVE void GltfAssetLoader_createRenderThread(TEngine *tEngine, TMaterialProvider *tMaterialProvider, void (*callback)(TGltfAssetLoader *))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -1031,7 +1141,9 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_destroyRenderThread(TEngine *tEngine, TGltfResourceLoader *tResourceLoader, uint32_t requestId, VoidCallback onComplete) {
EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_destroyRenderThread(TEngine *tEngine, TGltfResourceLoader *tResourceLoader, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -1041,7 +1153,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_loadResourcesRenderThread(TGltfResourceLoader *tGltfResourceLoader, TFilamentAsset *tFilamentAsset, void (*callback)(bool)) { EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_loadResourcesRenderThread(TGltfResourceLoader *tGltfResourceLoader, TFilamentAsset *tFilamentAsset, void (*callback)(bool))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -1056,7 +1169,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
const char *uri, const char *uri,
uint8_t *data, uint8_t *data,
size_t length, size_t length,
uint32_t requestId, VoidCallback onComplete) { uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -1069,7 +1183,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_asyncBeginLoadRenderThread( EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_asyncBeginLoadRenderThread(
TGltfResourceLoader *tGltfResourceLoader, TGltfResourceLoader *tGltfResourceLoader,
TFilamentAsset *tFilamentAsset, TFilamentAsset *tFilamentAsset,
void (*callback)(bool)) { void (*callback)(bool))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -1080,7 +1195,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
} }
EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_asyncUpdateLoadRenderThread( EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_asyncUpdateLoadRenderThread(
TGltfResourceLoader *tGltfResourceLoader) { TGltfResourceLoader *tGltfResourceLoader)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -1091,7 +1207,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_asyncGetLoadProgressRenderThread( EMSCRIPTEN_KEEPALIVE void GltfResourceLoader_asyncGetLoadProgressRenderThread(
TGltfResourceLoader *tGltfResourceLoader, TGltfResourceLoader *tGltfResourceLoader,
void (*callback)(float)) { void (*callback)(float))
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -1107,8 +1224,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
uint8_t *data, uint8_t *data,
size_t length, size_t length,
uint8_t numInstances, uint8_t numInstances,
void (*callback)(TFilamentAsset *) void (*callback)(TFilamentAsset *))
) { {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -1118,7 +1235,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
auto fut = _renderThread->add_task(lambda); auto fut = _renderThread->add_task(lambda);
} }
EMSCRIPTEN_KEEPALIVE void Scene_addFilamentAssetRenderThread(TScene* tScene, TFilamentAsset *tAsset, uint32_t requestId, VoidCallback onComplete) { EMSCRIPTEN_KEEPALIVE void Scene_addFilamentAssetRenderThread(TScene *tScene, TFilamentAsset *tAsset, uint32_t requestId, VoidCallback onComplete)
{
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {
@@ -1136,8 +1254,8 @@ EMSCRIPTEN_KEEPALIVE void SceneAsset_createFromFilamentAssetRenderThread(
TView *tView, TView *tView,
TMaterial *tMaterial, TMaterial *tMaterial,
TGizmoType tGizmoType, TGizmoType tGizmoType,
void (*callback)(TGizmo *) void (*callback)(TGizmo *))
) { {
std::packaged_task<void()> lambda( std::packaged_task<void()> lambda(
[=]() mutable [=]() mutable
{ {