Skip to content

feat: expose Engine backend and feature level to JS#337

Open
AndyCross wants to merge 1 commit intomargelo:mainfrom
AndyCross:feat/engine-backend-info
Open

feat: expose Engine backend and feature level to JS#337
AndyCross wants to merge 1 commit intomargelo:mainfrom
AndyCross:feat/engine-backend-info

Conversation

@AndyCross
Copy link

@AndyCross AndyCross commented Mar 11, 2026

We're using react-native-filament and needed a way to adapt rendering quality based on actual GPU capability. Right now there's no way to query anything about the graphics backend from JavaScript — you're stuck guessing from CPU benchmarks and RAM, which is particularly unreliable on budget Android devices where the GPU often punches well above the CPU's weight class.

Filament's C++ Engine already has getBackend(), getSupportedFeatureLevel(), and getActiveFeatureLevel() sitting right there as const getters. This PR just bridges them through the existing JSI layer so they're callable from JS.

getBackend() returns "opengl" / "vulkan" / "metal" — useful for diagnostics and knowing what you're actually running on.

getSupportedFeatureLevel() returns 0–3 mapping to OpenGL ES capability tiers. This turned out to be the signal we were after — a device at level 2+ has a meaningfully more capable GPU than one at 0–1, and it maps directly to what Filament can actually do on that hardware.

const { engine } = useFilamentContext();
const backend = engine.getBackend();                    // "opengl"
const featureLevel = engine.getSupportedFeatureLevel(); // 2

The implementation follows the existing EngineImplEngineWrapper → TypeScript pattern exactly, and reuses EnumMapper::convertEnumToJSUnion from RNFEngineBackendEnum.h for the backend conversion. Six files touched, 166 lines added, nothing removed. Added a docs/engine-info.md with the full API reference and usage examples.

Bridge three existing C++ Engine getters through the JSI layer:
- getBackend(): returns the resolved graphics backend ("opengl", "vulkan", "metal")
- getSupportedFeatureLevel(): returns the highest GPU feature level (0-3)
- getActiveFeatureLevel(): returns the currently active feature level

These are zero-cost const getters that already exist on filament::Engine
but were not accessible from JavaScript. They enable adaptive quality
decisions, device profiling, and telemetry without requiring additional
native modules or GL context creation.

See docs/engine-info.md for usage examples.
@AndyCross AndyCross force-pushed the feat/engine-backend-info branch from 35288a0 to a1b752d Compare March 11, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant