How the port works
The pieces
- The game: summers-aaron/halo-3 is a decompilation of Halo 3 for the Xbox 360, rebuilt as C++ with a PC port layer: a Xenos (Xbox 360 GPU) emulation layer on top of Vulkan or Direct3D 12, its own D3D9-style device, audio and input. Its shaders are the game’s original Xbox 360 microcode, translated ahead of time into a shader pack.
- ARM64 Linux:
tools/patch_arm64.pychanges the upstream tree so it builds and runs as an AArch64 Linux program against glibc 2.31, the oldest C library among the H700 firmware. It covers:- PowerPC memory barriers (lwsync, eieio) as ARM
dmb ish; - the Microsoft x64 calling convention, used by the port layer, on ARM;
- a low-4 GB allocator for the game’s 32-bit pointers that works on the handheld’s 4.9 kernel;
- NEON in place of the port layer’s SSE code;
- the handheld detail switches (render tier, detail scale, motion blur, particles);
- fixes for crashes found along the way.
- PowerPC memory barriers (lwsync, eieio) as ARM
- OpenGL ES 3.2: the H700’s Mali driver (Arm’s r20p0 blob) has no Vulkan entry points, so
src/gles_backend.cppis a third backend behind the upstream renderer’s backend interface (gpu_backend.h), beside Vulkan and Direct3D- The Xenos layer above it is unchanged: EDRAM emulation, resolves, the texture cache, constant blocks, vertex fetch.
- Shaders:
tools/patch_gles_shaders.pyadds a GLSL ES emitter to the upstream shader translator. Every Xbox 360 shader becomes a GLSL ES 3.20 module in a pack. On the handheld the backend links them into programs and keeps the Mali’s program binaries in a cache, so each program is compiled once. A program list records what a level needs, and a warm-up compiles it before play.
What makes it fast enough (so far)
- Vertex specialisation: each vertex shader is compiled against the draw’s vertex layout (
XE_VE_*constants), so the compiler removes the run-time decoding of formats, endianness and strides. - The opaque variant: shaders compiled without the alpha test’s
discardwhere the draw does not alpha-test, so the Mali can kill hidden fragments early. - The zero rule: the Xbox 360 treats 0 × anything as 0. The translated shaders imitate that only where the picture needs it (post-processing); material shaders use plain multiplies.
- Half precision in fragment shaders, with a NaN guard on the outputs of shaders without the zero rule.
- No CPU stalls on the driver:
- the exposure readback uses the last finished frame;
- resolve copies are small render passes;
- framebuffers are cached per texture;
- optionally, texture renaming for copies (
HALO3_GLES_RENAME).
- The game’s own scalability: Halo 3 has detail rows for 1-4 split-screen players. The handheld uses the 4-player row and scales its fade and LOD distances further.
- 480x270 internal resolution, scaled to the screen.
Tools
tools/device/: on-handheld scripts and helpers:- batch runs (
h3batch.sh,h3next.sh); - a Mali hardware counter reader (
mali_hwcnt.c); - a sampling CPU profiler (
cpuprof.c, reported bytools/cpuprof_report.py).
- batch runs (
tools/pc_gles_run.sh: runs the x86-64 build with the GLES renderer on Mesa’s software rasteriser (llvmpipe), to check pictures and shaders on a PC.tools/glsl_check/: compiles the pack’s modules with Mesa and with the Mali Offline Compiler (malioc) for cycle counts.
The game data, the translated shader pack and the program cache are not in this repository.