tursodatabase/turso-vdbe-doom-example — explained in plain English
Analysis updated 2026-05-18
See a real world demo of how a database's internal bytecode virtual machine can run arbitrary compiled programs, not just SQL.
Compile a C program to VDBE bytecode with vdbecc and load it into Turso as a runnable statement.
Run the Doom demo natively in a terminal or play it live in a browser on a canvas.
| tursodatabase/turso-vdbe-doom-example | nonanti/narwhal | reekta92/pinstar | |
|---|---|---|---|
| Stars | 28 | 28 | 28 |
| Language | Rust | Rust | Rust |
| Setup difficulty | hard | easy | easy |
| Complexity | 5/5 | 3/5 | 2/5 |
| Audience | developer | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
Browser demo needs a WASI SDK build and cross-origin isolation headers for SharedArrayBuffer.
This project runs the classic video game Doom inside Turso, a SQLite compatible database, as a demonstration of how general purpose a database's internal bytecode engine can be. Turso, like SQLite, works by compiling SQL queries into its own bytecode, called VDBE, and then running that bytecode on a small virtual machine built into the database. Normally SQL is the only thing that ever gets compiled down to that bytecode. This repository proves the virtual machine itself is powerful enough to run something completely unrelated to databases: it compiles the real id Software Doom game engine to VDBE bytecode and lets Turso's stock engine execute it, frame by frame, with no emulator and no reimplementation of Doom. To make this work, the authors built a small compiler called vdbecc that takes LLVM IR, an intermediate format produced by the clang compiler, and translates it into VDBE bytecode. Doom's C source is compiled to LLVM IR ahead of time, then vdbecc lowers that IR into a VDBE program that Turso can load and run like any prepared SQL statement. Doom's entire memory lives inside a single binary blob stored in one row of one table, and each video frame the game produces is streamed out as a result row, the same way a database would stream out query results. The game is driven by repeatedly stepping that statement, similar to pulling the next row from a cursor, and keyboard input is sent back in through statement bind parameters. Because Turso does not normally let you load a program you compiled yourself, this project is a small fork of Turso that adds just enough of a loading path to accept a vdbecc built program, using the database's existing byte access and blob read and write functions rather than any Doom specific engine code. The repository includes native and browser ways to run it, plus a test suite that checks vdbecc's output against a native compiled build for correctness. The database engine itself is unmodified apart from that loading addition, and full credit for it goes to the upstream Turso project.
A demo that runs the game Doom inside Turso, a SQLite compatible database, by compiling Doom to the database's own bytecode instead of SQL.
Mainly Rust. The stack also includes Rust, Turso, LLVM IR.
Setup difficulty is rated hard, with roughly 1h+ to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.