deltabeard / Peanut-GB

A Game Boy (DMG) emulator single header library written in C99. Performance is prioritised over accuracy.
https://projects.deltabeard.com/peanutgb/
276 stars 35 forks source link

core: allow LCD rendering to happen in separate thread #88

Open deltabeard opened 1 year ago

deltabeard commented 1 year ago

Peanut-GB would signal to the frontend that it should call gb_lcd_render_line() with copied sprite data and LCD registers. This would allow the LCD drawing -- which requires a lot of time -- to be completed on a separate thread whilst emulation continues.

deltabeard commented 9 months ago

Considering this screenshot from the pandoc: PPU Mode Timings

The gb_lcd_render_line() function could run in a separate thread whilst remaining within the timing of the GB CPU such that OAM is processed during OAM scan where the OAM is inaccessible (unless using OAM DMA, which is ignored here), and then the LCD rendering can be done in Mode 3, where the VRAM is also inaccessible. This means that copying the OAM and VRAM will not be necessary to render the LCD in a separate thread.