From 0b18caf4ffeec091d75efcb83362c8d81c5f6a9e Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Tue, 1 Jul 2025 10:07:10 +0800 Subject: [PATCH] expose Engine->getSupportedFeatureLevel() --- .../lib/src/filament/src/interface/engine.dart | 12 +++++++++++- .../native/include/c_api/APIBoundaryTypes.h | 8 ++++++++ thermion_dart/native/include/c_api/TEngine.h | 2 ++ thermion_dart/native/src/c_api/TEngine.cpp | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/thermion_dart/lib/src/filament/src/interface/engine.dart b/thermion_dart/lib/src/filament/src/interface/engine.dart index 396cd016..563655c2 100644 --- a/thermion_dart/lib/src/filament/src/interface/engine.dart +++ b/thermion_dart/lib/src/filament/src/interface/engine.dart @@ -25,4 +25,14 @@ enum Backend { 4 => NOOP, _ => throw ArgumentError("Unknown value for TBackend: $value"), }; -} \ No newline at end of file +} + +enum FeatureLevel { + FeatureLevel0(0), + FeatureLevel1(1), + FeatureLevel2(2), + FeatureLevel3(3); + + final int value; + const FeatureLevel(this.value); +} diff --git a/thermion_dart/native/include/c_api/APIBoundaryTypes.h b/thermion_dart/native/include/c_api/APIBoundaryTypes.h index f3cd9909..70e91863 100644 --- a/thermion_dart/native/include/c_api/APIBoundaryTypes.h +++ b/thermion_dart/native/include/c_api/APIBoundaryTypes.h @@ -100,6 +100,14 @@ extern "C" }; typedef enum TGizmoType TGizmoType; + enum TFeatureLevel { + FEATURE_LEVEL_0 = 0, + FEATURE_LEVEL_1 = 1, + FEATURE_LEVEL_2 = 2, + FEATURE_LEVEL_3 = 3 + }; + typedef enum TFeatureLevel TFeatureLevel; + enum TPrimitiveType { // don't change the enums values (made to match GL) PRIMITIVETYPE_POINTS = 0, //!< points diff --git a/thermion_dart/native/include/c_api/TEngine.h b/thermion_dart/native/include/c_api/TEngine.h index 00b3d827..a9f82765 100644 --- a/thermion_dart/native/include/c_api/TEngine.h +++ b/thermion_dart/native/include/c_api/TEngine.h @@ -28,6 +28,8 @@ EMSCRIPTEN_KEEPALIVE TEngine *Engine_create( bool disableHandleUseAfterFreeCheck ); +EMSCRIPTEN_KEEPALIVE TFeatureLevel Engine_getSupportedFeatureLevel(TEngine *tEngine); + EMSCRIPTEN_KEEPALIVE void Engine_destroy(TEngine *tEngine); EMSCRIPTEN_KEEPALIVE TRenderer *Engine_createRenderer(TEngine *tEngine); EMSCRIPTEN_KEEPALIVE TSwapChain *Engine_createSwapChain(TEngine *tEngine, void *window, uint64_t flags); diff --git a/thermion_dart/native/src/c_api/TEngine.cpp b/thermion_dart/native/src/c_api/TEngine.cpp index e54e4898..42314cb9 100644 --- a/thermion_dart/native/src/c_api/TEngine.cpp +++ b/thermion_dart/native/src/c_api/TEngine.cpp @@ -7,6 +7,7 @@ #include "c_api/TEngine.h" #include +#include #include #include #include @@ -74,6 +75,21 @@ namespace thermion return reinterpret_cast(engine); } + EMSCRIPTEN_KEEPALIVE TFeatureLevel Engine_getSupportedFeatureLevel(TEngine *tEngine) { + auto *engine = reinterpret_cast(tEngine); + auto featureLevel = engine->getSupportedFeatureLevel(); + switch(featureLevel) { + case filament::backend::FeatureLevel::FEATURE_LEVEL_0: + return FEATURE_LEVEL_0; + case filament::backend::FeatureLevel::FEATURE_LEVEL_1: + return FEATURE_LEVEL_1; + case filament::backend::FeatureLevel::FEATURE_LEVEL_2: + return FEATURE_LEVEL_2; + case filament::backend::FeatureLevel::FEATURE_LEVEL_3: + return FEATURE_LEVEL_3; + } + } + EMSCRIPTEN_KEEPALIVE void Engine_destroy(TEngine *tEngine) { auto *engine = reinterpret_cast(tEngine); Engine::destroy(engine);