Custom Backends
Filament’s backend abstraction layer provides a clean separation between the rendering engine and platform-specific graphics APIs. This architecture enables Filament to support multiple graphics backends while maintaining a unified API.Backend Architecture
Filament currently supports the following backends:- OpenGL 4.1+ (Linux, macOS, Windows)
- OpenGL ES 3.0+ (Android, iOS)
- Metal (macOS, iOS)
- Vulkan 1.0 (Android, Linux, macOS, Windows)
- WebGPU (Android, Linux, macOS, Windows)
- WebGL 2.0 (Browser)
filament/backend/include/backend/:
Platform Abstraction Layer
ThePlatform class abstracts backend creation and platform-specific operations:
Creating a Custom Platform
When implementing a custom platform, you can provide your ownPlatform subclass:
Platform object must outlive the Engine instance.
Driver Interface
TheDriver class defines the backend interface that all graphics backends must implement:
Command Stream Architecture
Filament uses a command stream pattern to batch rendering commands and execute them asynchronously on the render thread:How Commands Work
- Command Recording - The main thread records commands into a circular buffer
- Command Submission - Commands are submitted to the backend driver
- Command Execution - The render thread executes commands on the GPU
filament/backend/include/private/backend/CommandStream.h:
Backend Selection
Filament automatically selects the best backend for each platform:- macOS/iOS: Metal (default)
- Windows/Linux: Vulkan (default)
- Android: Vulkan or OpenGL ES
- Web: WebGL 2.0
Feature Levels
Backends support different feature levels based on platform capabilities:Shader Language Support
Different backends use different shader languages:| Backend | Shader Languages |
|---|---|
| OpenGL | GLSL/ESSL |
| Vulkan | SPIR-V |
| Metal | MSL, Metal Library |
| WebGPU | WGSL |
matc) generates shader code for all supported backends from a single material definition.
Backend-Specific Configuration
Metal Configuration
OpenGL Configuration
Shared Contexts
You can create an engine with a shared context for resource sharing:Platform-Specific Implementations
Filament provides platform-specific implementations:- OpenGLPlatform - Base class for OpenGL platforms
- VulkanPlatform - Vulkan platform abstraction
- MetalPlatform - Metal platform abstraction
Best Practices
- Use the default backend unless you have specific requirements
- Match feature levels to your target hardware capabilities
- Test on all target platforms as backends behave differently
- Handle backend creation failure gracefully
- Use shader variants to support multiple backends efficiently
Example: Backend Detection
See Also
- Performance Optimization - Backend-specific optimizations
- Threading Model - How commands are executed
- Building Filament - Platform build instructions