Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
deltabeard opened this issue May 26, 2023 · 2 comments
Open

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

deltabeard opened this issue May 26, 2023 · 2 comments
Labels
diff: complex A difficult issue; may require significant planning. enhancement New feature or request
Milestone

Comments

@deltabeard
Copy link
Owner

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 deltabeard added enhancement New feature or request diff: complex A difficult issue; may require significant planning. labels May 26, 2023
@deltabeard deltabeard added this to the v2 milestone May 26, 2023
@deltabeard
Copy link
Owner Author

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.

@deltabeard
Copy link
Owner Author

deltabeard commented Jan 7, 2025

Instead or as an addition option, I think that the LCD emulation should be allowed to be performed in a separate thread or handled using co-routines, where the emitting of a pixel is timed with the CPU emulation. This will allow for the emulation accuracy of LCD to be improved by emitting the pixels at the correct time rather than only at the end of Mode 3. This also means that the VRAM, OAM, etc. do not need to be copied to perform the LCD drawing.

The same could probably be done for audio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diff: complex A difficult issue; may require significant planning. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant