Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: A port of DOOM that runs (almost) entirely on the GPU (github.com/jhuber6)
8 points by jhuber6 7 months ago | hide | past | favorite | 1 comment
I've been recently working on porting standard C library functions to work on the GPU https://libc.llvm.org/gpu/. A colleague of mine suggested using it to run DOOM, so that's what I did. It runs on both AMD and NVIDIA GPUs and it is completely playable.

This works by targeting C code directly for the GPU via cross-compilation in clang, looks something like this https://godbolt.org/z/hh44a6vKr. The LLVM C library will provide the headers, C library functions, and the kernel that calls the main function, so we only need to compile the DOOM source code targeting my GPU to get an executable. Then it's just a matter of writing a loader utility to launch this program on the GPU using the appropriate vendor runtime libraries (AMD's HSA or CUDA).

Now, it's not entirely on the GPU because we still need the CPU's operating system to do a few things. The loader utility has a thread continuously scanning some memory for 'syscall' requests from the GPU. Currently the only parts running on the CPU for this demo are standard I/O, reading input keys from SDL, and writing the rendered framebuffer to the SDL window. The only modifications made to the DOOM source code itself were done to allow rendering with multiple threads for better FPS.




I love this, thanks for posting. It's an existence proof of running arbitrary complicated C as a GPU shader.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: