Bring TypeGPU (
'use gpu'TypeScript shaders & compute) to consoles and handhelds with no browser and no WebGPU/wgpu — starting on real PlayStation 3 hardware (RSX NV40 + Cell 6×SPU).
Built on top of the PocketJS native console runtime foundation, pocket-typegpu provides an end-to-end multi-target compilation toolchain ('use gpu' TypeScript → WGSL → hardware microcode & heterogeneous compute kernels) and a standalone PlayStation 3 homebrew (TGPU00001: Pocket TypeGPU) running 36 ported official TypeGPU examples live at 1080p HDMI output (Phase 1 + Phase 2 + Phase 2.5 PS3 Ultimate Parity COMPLETE — see ROADMAP.md).
All screenshots below are real, unedited framebuffer captures from a PlayStation 3 Slim (CECH-2512B, 4.81 CEX, RSX NV40 + 6× Cell SPU), compiled directly from examples/shaders/*.tgpu.ts with zero hand-written WGSL or assembly:
rendering/jelly-switch (30 FPS, Native 2,184i FP2.0 past cgcomp 1024 wall!) |
rendering/global-illumination (20 FPS, Native 1,584i FP2.0 Cornell Box GI) |
|---|---|
![]() |
![]() |
rendering/radiance-cascades (30 FPS @ 1080p, 4-Pass 2D GI RTT) |
simple/liquid-glass (30 FPS @ 1080p, 2-Pass Chromatic Refraction) |
|---|---|
![]() |
![]() |
algorithms/jump-flood-voronoi (26 FPS @ 1080p, 8-Pass GPU JFA) |
rendering/point-light-shadow (12 FPS @ 720p, 6-Face 360° Cube RTT) |
|---|---|
![]() |
![]() |
simulation/fluid-with-atomics (6×SPU 0.37 ms, Live LL/SC 1536 Atomics) |
algorithms/sort (6×SPU 0.06 ms, SORTED OK (512) buffer.read()) |
|---|---|
![]() |
![]() |
simulation/slime-mold-3d (6×SPU 2.14 ms → 32³ HW 3D Tex, 30 FPS) |
simple/mesh-skinning (43 FPS @ 1080p, VP2.0 4-Bone mat4x4f LBS) |
|---|---|
![]() |
![]() |
algorithms/matrix-multiplication (6×SPU 0.81 ms, ERR 0.0000 buffer.read()) |
simulation/fluid-double-buffering (60 FPS @ 1080p, 5-Pass 6×SPU 1.41 ms) |
|---|---|
![]() |
![]() |
simulation/confetti (60 FPS @ 1080p, 512 Ribbons 6×SPU 0.12 ms) |
simulation/gravity (60 FPS @ 1080p, 320-Body 3D 6×SPU 1.38 ms) |
|---|---|
![]() |
![]() |
rendering/triplanar-mapping (60 FPS @ 1080p, Seam-Free 3D Triplanar) |
rendering/box-raytracing (30 FPS @ 720p, HW 8×8×8 RSX 3D Tex) |
|---|---|
![]() |
![]() |
image-processing/blur (30 FPS @ 1080p, 3-Pass RTT Separable Blur) |
rendering/cubemap-reflection (60 FPS @ 1080p, Swizzled RSX CUBE) |
|---|---|
![]() |
![]() |
rendering/simple-shadow (30 FPS @ 1080p, 2-Pass Shadow Map RTT) |
rendering/two-boxes (44 FPS @ 1080p, 3D IBO + Z24S8 Depth) |
|---|---|
![]() |
![]() |
simple/stencil (30 FPS @ 1080p, Hardware Z24S8 Stencil Mask) |
rendering/jelly-slider (33 FPS, Beer-Lambert + Fresnel) |
|---|---|
![]() |
![]() |
rendering/ray-marching (15 FPS, SDF + Soft Shadows) |
rendering/perlin-noise (30 FPS @ 720p, tgpu.unroll + fwidth) |
|---|---|
![]() |
![]() |
rendering/disco (30 FPS @ 720p, switch + DDX/DDY AA) |
simple/oklab (17 FPS @ 1080p, @typegpu/color Hue Gamut) |
|---|---|
![]() |
![]() |
simple/gradient-tiles (60 FPS @ 1080p, switch + fwidth Grout) |
rendering/xor-dev-centrifuge-2 (15 FPS, NV40 HW LOOP) |
|---|---|
![]() |
![]() |
simple/vaporrave (19 FPS, tgpu.slot Grid / Circles) |
simulation/boids (60 FPS @ 1080p, 6×SPU 8.44 ms, 1000 Boids) |
|---|---|
![]() |
![]() |
simulation/game-of-life (60 FPS @ 1080p, 6×SPU 0.47 ms) |
simulation/slime-mold (30 FPS @ 1080p, 6×SPU 0.28 ms, 2048 Agents) |
|---|---|
![]() |
![]() |
rendering/caustics (54 FPS @ 720p, 3D Perlin + God Rays) |
rendering/phong-reflection (16 FPS @ 540p, Blinn-Phong 3D) |
|---|---|
![]() |
![]() |
rendering/clouds (15 FPS @ 360p, Volumetric FBM Sun Scattering) |
simple/triangle (60 FPS @ 1080p, $vertexIndex + std.mix) |
|---|---|
![]() |
![]() |
TypeScript ('use gpu' / d.* / std.* / tgpu.slot) [examples/shaders/*.tgpu.ts]
│
▼ tgsl-transpiler.ts (TypeScript AST Frontend)
Standard WGSL [generated/wgsl/*.wgsl]
│
▼ wgsl-parser.ts (Typed AST + Inlining + Liveness)
┌──────────────┴──────────────────┬────────────────────┬────────────────────┐
▼ ▼ ▼ ▼
PS3 RSX NV40 + 6×SPU PS Vita GXM 3DS PICA200 PSP GU + VFPU
[Phase 1: LIVE] [Planned] [Planned] [Research]
├─ nv40-codegen.ts ├─ Cg -> psp2cgc ├─ picasso .pica ├─ VFPU vertex stream
│ → !!VP2.0 / !!FP2.0 │ (.gxp shaders) ├─ 6-stage TEV ├─ ME/VFPU compute
│ → cgcomp -a → .vpo/.fpo └─ 3×Cortex-A9 │ synthesizer ├─ Dynamic CLUT tricks
└─ spu-codegen.ts NEON compute └─ Dual ARM11 └─ 120×68 VFPU soft-tile
→ Cell SPU C99 → spu-gcc -O3 + GE bilinear upscale
See docs/ARCHITECTURE.md for the full multi-target hardware matrix and PSP no-shader extreme compilation strategies.
| # | Official Example | Shader / Compute Compilation (Post-Peephole) | Render Scale | Measured PS3 Hardware Perf |
|---|---|---|---|---|
| 1 | simple/triangle |
VP 35i/7r · FP 5i/4r (-44% opt) |
1080p |
60 FPS (16.7 ms) |
| 2 | rendering/caustics |
VP 24i/6r · FP 693i/17r (-24% opt) |
720p→1080p |
54 FPS (18.5 ms) / 60 FPS @ 540p |
| 3 | rendering/xor-dev-centrifuge-2 |
VP 22i/5r · FP 112i/14r (HW LOOP) |
360p→1080p |
15 FPS (66.7 ms, 42 steps) |
| 4 | rendering/ray-marching |
VP 22i/5r · FP 674i/26r (-30% opt, HW LOOP) |
360p→1080p |
15 FPS (66.8 ms, 64+24 steps + bounding sphere) |
| 5 | simple/vaporrave |
2× tgpu.slot FP (162i Circles / 156i Grid) |
540p→1080p |
18–19 FPS (52.6–55.1 ms) |
| 6 | simulation/boids |
Cell 6×SPU boids_sim ELF + RSX Instanced (56i/8r) |
1080p |
60 FPS (16.7 ms), 6×SPU 8.44 ms (1000 boids $O(N^2)$) |
| 7 | simulation/game-of-life |
Cell 6×SPU gol_step 2D ELF + RSX Tex (63i/11r) |
1080p |
60 FPS (16.7 ms), 6×SPU 0.47 ms (128×128) |
| 8 | rendering/jelly-slider |
VP 22i/5r · FP 693i/29r (-30% opt, Refract SDF) |
360p→1080p |
33 FPS (30.6 ms) |
| 9 | rendering/clouds |
VP 22i/5r · FP 227i/19r (-33% opt, Volumetric FBM) |
360p→1080p |
15 FPS (66.6 ms) |
| 10 | simulation/slime-mold |
Cell 6×SPU Physarum (2048 agents + 128×128) + RSX (88i/12r) |
1080p |
30 FPS (33.4 ms), 6×SPU 0.28 ms
|
| 11 | rendering/phong-reflection |
VP 22i/5r · FP 372i/28r (-29% opt, Blinn-Phong 3D) |
540p→1080p |
16 FPS (61.6 ms) |
| 12 | rendering/perlin-noise |
VP 22i/6r · FP 379i/20r (tgpu.unroll + fwidth) |
720p→1080p |
30 FPS (33.4 ms) |
| 13 | simple/gradient-tiles |
VP 22i/6r · FP 93i/13r (switch + fwidth Grout) |
1080p |
60 FPS (16.7 ms) |
| 14 | simple/oklab |
VP 22i/6r · FP 456i/27r (@typegpu/color + fwidth) |
1080p |
17 FPS (58.4 ms) |
| 15 | rendering/disco |
VP 22i/6r · FP 353i/17r (switch + LOOP + DDX/DDY) |
720p→1080p |
30 FPS (33.4 ms) |
| 16 | simple/stencil |
VP 14i/4r · FP 130i/13r (HW Z24S8 Stencil Mask) |
1080p |
30 FPS (33.4 ms) |
| 17 | rendering/two-boxes |
VP 29i/8r · FP 152i/20r (3D IBO + mat4x4f + Z24S8) |
1080p |
44 FPS (22.8 ms) |
| 18 | rendering/cubemap-reflection |
Skybox (14i/11i) + Mesh (28i/65i, Swizzled RSX CUBE) |
1080p |
60 FPS (16.7 ms) |
| 19 | rendering/simple-shadow |
2-Pass: Depth RTT (12i/16i) + Main 2×2 PCF (28i/201i) |
1080p |
30 FPS (33.1 ms) |
| 20 | rendering/box-raytracing |
VP 22i/5r · FP 280i/29r (HW 8×8×8 RSX 3D Tex + DDA LOOP) |
720p→1080p |
30 FPS (33.3 ms) |
| 21 | rendering/triplanar-mapping |
VP 28i/7r · FP 121i/13r (X/Y/Z Albedo + Bump Triplanar) |
1080p |
60 FPS (16.7 ms) |
| 22 | image-processing/blur |
3-Pass RTT: Scene (443i) + Horiz (48i) + Vert Split (79i) |
1080p |
30 FPS (33.4 ms) |
| 23 | algorithms/matrix-multiplication |
Cell 6×SPU matmul_tiled (var<workgroup> + workgroupBarrier) + RSX (175i) |
1080p |
40 FPS, 6×SPU 0.81 ms, ERR 0.0000 (buffer.read())
|
| 24 | simulation/gravity |
Cell 6×SPU gravity_step (320-body 3D, 3 bufs) + RSX 3D Glow (25i) |
1080p |
60 FPS (16.7 ms), 6×SPU 1.38 ms
|
| 25 | simulation/confetti |
Cell 6×SPU confetti_step (512 ribbons, 64 KiB quad out) + RSX (24i) |
1080p |
60 FPS (16.7 ms), 6×SPU 0.12 ms
|
| 26 | simulation/fluid-double-buffering |
Cell 6×SPU 5-Pass Navier-Stokes (64×64, 6 Jacobi) + RSX (48i) |
1080p |
60 FPS (16.7 ms), 6×SPU 1.41 ms
|
| 27 | simulation/fluid-with-atomics |
Cell 6×SPU LL/SC atomicAdd/Max (3 kernels, 1536 splats) + RSX (160i) |
1080p |
30 FPS (33.4 ms), 6×SPU 0.37 ms
|
| 28 | algorithms/sort |
Cell 6×SPU Atomic Histogram + LS Scan + Scatter (3 kernels) + RSX (234i) |
1080p |
30 FPS, 6×SPU 0.06 ms, SORTED OK (512)
|
| 29 | simulation/slime-mold-3d |
Cell 6×SPU 3D Physarum → Morton-3D RSX 32³ 3D Tex (127i LOOP) |
720p→1080p |
30 FPS (33.4 ms), 6×SPU 2.14 ms
|
| 30 | simple/mesh-skinning |
VP 67i/10r (4-Bone array<mat4x4f, 4> LBS) · FP 168i/23r
|
1080p |
43 FPS (23.4 ms) |
| 31 | rendering/point-light-shadow |
6-Face 128×128 Cube RTT (23i/18i) + Room (29i/155i CUBE) |
720p→1080p |
12 FPS (82.5 ms) |
| 32 | rendering/radiance-cascades |
4-Pass GI RTT: Scene (378i) + Hi (96i) + Lo (183i) + Display (108i) |
1080p |
30 FPS (33.4 ms) |
| 33 | algorithms/jump-flood-voronoi |
8-Pass Ping-Pong JFA RTT (128..1, 184i) + Display (169i) |
1080p |
26 FPS (39.1 ms) |
| 34 | simple/liquid-glass |
2-Pass RTT: Backdrop (466i) + Chromatic SDF Glass Lens (274i) |
1080p |
30 FPS (33.3 ms) |
| 35 | rendering/jelly-switch |
Native NV40 FP2.0 (nv40-fp-assembler.ts): VP 22i · FP 2184i/29r (54.4 KB)
|
360p→1080p |
30 FPS (33.4 ms) |
| 36 | rendering/global-illumination |
Native NV40 FP2.0 (nv40-fp-assembler.ts): VP 22i · FP 1584i/31r (37.0 KB)
|
360p→1080p |
20 FPS (50.0 ms) |
- Real
'use gpu'TypeScript Frontend (tgsl-transpiler.ts+typegpu-bridge.ts): Parses standard TypeScript shader functions containing'use gpu',d.struct,d.vec*,std.*,u.$uniform dereferences,tgpu.vertexFn/fragmentFn/computeFn,tgpu.unroll,tgpu.accessor, cross-file imports,@typegpu/color/@typegpu/sdfstdlib injection, compile-timetgpu.slotspecialization, and pre-resolvedtgpu.resolve()WGSL bridging. - RSX NV40 Compiler, 9-Pass Optimizer & Native 4K FP2.0 Assembler (
nv40-codegen.ts+nv40-peephole.ts+nv40-fp-assembler.ts): Full function inlining, struct flattening, float4/matrix/array uniform packing, structuredwhile/switch/continue/early-returnlowering, NV40 hardware derivatives (DDX/DDY/fwidth) &TXL(2D/CUBE/3D), 9-pass code-density optimization (-28% to -39% FP), and a native 128-bit NV40 FP2.0.fpobinary assembler verified bit-for-bit againstcgcomp -a -fthat breakscgcomp's hardcoded ~1024-instruction segfault wall up to RSX's true 4,096-instruction hardware limit. - Universal Auto-Generated Cell 6×SPU Compute Engine (
spu-codegen.ts+tgpu_spu_worker.c): Compiles WGSL@computeshaders (includingvar<workgroup>+workgroupBarrier()multi-phase Local Store lowering and Cell MFC hardware LL/SCatomicops viamfc_getllar/mfc_putllc) into zero-warning-O3Cell SPU C99 kernels with auto-generated multi-buffer 16 KiB chunked DMA dispatch (1–8 buffers, zero manual per-kernel C glue), livebuffer.read()JS readback verification, and direct RSX VRAM vertex/texture upload across all 6 hardware 3.2 GHz SPUs. - Standalone Full-3D PS3 Homebrew (
TGPU00001): Builds an independentEBOOT.BIN+ installablepocket-typegpu-ps3.pkgwith dynamic.vpo/.fpoloading,ppu-gcc13 strict-aliasing-safe FP uniform patching (rsxInlineTransfer), Z24S8 depth/stencil, 16/32-bit IBOs, Morton-swizzled hardwareCUBE&3Dtextures, user Offscreen RTTs, multi-resolution upscaling (360p/540p/720p/1080p), crisp 3× Retina SolidJS telemetry HUD, and TCP DevShell live hot-reload.
pocket-typegpu/
├── packages/pocket-typegpu/
│ └── src/
│ ├── compiler/
│ │ ├── tgsl-transpiler.ts # 'use gpu' TypeScript -> WGSL frontend
│ │ ├── typegpu-bridge.ts # Multi-file resolver & tgpu.resolve() bridge
│ │ ├── wgsl-ast.ts # Typed WGSL AST
│ │ ├── wgsl-parser.ts # Recursive-descent WGSL parser
│ │ ├── nv40-codegen.ts # WGSL -> PS3 RSX NV40 (!!VP2.0 / !!FP2.0)
│ │ ├── nv40-peephole.ts # 9-pass NV40 DSE/CSE/MAD/LICM optimizer
│ │ ├── nv40-fp-assembler.ts # Native 128-bit NV40 FP2.0 .fpo assembler (up to 4096i)
│ │ └── spu-codegen.ts # WGSL @compute -> Cell 6xSPU C99 kernel
│ ├── backends/targets.ts # PS3 / Vita / 3DS / PSP capability & audit layer
│ ├── runtime/ # TypeGPU-compatible JS runtime shim (QuickJS)
│ └── cli.ts # End-to-end shader compiler & target auditor
├── examples/
│ ├── shaders/*.tgpu.ts # 36 official TypeGPU examples in 'use gpu' TS
│ ├── mesh3d.ts # Procedural 3D meshes & mat4/cubemap builders
│ ├── catalog.ts # Example pipeline & feature manifest
│ └── runners.ts # Interactive DualShock 3 runners for all 36 demos
├── native/ps3/ # Standalone PS3 Homebrew (TGPU00001)
│ ├── rsx_tgpu.{h,c} # Dynamic RSX NV40 pipeline + multi-res RTT engine
│ ├── tgpu_spu.{h,c} # Cell 6xSPU compute pool host controller
│ ├── tgpu_spu_worker.c # 6xSPU worker executing compiled WGSL kernels
│ ├── tgpu_js.{h,c} # QuickJS zero-copy TypedArray bridge
│ ├── main.c & Makefile # EBOOT.BIN + pocket-typegpu-ps3.pkg builder
├── app/ # PocketJS 3x Retina SolidJS PS3 showcase UI
├── tools/ # Build & webMAN PS3 deployment scripts
├── tests/compiler.test.ts # End-to-end TGSL -> WGSL -> NV40/SPU tests
└── docs/
├── ARCHITECTURE.md # Multi-target architecture & PSP extreme tricks
└── images/ # Real 1080p PS3 hardware captures
Requires Bun, Docker (hldtux/ps3dev:latest for cgcomp/ppu-gcc/spu-gcc), and a sibling checkout of pocket-nexus/pocketjs.
# 1. Run compiler & multi-target unit tests
bun test
# 2. Transpile all 36 'use gpu' TS examples -> WGSL -> NV40 (.vpo/.fpo) & Cell 6xSPU C99
bun run compile:shaders
# 3. Inspect PS3 / Vita / 3DS / PSP compatibility matrix
bun run audit:targets
# 4. Build PocketJS app bundle (.pkb) and standalone PS3 Homebrew (EBOOT.BIN + .pkg)
bun run build:app
bun run build:ps3
# 5. Deploy & launch standalone TGPU00001 homebrew on a CFW/HEN PS3 over LAN
PS3_IP=192.168.8.143 bun run deploy:ps3L1 / R1: Switch between all 36 official TypeGPU examples○(Circle): Cycle live render scale (1080p/720p/540p/360p→ 1080p RSX upscale)SELECT: Toggle 3× Retina telemetry HUD× / □ / △ / D-Pad / Sticks: Per-example live controls (drag Jelly Slider spring physics, swap Vaporravetgpu.slotCircles/Grid, cycle Boids presets & palettes, paint live cells in Game of Life, orbit Ray Marching / Phong / Clouds, switch Physarum Slime Mold colonies)
MIT



































