How puddingcoke/gear-engine works
Purpose and entry points
Gear Engine is a Windows/Direct3D 12 graphics-and-compute engine that hides much D3D12 boilerplate behind a D3D11-like API while retaining explicit resource-state and command-list control. The primary reusable library is Engine/Engine.vcxproj; each demo is a separate executable. Typical application entry points are Demos/SampleProject/main.cpp, Demos/SampleProject/MyGame.h, and Demos/SampleProject/MyRenderTask.h.
Application lifecycle and execution modes
Applications initialize Gear, supply a Gear::Game implementation, and let the engine own the main lifecycle, window/input processing, updates, and rendering. Game is the application boundary; RenderTask is the command-recording boundary. Runtime modes include interactive window rendering, headless video rendering, and desktop-wallpaper rendering.
• Engine/Inc/Gear/Game.h
• Engine/Inc/Gear/Core/RenderEngine.h
• Engine/Inc/Gear/InitializationParam.h
D3D12 device, commands, and synchronization
The core runtime initializes the D3D12 device and records/submits graphics, compute, and video command lists. Command queues, fences, descriptor heaps, root signatures, and pipeline states are explicit engine subsystems rather than application-facing D3D12 calls. Render tasks can be created asynchronously and recorded independently; multi-thread recording is architecturally supported.
• Engine/Inc/Gear/Core/GraphicsDevice.h
• Engine/Inc/Gear/Core/D3D12Core/CommandQueue.h
• Engine/Src/Gear/Core/RenderThread.cpp
Bindless resources and automatic barriers
Resource views expose descriptor indices plus underlying-resource/subresource metadata. GraphicsContext consumes these pipeline-resource descriptors when constants, render targets, and shader resources are set; before draw/dispatch it resolves required states and flushes transitions. This is the central abstraction that makes high-level draw/dispatch calls manage D3D12 barriers automatically. Bindless binding requires Shader Model 6.6 ResourceDescriptorHeap.
• Engine/Inc/Gear/Core/GraphicsContext.h
• Engine/Inc/Gear/Resource/PipelineResourceDesc.h
• Engine/Src/Gear/Core/D3D12Core/ResourceStateTracker.cpp
Resource, shader, and pipeline construction
ResourceManager and resource/view classes create GPU buffers, textures, constant buffers, swap resources, upload/readback heaps, and render/depth views. Pipeline construction combines shader compilation, root signatures, and graphics/compute state through builder/helper APIs. HLSL is compiled at runtime through DXC; built-in shaders provide common fullscreen, post-process, primitive, SSR, and video conversion operations.
• Engine/Inc/Gear/Core/ResourceManager.h
• Engine/Inc/Gear/Core/PipelineStateBuilder.h
• Engine/Inc/Gear/Core/D3D12Core/DXCCompiler.h
Effects and reusable rendering stages
Effects are self-contained post-processing/rendering stages that own their shaders, PSOs, and resources behind a process()-style interface. Included stages cover bloom, FXAA, tone mapping, gamma/HDR handling, SSR, HBAO+, back-buffer blitting, and lat-long-to-cubemap conversion. Demos compose these with custom render tasks and shaders.
• Engine/Inc/Gear/Effect/EffectBase.h
• Engine/Src/Gear/Effect/BloomEffect.cpp
• Engine/Src/Gear/Effect/SSREffect.cpp
Demo workloads and external integration
The demos validate the engine across deferred PBR scenes, FFT ocean simulation, compute fluid simulation, particles, fractals, and wallpaper rendering. Representative compute ping-pong flows use SwapTexture/SwapBuffer; scene demos add model/material layers. The Windows-native stack includes D3D12/DXC, ImGui, DirectXTex/WIC/OpenEXR texture support, Assimp model import, NVIDIA HBAO+, FFmpeg, and NVENC/optional software video encoding.
• Demos/CrytekSponza/SceneRenderTask.h
• Demos/FluidSimulation/MyRenderTask.h
• Engine/Inc/Gear/Core/VideoEncoder/NVIDIAEncoder.h
Main entry points: GraphicsContext.h GraphicsContext · RenderEngine.h RenderEngine · MyRenderTask.h RenderTask · RenderThread.cpp Render thread
Components 18
Applications
- Sample application
Demos/SampleProject/main.cpp - Game implementation · Supplies application logic to the engine lifecycle.
Engine/Inc/Gear/Game.h - RenderTask · Application command-recording work unit.
Demos/SampleProject/MyRenderTask.h
Engine Runtime
- RenderEngine · Owns window, input, update, and rendering lifecycle.
Engine/Inc/Gear/Core/RenderEngine.h - Initialization parameters · Selects interactive, headless-video, or wallpaper operation.
Engine/Inc/Gear/InitializationParam.h - Render thread · Supports asynchronous, independently recorded render tasks.
Engine/Src/Gear/Core/RenderThread.cpp
Rendering Core
- GraphicsDevice · Initializes the native graphics device.
Engine/Inc/Gear/Core/GraphicsDevice.h - Command queues and fences · Submits graphics, compute, and video command lists.
Engine/Inc/Gear/Core/D3D12Core/CommandQueue.h - GraphicsContext · D3D11-like draw and dispatch API over explicit command lists.
Engine/Inc/Gear/Core/GraphicsContext.h - Pipeline resource descriptors · Carries descriptor indices and resource/subresource metadata.
Engine/Inc/Gear/Resource/PipelineResourceDesc.h - Resource state tracker · Resolves required states and flushes transitions before execution.
Engine/Src/Gear/Core/D3D12Core/ResourceStateTracker.cpp
Resources and Effects
- ResourceManager · Creates buffers, textures, views, swap resources, and transfer heaps.
Engine/Inc/Gear/Core/ResourceManager.h - Pipeline state builder · Combines shaders, root signatures, and graphics or compute state.
Engine/Inc/Gear/Core/PipelineStateBuilder.h - DXC compiler · Compiles shaders including SM 6.6 bindless access.
Engine/Inc/Gear/Core/D3D12Core/DXCCompiler.h - Effects library · Self-contained bloom, SSR, AA, tone-map, and conversion stages.
Engine/Inc/Gear/Effect/EffectBase.h
Workloads and Integration
- Graphics and compute demos · Includes deferred PBR, fluid, ocean, particles, fractals, and wallpaper.
Demos/FluidSimulation/MyRenderTask.h - Scene rendering demo · Representative deferred PBR scene integration.
Demos/CrytekSponza/SceneRenderTask.h - NVIDIA video encoder · Optional hardware video output for headless rendering.
Engine/Inc/Gear/Core/VideoEncoder/NVIDIAEncoder.h
Connections 22
- Sample application → Game implementation: implements
- Sample application → RenderTask: defines
- Game implementation → RenderEngine: runs in
- Initialization parameters → RenderEngine: configures modes
- RenderEngine → Render thread: schedules
- Render thread → RenderTask: records asynchronously
- RenderEngine → GraphicsDevice: initializes
- Render thread → GraphicsContext: creates recording context
- RenderTask → GraphicsContext: records draw and dispatch
- GraphicsContext → Pipeline resource descriptors: binds
- GraphicsContext → Resource state tracker: flushes transitions
- Resource state tracker → Command queues and fences: prepares command lists
- GraphicsContext → Command queues and fences: submits through
- ResourceManager → Pipeline resource descriptors: creates views
- Pipeline state builder → DXC compiler: compiles shaders with
- Pipeline state builder → GraphicsContext: provides PSOs
- Effects library → Pipeline state builder: owns PSOs
- Effects library → ResourceManager: owns resources
- Graphics and compute demos → RenderTask: custom tasks
- Graphics and compute demos → Effects library: composes
- Scene rendering demo → RenderTask: implements
- RenderEngine → NVIDIA video encoder: headless video output