Repository navigation
Metal Backend
Release boundary: This page documents an experimental implementation outside the blocked and uncertified
stable-v1product scope (Windows 11 x64/MSVC v143 with D3D11 or Windows NullRHI and C++ modules). It is not a supported or release-certified backend.
Experimental macOS backend using Apple's Metal API directly (not via MoltenVK). Current source contains Objective-C++ device, interop, and texture-readback implementations; it remains partial, blocked, and outside stable-v1.
-
Namespace:
Spark::RHI::Metal -
Source:
Graphics/RHI/Metal/MetalDevice.{h,mm},MetalInterop.{h,mm}, andMetalTextureReadback.{h,mm}. -
Guard:
#ifdef __APPLE__ && ENABLE_METAL -
Language: C++/Objective-C++ (
.mm). The header is pure C++ with ARC-bridged handles. - Host status: the macOS source/build path is experimental; no qualified OS/hardware support matrix or release certification exists.
| Class | Purpose | RHI interface |
|---|---|---|
MetalDevice |
id<MTLDevice> owner + command queue |
IRHIDevice |
MetalBuffer |
id<MTLBuffer> — shared / managed / private storage |
IRHIBuffer |
MetalTexture |
id<MTLTexture> with optional MTLPixelFormat reinterpretation |
IRHITexture |
MetalShader |
id<MTLFunction> from MTLLibrary
|
IRHIShader |
MetalSampler |
id<MTLSamplerState> |
IRHISampler |
MetalPipelineState |
id<MTLRenderPipelineState> / MTLComputePipelineState
|
IRHIPipelineState |
MetalSwapChain |
CAMetalLayer + MTKView for presentation |
IRHISwapChain |
MetalCommandList |
id<MTLCommandBuffer> + MTLRenderCommandEncoder
|
IRHICommandList |
The header defines ObjCHandle<T> — an RAII wrapper around id<T> that replaces Apple's __strong / __weak with explicit Reset() semantics. This keeps the C++ side clean of Objective-C retain/release details while still participating in ARC.
- Argument buffers — Metal's equivalent of descriptor tables / bindless.
- Tile shaders — tile-based deferred rendering hooks (Apple silicon).
- MetalFX upscaling — integrates with Upscaling System once the base backend is live.
-
MSL codegen — shader pipeline extension to emit MSL from HLSL via
dxc+SPIRV-Cross.
// RHIFactory.cpp
case GraphicsBackend::Metal:
device = Metal::CreateDevice();
break;When compiled, the factory can select Metal and call Metal::CreateDevice(). That construction path is implementation evidence only; it does not establish a macOS fallback, parity, support, or stable-v1 certification. Runtime retries are owned by RHIBridge.
- Implemented, experimental: Objective-C++ device, interop, and synchronous texture-readback paths.
- Blocked: backend/shader/pass parity, resource-lifetime, golden-scene, performance, driver, and packaged-macOS proof.
- Planned: full ray-tracing pipeline integration, argument buffers, tile shaders, MetalFX.
See PROJECT_STATUS.md for the authoritative maturity table.
- RHI Abstraction Layer
- Vulkan Backend — experimental development path via MoltenVK.
- Upscaling System — MetalFX integration target.
Published from 2b03dc797148. Edit the canonical source in wiki/.
- Documentation
- Docs route
- Wiki index
- Guides
- Tutorials
- Samples
- Examples
- API Reference
- API route
- Reference
- Build Guide
- Dependencies
- FAQ
- Changelog
- Roadmap
- Contributing
- Code of Conduct
- Home
- FAQ
- Getting Started
- Quick-Start Tutorial
- Making Your First Game
- Making Your First Multiplayer Game
- Artist Workflow Guide
- Editor Walkthrough
- Migration Guide
- How SparkEngine Works
- Architecture Overview
- Engine Architecture Flowchart
- Creating a Game Module
- Game Modules (catalog)
- Entity Component System
- Rendering and Graphics
- Physics
- Cloth Simulation
- Audio
- Input System
- Camera System
- Scripting with AngelScript
- Visual Scripting
- AI and Navigation
- Animation
- 2D Systems
- Networking
- Dedicated Server
- Multiplayer Quick Start
- Area Server Architecture
- Scene Management
- Large World Support
- Collaborative Editing
- Coroutine System
- Event System
- Event Response System
- Job System
- UI System
- UI Layout Extensions
- Localization
- Dialogue System
- Destruction System
- Replay System
- Achievement System
- Loading System
- Mod System
- Content Delivery
- Tween System
- Memory Integrity
- Gameplay Systems
- Terrain and Procedural Generation
- Save System
- Persistence System
- Day Night Cycle and Weather
- Cinematic Sequencer
- Runtime Prefabs
- SparkEditor
- Editor Tutorials
- SparkConsole
- SparkDaemon
- Shader Pipeline
- Asset Pipeline
- Asset Validation
- Asset Migration
- Game Packaging
- Online Services
- DataTable System
- Loot and Crafting System
- CSG System
- Font System
- Timer Manager
- Movie Render Pipeline
- HLOD and World Partition
- Remote Debug System
- Selection Manager
- Asset Dependency Graph
- Editor Automation
- File Watcher
- Project Templates
- System Requirements
- VR Support
- Mobile Platform
- Accessibility
- Platform Input
- Platform Certification
- Cross-Compilation: Wine Testing
- RHI Abstraction Layer
- D3D11 Backend
- D3D12 Backend
- Vulkan Backend
- OpenGL Backend
- Metal Backend
- DXR Raytracing
- Hybrid Ray Tracing
- Upscaling (DLSS/FSR)
- Render Graph
- Shader Graph
- GPU Particles
- GPU-Driven Rendering
- Volumetric Fog
- Volumetric Clouds
- Global Illumination
- Virtual Texturing
- Water Rendering
- Clustered Lighting
- Material System
- Post-Processing
- Shadow System
- Particle System
- Decal System
- Sky and Atmosphere
- Foliage System
- Mesh Shaders
- Neural Rendering
- Configuration Reference
- Performance Tips
- Benchmark Framework
- Threading Model
- Fuzz Policy and Parser Security
- Memory Safety
- Memory Management Patterns
- Build System and CMake Modules
- Profiler and Debugging
- Performance Profiling Guide
- Telemetry System
- Crash Reporting
- Golden Image Testing
- Utilities
- Testing
- Fuzz Policy and Parser Security
- Codebase Statistics
- Codebase Health
- Error Handling Patterns
- Hot Reload Overview
- Troubleshooting
- Contributing
- Workflow Patterns
- Build Optimizations
- CI Reproducible Builds
- GitHub API and PR Checks
- Git Rebase Conflicts
- Clang-Format
- Code Quality Violations
- AI Bloat Pattern
- MinGW + Wine Cross-Compilation
- Live Editor Testing
- Engine & Renderer Landscape
- DuetOS Portability Catalog
- Five-Engine Analysis
- Eleven-Engine Analysis
- ThorVG / Unity Graphics Analysis
- Advanced Techniques Catalog
- Third-Party Library Evaluation
- Engine Viability Evaluation
- Engine Feature Recommendations
- Project Recommendations
- Mac Compatibility Analysis
- Codebase Observations
- Codebase Bloat Audit
- Test Suite Audit
- Documentation Coverage Audit
- ThirdParty Dependencies Audit
- Load Test Baseline
- Gameplay Systems Status
- SparkGame Module Status
- Stub and Abandoned Features
- Memory Integrity System
- Memory Safety Evaluation
- Hardware Acceleration Systems
- Jolt Physics Integration
- GPU/CPU Separation Plan
- Daemon Services Architecture
- Reflection & Polymorphism Refactoring Plan
- SparkBuild In-Tree
- Wine No-JobSystem Breakthrough
- Wine Role and Fallback Tiers