I would like to improve the performance of my graphics code by implementing a better kind of double buffering for VESA video memory.
Background:
I wrote a simple Game of Life implementation in x86_64, nasm. It boots in QEMU, switches to 64bit and runs the game from some pseudo-random initial state.
I am using a memory buffer to store the "next" state and at the end of each tick I am copying that entire buffer to video mem location, then zeroing it. In my current case that's almost 2MiBs of data swapped/changed on each tick, probably unnecessarily. This approach worked fine in 320x200x8bpp, but now in VESA 640x480x24bpp it is too slow.
I am sure that there is a better way to do it and my first thought is to simply swap the memory addresses of the buffers. I looked for a way to do it but could not find anything on programming the parameters. I can get the VESA mode info etc., but is there a way to set some values?
Or maybe I am doing it wrong and there is a better/other way to do it?
Some notes:
- 64bit long mode, no BIOS interrupts available
- I am writing to a continuous video mem mapped to RAM location @ VBEModeInfo.VidMemBasePtr