Skip to content
Niffoxic

Vulpes Noctis: a game on my own CPU-rendered engine

A complete top-down action adventure where every pixel, light and shadow is computed by my own multithreaded CPU renderer. The GPU only shows the finished frame.

Type
Game + engine · C++20 · AVX2
Role
Solo: engine, rendering, tools, gameplay, story, level generation and tests
Dates
Oct–Nov 2025, rebuilt Nov 2026
Stack
C++20 · AVX2 · Multithreading · flecs (ECS) · Win32 · XAudio2 · Direct3D 11 (present only) · Google Test · CMake + vcpkg
Links
Play on itch.io ↗Demo on YouTube ↗Source on GitHub ↗
Vulpes Noctis: a game on my own CPU-rendered engine
A crowd fight at the torch-lit shrine. The sprites, lights, shadows and bloom are all drawn on the CPU.

A lit frame with 1,731 sprites and 49 shadow-casting lights renders in 1.54 ms on the CPU, about 10× faster than on one thread.

for a lit 640×360 frame: 1,731 sprites and 49 shadow-casting lights on 16 threads (about 650 FPS)
1.54 ms
faster than one thread on the same frame (15.24 to 1.54 ms), from the job system and AVX2
~10×
to render a frame in game, read off the F3 profiler mid-fight
0.9 ms
Google Test cases, all passing, including a 3-minute soak test with the real renderer
181

Overview

The constraint: a whole game in C++ with no game engine and no GPU rendering. The first version, PixelFox, was a four-week build. It worked, but ran at 55–68 FPS with about 40 enemies at 1280×720 and no lighting, had race conditions between its logic and render threads, and its test suite never compiled. I rebuilt the PixelFox engine around a tile-based renderer, a job system and AVX2, and turned the prototype into a finished game: Vulpes Noctis, a dark-fantasy action adventure with combo combat, a skill tree, branching dialogue and a two-phase boss. Every number here was measured on one machine, a 16-core Ryzen 9 9950X. The art is the free Ninja Adventure pack (CC0) by Pixel-boy and AAA, and the music and sound effects are AI-generated.

The 87-second demo, with captions and the game's music: dialogue, the skill tree, a crowd fight with the profiler open, lighting in the dark and the two-phase boss.

What I built

The engine: PixelFox, about 5,100 lines of C++20

  • Tile-based software renderer Sprites are binned into 64×40 screen tiles and each tile is drawn by one job, so a frame needs no locks and the output is identical on 1 or 16 threads, which a test checks.
  • Lighting on the CPU Normal-mapped point lights, soft 2D shadows from polar shadow maps, emissive sprites, bloom, ACES tonemapping, colour grading, vignette, ordered dither and an optional CRT filter.
  • AVX2 Blending and tonemapping in AVX2, chosen at run time by CPU detection, with a scalar fallback. On one thread it takes the tonemap, grade and dither pass from 4.9 to 1.85 ms (2.7×).
  • Job system One worker per physical core, an atomic work counter, and spin-then-sleep between passes.
  • Pipelined main loop The game ticks at a fixed 60 Hz while the previous frame renders on its own thread from a double-buffered draw list, with an exception-safe shutdown.
  • Audio, input and tools My own software mixer on XAudio2 (pan, pitch, loop points, fades and buses; WAV and OGG), tick-latched input with XInput gamepads and rebindable actions, a crash reporter (stack trace and minidump), a session log, the F3 profiler and frame recording for trailers.

The game: Vulpes Noctis, about 5,200 lines on flecs (ECS)

  • Combat A 3-hit combo with input buffering, a dash with i-frames, aimed spells, hit-stop and knockback.
  • Enemies AI state machines with a BFS flow field for pathing, elites, and a two-phase boss.
  • Progression and story A 15-skill tree, branching data-driven dialogue (36 nodes, 3 quests, 2 endings), a shop and potions.
  • Saves Versioned save files written atomically, and shrine checkpoints.

Tests

  • 181 Google Test cases Renderer determinism, AVX2 against scalar, the job system, input, the audio mixer, gameplay, save files, dialogue script integrity and a 3-minute soak test with the real renderer.

Results

6 figures
Vulpes Noctis · 0.9 ms renderOld PixelFox · 68 FPSOld PixelFox · 68 FPSVulpes Noctis · 0.9 ms render
FIG. 1Old PixelFox: 68 FPS at 1280×720 with no lighting. Vulpes Noctis: 0.9 ms to render a fully lit 480×270 frame, with the F3 profiler open. Different scenes and resolutions; drag the divider to compare.
ThreadsFrame, averageSlowest 1%FPS
1, scalar15.24 ms19.38 ms66
1, AVX212.42 ms15.65 ms81
44.78 ms5.23 ms209
82.49 ms2.75 ms401
16, one per core1.54 ms1.76 ms650
31, with SMT1.66 ms4.09 ms604
16, lighting off0.40 ms0.63 ms2,473
16, CRT filter at 1920×10802.13 ms2.53 ms469
FIG. 2The benchmark scene at 640×360 with full lighting, shadows and bloom: 1,731 sprites and 49 lights. Every row after the first uses AVX2. At 31 threads the average barely moves but the slowest frames get 2.3× worse, so the engine runs one worker per physical core.
Combat with spell bolts and torches: normal-mapped point lights, soft 2D shadows and bloom, all computed on the CPU.
FIG. 3Combat with spell bolts and torches: normal-mapped point lights, soft 2D shadows and bloom, all computed on the CPU.
The Ashborn boss fight in its second phase, with its rings of fire.
FIG. 4The Ashborn boss fight in its second phase, with its rings of fire.
Branching dialogue with portraits and choices, read from data: 36 nodes, 3 quests and 2 endings.
FIG. 5Branching dialogue with portraits and choices, read from data: 36 nodes, 3 quests and 2 endings.
The skill tree: 15 skills in 3 branches, here with the Blade and Arcane lines learned.
FIG. 6The skill tree: 15 skills in 3 branches, here with the Blade and Arcane lines learned.

Hard parts

  • More threads made it worse: on 31 threads, using SMT, the average frame only rose from 1.54 to 1.66 ms, but the slowest 1% went from 1.76 to 4.09 ms, 2.3× worse. So the engine runs one worker per physical core.
  • Making it thread-safe: the old logic and render threads had race conditions. The rebuild hands the renderer a double-buffered draw list from a fixed 60 Hz tick, and splits each frame by screen tile so no two jobs write the same pixel.
  • Making it testable: the old test suite never compiled. Alongside the new 181 cases, an audit of the old code found 13 bugs, including use-after-free and container bugs, all fixed.

Limits

What it doesn't do yet
  • Windows only: Win32 for the window, XAudio2 for sound and Direct3D 11 to show the finished frame.
  • The game renders at 480×270 and scales up by whole numbers (2×, 3× or 4×). The benchmark frame is 640×360; the CRT filter at 1920×1080 output takes a frame to 2.13 ms.
  • All the numbers come from one machine, a 16-core Ryzen 9 9950X.

Credits. Art: the Ninja Adventure asset pack by Pixel-boy and AAA (CC0), not my own work. Music and sound effects: AI-generated, locally. Libraries: flecs (ECS), GoogleTest, nlohmann-json and stb_vorbis.

Harsh Dubey

Harsh Dubey

Graphics and game programmer. MSc Games Engineering (Distinction), University of Warwick.

About me