georginikolov
Joined 2 years ago
Joined 2 years ago
It covers all the steps needed to produce a single frame in my WebGPU deferred renderer demo. Additionally, it talks about the WebGPU API itself and how it differs in some ways from Metal.
Game tick loop
User input
Providing characters "0123456789GAMEOVER" byte data on game startup
Blitting the pixel buffer to the display with WebGL2
The game uses 3 virtual pages of memory (64kb each) for a total of 192kb. Within those exist the pixel buffer contents, the characters data and snake positions. For more detailed breakdown you can check src/snake.wat.
The memory is shared between WASM and JS. On each game tick, the pixel buffer region of the memory is transferred to a WebGL2 texture, uploaded to the GPU and blitted to the screen.
For more info you can refer to the repo - https://github.com/gnikoloff/wasm-snake
reach out at https://georgi-nikolov.com