/handmade-zig

Learning Zig by following along with the Handmade Hero series of videos by Casey Muratori.

Primary LanguageZig

Handmade Zig

Learning Zig by following along with the Handmade Hero series of videos by Casey Muratori.

Assets

Graphical assets are not included as they are not created by me. They need to be added to the data/ directory manually. We currently expect the test, test2, and test3 directories of assets found in this location of the pre-order data: handmade_hero_legacy_art.zip/early_data.

Debugging

The included debugger config under .vscode/launch.json is compatible with the nvim-dap plugin in Neovim and the C/C++ extension in VS Code. Using Visual Studio with C/C++ tooling appears to give the most reliable results.

When running outside of an IDE, OutputDebugString messages can be viewed using DebugView.

Build options

  • Timing: use the -Dtiming flag when building to enable printing timing (ms/frame, fps and cycles/frame) to the debug output.

Analyzing generated assembly

The build is setup to emit the generated assembly code which can be used to analyze the code for bottlenecks using llvm-mca which is bundled with LLVM version 18+.

asm volatile("# LLVM-MCA-BEGIN ProcessPixel");
// Code to analyze.
// ...
asm volatile("# LLVM-MCA-END ProcessPixel");

Analyze the emitted assembly code:

llvm-mca .\zig-out\bin\handmade-dll.asm -bottleneck-analysis -o .\zig-out\bin\handmade-dll-mca.txt

Reference

Intel

AMD