Repository navigation
D3D11 Backend
DirectX 11 is SparkEngine's primary Windows implementation and the renderer candidate in the blocked, uncertified stable-v1 Windows 11 x64 profile. Auto-selection prefers it on Windows when compiled in. The implementation contains the major rendering paths described below, but their stable-v1 certification gates remain open; this page does not claim production or known-stable status.
-
Namespace:
Spark::RHI::D3D11 -
Files:
Graphics/RHI/D3D11/D3D11Device.{h,cpp}(~360 LOC header) -
Guard:
#ifdef _WIN32— compiled only on Windows builds. -
Links against:
d3d11.dll,dxgi.dll,d3dcompiler_47.dll,dxguid.lib(automatic via MSVC#pragma comment). - Feature level: 11_0 (Shader Model 5.0) is the hard floor; 11_1 is preferred. Device creation fails on adapters below 11_0 instead of degrading.
| Class | Purpose | RHI interface |
|---|---|---|
D3D11Device |
Adapter + device + immediate context owner | IRHIDevice |
D3D11Buffer |
GPU buffer backed by ID3D11Buffer
|
IRHIBuffer |
D3D11Texture |
1D/2D/3D/Cube texture + SRV/RTV/DSV views | IRHITexture |
D3D11Shader |
Any shader stage + compiled bytecode | IRHIShader |
D3D11Sampler |
Sampler state | IRHISampler |
D3D11PipelineState |
Aggregate rasterizer / depth / blend / VS+PS | IRHIPipelineState |
D3D11SwapChain |
DXGI 1.2+ flip-model swap chain | IRHISwapChain |
D3D11CommandList |
Immediate-context translation of RHI calls; deferred lists record via FinishCommandList and replay on ExecuteCommandList
|
IRHICommandList |
Resources use Microsoft::WRL::ComPtr (RAII for COM objects). No raw AddRef / Release calls in user code.
Each D3D11Device owns a TransientBufferAllocator used for per-frame CPU-visible vertex/index data — debug draw, particle batches, and UI geometry all use it instead of allocating fresh buffers every frame. The allocator resets on swap-chain present.
-
Debug layer — auto-enabled on Debug builds (
D3D11_CREATE_DEVICE_DEBUG+ info-queue breakpoints). -
WARP fallback — if no hardware adapter matches, the engine retries with
D3D_DRIVER_TYPE_WARP; see RHI Abstraction Layer for the broader fallback chain.RHIBridge::Initializeno longer degrades a windowed request to NullRHI unlessallowHeadlessFallbackis passed. -
Structured / indirect buffers — created with the matching
D3D11_RESOURCE_MISC_*flags plus SRV/UAV views; noIRHICommandListoverload binds anIRHIBufferas a shader resource yet. -
Deferred deletion queue —
RHI/DeferredDeletionQueue.his header-only with test coverage (Tests/TestDeferredDeletionReal.cpp) but no production caller:D3D11Deviceholds no such member and no backend callsEnqueue/ProcessQueue(D3D12 has its own fence-based queue). D3D11 is immediate-mode, so frame-delayed deletion is not required there. -
Tearing / flip-discard — swap chain opts into
DXGI_SWAP_EFFECT_FLIP_DISCARDandDXGI_FEATURE_PRESENT_ALLOW_TEARINGwhen the adapter reports support. -
MSAA / sRGB / HDR formats — supported; per-texture MSAA sample count is validated via
CheckMultisampleQualityLevels.
D3D11Device::Initialize calls IDXGIFactory1::EnumAdapters1, picks the one with the largest dedicated video memory, and records:
caps.maxTextureSize // 16384 on FL11, 2048 on FL10
caps.computeShaderSupport // true on FL10+
caps.tessellationSupport // true on FL11+
caps.maxMSAASamples // 1/2/4/8 based on format checksThese land on IRHIDevice::GetCapabilities() and feed the engine's feature gates (e.g. TAA disables itself if MSAA > 1 is forced elsewhere).
Shaders compile through D3DCompile (d3dcompiler_47.dll). Entry points: vs_5_0, ps_5_0, cs_5_0, etc. For the offline shader cook path, see Shader Pipeline.
// RHIFactory.cpp
case GraphicsBackend::D3D11:
device = std::make_unique<D3D11::D3D11Device>();
break;Selected automatically by RHIFactory::GetRecommendedBackend() on Windows.
- No bindless — binding model is CBV / SRV / UAV slots. Use D3D12 if your workload needs descriptor-heap bindless.
- No mesh shaders — requires D3D12 + SM 6.5.
- No DXR — ray tracing requires D3D12. Hybrid Ray Tracing falls back to screen-space techniques on D3D11.
- No timeline semaphores — synchronization is fence-based.
- RHI Abstraction Layer — common interface every backend implements.
- D3D12 Backend — modern low-level alternative on Windows.
- Vulkan Backend — cross-platform equivalent.
- Render Graph — declarative pipeline that runs on top of any backend.
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