Repository navigation
GPU CPU Separation Plan
Audience: Programmers
Thread Context: Build-time / source-organization concern, not runtime. The split governs which translation units compile on which platform.
Platform/Backend Scope: This historical source-separation plan began as Windows (D3D11) vs. Linux/headless work. The goal is that pure-CPU logic compiles everywhere while backend-specific code is isolated into per-platform translation units. Current backend implementation and release-support status is called out separately below.
SparkEngine has a D3D11-primary rendering backend with Linux support via Core/Platform.h stubs. To keep CPU-portable code compiling on Linux/headless builds, GPU-heavy source files were split along the CPU/GPU boundary: a shared CPU .cpp plus platform-specific implementation files. This plan tracked the remaining work to complete that separation across the engine.
A naming note: the original plan proposed *GPU.cpp suffixes for the extracted GPU code. The implementation instead settled on per-platform suffixes — *Windows.cpp (D3D11) and *Linux.cpp (CPU stub) — which more directly expresses the three-way split the plan called for.
Overall: Substantially Completed (Phases 1-2), Partial (Phases 3-4); backend breadth remains experimental and uncertified.
| Phase | Scope | Status | Evidence |
|---|---|---|---|
| 1 | Complete the 4 deferred file splits | Completed |
AssetTypesWindows.cpp + AssetTypesLinux.cpp, MaterialSystemWindows.cpp + MaterialSystemLinux.cpp, PBRMaterialLightingWindows.cpp + PBRMaterialLightingLinux.cpp, GPUParticleSystemWindows.cpp + GPUParticleSystemLinux.cpp all exist under SparkEngine/Source/Graphics/
|
| 2 | Unguard CPU-portable headers | Likely Completed / N/A | Earlier splits (Foliage, PostProcessing, TextureSystem, UpscalingSystem) now ship as *Windows.cpp companions; portable headers compile on Linux. Not separately re-audited line-by-line. |
| 3 | Wire 6 lifecycle-only systems to the GPU pipeline | Partial |
BVHAccelerator::FrustumQuery is now called from SceneRenderer.cpp:132. GTAO, VCT (TraceDiffuse/TraceSpecular), ShaderVariantSystem::RequestVariant, and the denoiser remain documented as not called from any render pass (see their header comments). |
| 4 | RHI backend parity (Vulkan/OpenGL/D3D12/Metal) | Partial / Uncertified |
RHIFactory has concrete creation paths for D3D12, Vulkan, OpenGL, and Metal behind platform/build guards, but those implementations remain experimental and outside stable-v1; parity and release evidence are incomplete. RHIBridge can force or fall back to NullRHIDevice, while the current Windows and SparkServer headless hosts still pass a null graphics service instead of instantiating that bridge/device (HEAD-220). |
The earlier-completed splits described in the original "Current State" section (FoliageRenderer, FoliageImpostorBaker, PostProcessingPipeline, TextureSystem, UpscalingSystem) are confirmed present, now as *Windows.cpp companion files rather than *GPU.cpp.
The four files used a nested dual-guard pattern (#ifdef SPARK_PLATFORM_WINDOWS … #else … #endif) where both the Windows D3D11 implementation and the Linux CPU stub lived in one file with diverging includes. The fix was a three-way split: shared CPU helpers in the original .cpp, the Windows block extracted to *Windows.cpp, the Linux block to *Linux.cpp.
| File | Status |
|---|---|
AssetTypes.cpp → AssetTypesWindows.cpp / AssetTypesLinux.cpp
|
Done |
MaterialSystem.cpp → MaterialSystemWindows.cpp / MaterialSystemLinux.cpp
|
Done |
PBRMaterialLighting.cpp → PBRMaterialLightingWindows.cpp / PBRMaterialLightingLinux.cpp
|
Done |
GPUParticleSystem.cpp → GPUParticleSystemWindows.cpp / GPUParticleSystemLinux.cpp
|
Done |
The plan flagged headers whose #ifdef SPARK_PLATFORM_WINDOWS guards were wrapping pure-CPU logic (enums, sort keys) that should compile everywhere — e.g. DynamicQualityTypes.h, TemporalEffectsTypes.h, DrawSortKey.h. Correct guards (D3D11 ComPtrs in FoliageRenderer.h, PostProcessingPipeline.h) were to stay. With the Phase 1 splits landed and Linux builds passing, this work is effectively folded in; a fresh line-by-line audit was not separately confirmed.
Six systems were "lifecycle-only" — initialized but never producing GPU output:
| System | Original Gap | Status (2026-06-08) |
|---|---|---|
| BVHAccelerator |
FrustumQuery never called |
Wired — called from SceneRenderer.cpp cull pass |
| GTAOEffect |
ComputeGTAO never dispatched |
Not wired (header still notes GPU path uncalled) |
| VCTSystem |
TraceDiffuse/TraceSpecular never called |
Not wired (VoxelConeTracing.h notes uncalled) |
| ShaderVariantSystem |
RequestVariant never called |
Not wired (ShaderVariantSystem.h notes uncalled) |
| SoftwareDenoiser |
Denoise never called |
Not wired (DenoiserInterface.h notes uncalled) |
| NoiseGraph |
Evaluate never called |
Not separately confirmed |
The original priority order put BVHAccelerator → SceneRenderer first; that is the one that landed.
RHIFactory now contains concrete device-creation paths for D3D11, D3D12, Vulkan, OpenGL, and Metal when their platform/build guards are enabled. Their maturity differs: D3D11 is the primary stable-v1 implementation path, while D3D12, Vulkan, OpenGL, and Metal remain experimental, outside the profile, and lack parity/release evidence.
RHIBridge::Initialize() can explicitly select NullRHIDevice for a null window and can fall back to it after GPU backend failures. That bridge-level behavior is not the same as end-to-end headless host integration: SparkEngineWindowsHeadless.cpp and SparkServer/src/ServerApplication.cpp currently construct EngineContext with null graphics and input services, so they bypass RHIBridge and do not instantiate NullRHIDevice. Packaged Windows/server headless certification therefore remains open under HEAD-220.
The per-platform split remains the enabler for backend-specific companions such as *Vulkan.cpp or *OpenGL.cpp alongside existing *Windows.cpp, with shared CPU logic kept in the unsuffixed .cpp and CMake selecting compiled implementations.
cmake --preset linux-gcc-release && cmake --build build --config Releasecd build && ctest --output-on-failure --no-tests=errortools/validate-all.sh --warn-only-
clang-format -ion modified files
-
Original entry date: 2026-04-12 (
gpu-cpu-separation-plan-2026-04-12.md, type: Plan) - Verified against codebase 2026-08-28.
- Status bullets:
-
Phase 1 Completed — all four deferred files now have
*Windows.cpp/*Linux.cppcompanions (naming differs from the plan's*GPU.cppproposal). -
Phase 3 Partial — only
BVHAccelerator::FrustumQueryis wired in (SceneRenderer.cpp:132); GTAO/VCT/ShaderVariant/Denoiser headers still self-document as uncalled. -
Phase 4 Partial / Uncertified — guarded implementations exist for D3D12, Vulkan, OpenGL, and Metal but remain experimental and outside
stable-v1;RHIBridgehas aNullRHIDevicepath, while the current Windows/server headless hosts bypass it with null graphics services (HEAD-220).
-
Phase 1 Completed — all four deferred files now have
- Jolt Physics Integration
- Wine Role and Fallback Tiers — NullRHIDevice / software-render tiers
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