logoalt Hacker News

boricj • today at 12:20 PM • 0 replies • view on HN

That reminds me of some of the tricks I've used while tinkering with a voxel space rendering tech demo on the PlayStation.

The quirks of that console for this is that the CPU takes a 6 cycle stall on any read from main RAM (it's not even stall-on-use) and doesn't have a data cache. That would make it a very poor fit for this, so I had to improvise a bunch of tricks to reclaim performance:

- Made all of my hot loop fit within one function, so that it fits entirely in the 4 KiB direct-mapped instruction cache (so less than 1024 instructions)

- Wrote a C++ template that can trampoline a function call into the 2 KiB scratchpad

- Used the rest of the scratchpad for a CLUT table because it doesn't stall on read

- Used the GTE to transform the N set of coordinates while the CPU stalls fetching the N+1 set of heightmap data

- Figured ways to abuse the GTE into transforming more points per instructions than it theoretically can, taking advantage of simplified formulas compared to real 3D projection

- Write the rectangle primitives straight to the GPU registers instead of going through a display list

It's such an abuse of the PlayStation that PCSX-Redux and DuckStation disagree on its performance by up to a factor of two. I should finish it someday and see how it runs on real hardware...