chibinz / GameBar

A Game Boy Advance emulator written in Rust
MIT License
3 stars 0 forks source link

Cache rendering result #3

Open chibinz opened 3 years ago

chibinz commented 3 years ago

Most of the time, the ppu is doing duplicate work, i.e., redrawing the same sprite, background, etc. Imagine if you were to do a diff of 2 consecutive frames, the number of different pixels, in the common case, should be relatively small. Changes usually happen in offsets, colors, mosaics and other attributes. Actual pixels are often kept intact. But caching at what level of abstraction is still a problem. Tiles or objects? Caching objects seems too complicated. An issue of caching tiles is that you might not know the underlying tile data is 4bpp or 8bpp...Also, tile data are references to palette ram values. A write to the palette memory should invalidate the tile cache... If tile caching is implemented correctly, most rendering work should cost no more than a bunch of memcpy's. Complicated but worth while trying.