Hi,
I've looked at the available (and limited) information for using the Mailbox to output graphics to the screen, and even though I've not yet implemented anything, I see a potential problem...
I'm aiming to develop a basic system, called RetrOS, which will allow retro games to be played and programmed (via an interpreter, RetroBASIC) on the Raspberry Pi. The only thing is, to do this it would be ideal if I could implement double-buffering. From what I've read however, I couldn't simply draw my graphics to a certain portion of memory and update a pointer to point to that area of memory, as the GPU decides the location of the buffer itself; the only way I'll be able to achieve double-buffering is to copy the data from a back buffer to the front buffer.
The question is, how can I do this quickly? I'm a bit of a n00b when it comes to the Pi, but from what I've read it looks like DMA is going to be the way forward. Basically, I'll get my front buffer's address by using the Mailbox, then I'll set up a back buffer somewhere else in memory, draw to it, then when I'm finished drawing I'll use DMA to copy the contents of the back buffer to the front buffer. Does this sound a sensible way forward (if it's even plausible)?
Thanks in advance!
Raspberry Pi Bare Metal - Double Buffering???
-
- Member
- Posts: 25
- Joined: Sat Jan 15, 2011 8:40 pm
Raspberry Pi Bare Metal - Double Buffering???
Lee.J.Baxter - Designer of CHAOS (Cybernetic Hivemind Adaptive Operating System)
Re: Raspberry Pi Bare Metal - Double Buffering???
The rpi framebuffer lets you set both a virtual and physical size. One way to implement double buffering is to have the virtual size twice the physical size. e.g. for a 1920x1080 display, you set the virtual size to be 1920x2160 and the physical size to 1920x1080, and then you are given the pointer to a framebuffer. You then have two screens, one at (0, 0) and one at (0, 1080). The idea then is that you give them names, e.g. screen0 and screen1 and alternate between which is the back buffer and which is the front. For example, you could write a frame to screen0, then set the virtual offset (using the mailbox property interface) to (0, 0), then write the next frame to screen1, then set the virtual offset to (0, 1080), then write the next frame back to screen0 and so on. Obviously this requires that each time you update a screen, you have to update the parts that have changed in both the current and previous frame.
However, you're probably better off asking on the rpi forums for this.
Regards,
John.
However, you're probably better off asking on the rpi forums for this.
Regards,
John.
-
- Member
- Posts: 25
- Joined: Sat Jan 15, 2011 8:40 pm
Re: Raspberry Pi Bare Metal - Double Buffering???
Brilliant!!! This seems like a much similar way forward, so I'll give it a go!!!jnc100 wrote:The rpi framebuffer lets you set both a virtual and physical size. One way to implement double buffering is to have the virtual size twice the physical size. e.g. for a 1920x1080 display, you set the virtual size to be 1920x2160 and the physical size to 1920x1080, and then you are given the pointer to a framebuffer. You then have two screens, one at (0, 0) and one at (0, 1080). The idea then is that you give them names, e.g. screen0 and screen1 and alternate between which is the back buffer and which is the front. For example, you could write a frame to screen0, then set the virtual offset (using the mailbox property interface) to (0, 0), then write the next frame to screen1, then set the virtual offset to (0, 1080), then write the next frame back to screen0 and so on. Obviously this requires that each time you update a screen, you have to update the parts that have changed in both the current and previous frame.
However, you're probably better off asking on the rpi forums for this.
Regards,
John.
Cheers,
Lee.
Lee.J.Baxter - Designer of CHAOS (Cybernetic Hivemind Adaptive Operating System)