deltabeard / Peanut-GB

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

sdl2: only update LCD line on change #51

Closed deltabeard closed 2 years ago

deltabeard commented 2 years ago

Add a feature in the SDL2 example to only refresh the lines of the screen that have changed since the previous frame. This can be used as a reference for a performance improvement on platforms where communicating with an LCD is time costly.

A hashing algorithm that is fast for 160 bytes of data should be selected.

In this case, multiple hash algorithms could be added, and one could be selected for use at runtime. Some platforms, like the RP2040, have integrated CRC32 hashing. I think it will be interesting to see how well something like CRC32 will do against a stronger hash algorithm like wyhash or xxHash.

deltabeard commented 2 years ago

This has been added in the RP2040-GB project (Peanut-GB on the RP2040) at https://github.com/deltabeard/RP2040-GB/commit/97360886efec22b1c2a5598baa338de4110e08b1. This code uses the DMA sniffing feature of the RP2040 to generate a hash. This improved frame rate from 65 to 80 FPS. The DMA transfer replaces a memcpy, but now also performs this additional hashing at no performance penalty.

deltabeard commented 2 years ago

I think the example in https://github.com/deltabeard/RP2040-GB is adequate.