Repository navigation
DuetOS Portability Catalog
Audience: Programmers | Mixed
Thread Context: N/A (research/reference)
Platform/Backend Scope: Cross-project reference
DuetOS (a sibling project: a from-scratch C++23/Rust x86_64 operating system with a Win32/PE subsystem) shares an author and a coding lineage with SparkEngine. This page catalogs DuetOS components that were evaluated for reuse in SparkEngine, with an explicit why / why-not verdict for each.
Headline conclusion: Very little should be literally ported. DuetOS code is freestanding kernel code — it deliberately avoids the C++ standard library, libc, exceptions, and the heap-until-late, and reimplements primitives that SparkEngine already gets for free from std:: and its existing mature subsystems (EnTT, Jolt, the engine JobSystem, Logger, Profiler, SPARK_HAS_EXPECTED/std::expected). The real value DuetOS offers SparkEngine is architectural reference (its wiki/docs discipline and a couple of ergonomic idioms), not drop-in modules.
This catalog exists so the evaluation is recorded and we don't re-litigate it each time someone notices the overlap.
Each entry lists the DuetOS source location, what it does, and a verdict:
- Adopt — genuinely additive; worth porting/adapting.
-
Reference only — study the design, but SparkEngine should use its own/
std::version. - Skip — kernel-specific or fully duplicative; no action.
| Component | DuetOS path | What it is | Verdict | Why / why-not |
|---|---|---|---|---|
Result<T,E> |
kernel/util/result.h |
Exception-free result type with RESULT_TRY macros |
Skip | SparkEngine already standardizes on C++23 std::expected via SPARK_HAS_EXPECTED (see Core/Platform.h). Introducing a second result type would fragment error handling and create conversion friction. |
ScopeGuard / DUETOS_DEFER
|
kernel/util/defer.h |
RAII scope-exit cleanup (Go-style defer) |
Reference only | A legitimately nice ergonomic. But it's ~20 lines and trivially re-expressible; if the engine wants defer, write a small Spark::ScopeGuard in Utils/ rather than importing DuetOS's. Low priority — RAII wrappers already cover most cases. |
| Saturating arithmetic | kernel/util/saturating.h |
Clamp-instead-of-wrap add/sub/mul | Skip | Niche; std:: + manual clamps suffice where needed. No current call site demand. |
String ops (MemcpyChecked, etc.) |
kernel/util/string.h |
Freestanding, bounds-checked mem/str ops | Skip | Exists only because the kernel has no libc. SparkEngine has full <cstring>/std::string/std::span. |
| Unicode width/case-fold | kernel/util/unicode.h |
UTF-8 helpers | Skip | The editor/UI already handle text via ImGui + existing localization; no gap. |
| Component | DuetOS path | What it is | Verdict | Why / why-not |
|---|---|---|---|---|
| Slab / object-pool allocator | kernel/mm/slab.h |
Fixed-size object cache, O(1) alloc/free | Reference only | The idea (per-type pools for particles, physics bodies, audio voices) is sound, but the kernel slab is coupled to the kernel page allocator. If profiling shows allocator pressure in a hot pool, write an engine-native Spark::ObjectPool<T> over std::pmr rather than port kernel code. No current measured need. |
| KHeap (coalescing freelist) | kernel/mm/kheap.h |
General-purpose heap | Skip | SparkEngine uses the platform allocator + std::pmr; replacing the global allocator is out of scope and risky. |
| Frame/zone allocators |
kernel/mm/frame_allocator.h, zone.cpp
|
Physical-page / DMA-zone allocators | Skip | Kernel-only concepts (physical memory, IOMMU zones). Not applicable. |
| Poison allocator | kernel/mm/poison_alloc.h |
Fills freed memory with sentinels | Skip | ASan/UBSan (already in CI) cover use-after-free far better on the engine's platforms. |
| Component | DuetOS path | What it is | Verdict | Why / why-not |
|---|---|---|---|---|
| Spinlock / adaptive mutex / rwlock / seqlock | kernel/sync/* |
Hand-rolled sync primitives with IRQ save/restore | Skip | These exist because a kernel can't call std::mutex. SparkEngine has std::mutex/std::shared_mutex/std::atomic and documented thread-safety rules per subsystem. Hand-rolled spinlocks in user space are usually a pessimization. |
| RCU | kernel/sync/rcu.h |
Read-copy-update with grace periods | Reference only | Interesting for lock-free read-mostly engine data (e.g. live config), but RCU's grace-period model is tied to the scheduler. If needed, prefer std::atomic<shared_ptr> or a hazard-pointer lib. |
| Lockdep (lock-order auditor) | kernel/sync/lockdep.h |
Runtime deadlock-cycle detector | Reference only | Genuinely useful concept for debug builds. But TSan (already a CI job) catches lock-order inversions on the engine's platforms without bespoke instrumentation. |
| WorkPool | kernel/sched/workpool.h |
N-worker bounded-FIFO thread pool | Skip | SparkEngine already has a JobSystem (see Job-System wiki page) that is integrated with the frame loop and Wine fallbacks. A second pool would compete with it. |
| Component | DuetOS path | What it is | Verdict | Why / why-not |
|---|---|---|---|---|
| DEFLATE / GZIP / ZIP | kernel/util/{deflate,gzip,zip}.* |
Decompression | Skip | SparkEngine already vendors miniz and zstd (see ThirdParty-Dependencies-Audit). |
| PNG / BMP / TGA / JPEG decode | kernel/util/{png,bmp,tga,jpeg}.* |
Read-only image loaders | Skip | SparkEngine uses stb_image (+ tinyexr, Basis transcoder). Duplicative. |
| Base64 / CRC32 / Adler32 | kernel/util/{base64,crc32,adler32}.* |
Encoding/checksums | Skip | Trivially available; miniz/zstd already provide CRC. |
| Crypto (AES/SHA/RSA/X.509) | kernel/crypto/* |
Full crypto suite | Skip | An engine doesn't need a kernel-grade crypto stack; if save-file signing is ever wanted, use a maintained lib, not kernel code. |
| Component | DuetOS path | What it is | Verdict | Why / why-not |
|---|---|---|---|---|
| Kernel logging | kernel/log/ |
Severity/component-tagged async ring-buffer logging | Skip | SparkEngine has Utils/Logger (sinks, file rotation) + SimpleConsole IPC. No gap. |
| Cleanroom trace ring buffer | kernel/diag/ |
Low-overhead (timestamp,event) capture |
Reference only | The pattern is a nice complement to the existing Profiler for frame-spike capture, but the engine Profiler + Tracy-style tooling already cover this space. |
The durable wins are process and documentation, not code:
-
The wiki discipline — DuetOS's
_Template.mdaudience/maturity header,_Sidebar.mdmaster TOC, anddocs/sync-wiki.shAUTO-block synchronization are the model this very migration adopts. SparkEngine already had a comparable wiki; this effort brings the.claude/knowledgecontent fully into it. -
// GAP:/// STUB:marker conventions — DuetOS distinguishes "not implemented yet" from "deliberately partial." SparkEngine could adopt the same two-marker convention to make Stub-and-Abandoned-Features auto-discoverable. -
defer/ScopeGuardergonomic — the one code idiom worth (re)writing natively if a contributor wants it.
- Third-Party Library Evaluation
- Engine & Renderer Landscape (deep external research)
- Advanced Techniques Catalog
- ThirdParty Dependencies Audit
-
Origin: Evaluation of
C:\Users\natew\source\repos\DuetOS(sibling OS project) against the SparkEngine codebase. - Compiled: 2026-06-08.
-
Note: Verdicts reflect SparkEngine's current mature state (full
std::, EnTT, Jolt, JobSystem, Logger/Profiler,std::expected). Revisit only if a specific, profiled gap appears that a DuetOS component uniquely fills.
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