0
\$\begingroup\$

I'm working with Page Flipping and Tiled Rendering (all hardware based) but i cannot understand one aspect of page flipping technique.

When you're at frame 1, you're rendering bank1 and working on bank2 for instance. Then you start rendering frame 2 and switch to render bank2 that you was working. Until there, all okay, but when you start working on bank1 again, all changes that you done on bank2 arent on bank1.

How do Page Flipping works without copying content from bank2 to bank1, since do a full copy (like Double Buffering) its impossíble only in vsync time for my applicaition.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ You either have to copy the new data from bank2 to bank1 or re-render everything you rendered in the previous step into bank2 before doing the next render step into bank1. Page flipping is all about not writing to a page which is currently read by the video logic. But reading that page is allowed. That's why page flipping is slower: you have to render everything twice. \$\endgroup\$
    – Janka
    Nov 29 '17 at 14:46
  • \$\begingroup\$ @Janka Understood, but if Im busy reading everything from bank1 into bank2 while displaying bank1 when do I have time to do processing on any bank? \$\endgroup\$
    – h0m3
    Nov 29 '17 at 14:59
  • 1
    \$\begingroup\$ You had time rendering into bank1, haven't you? Then, there should be no problem to do the same render to bank2. Of course, you would need some time left for rendering new content to bank2 afterwards. \$\endgroup\$
    – Janka
    Nov 29 '17 at 15:01
  • 1
    \$\begingroup\$ I should add a more sophisticated update scheme does not honor complete frames, but the very scanline the video logic reads out at the moment. You can get around a lot of timing and speed problems that way, at the cost of a much more complicated rendering scheme. \$\endgroup\$
    – Janka
    Nov 29 '17 at 15:06
  • \$\begingroup\$ @Janka Yes. Actually, that is what is not working in my head. Since Im displaying on bank1 I can copy the content to bank2, but that makes bank2 inaccessible to new changes. I will only be able to add new changes into bank2 while I'm vsync, that defeats the hole purpose of using bank switching. Or, as you say, do things twice as slow by repeating the same frame twice, one for each bank. So a 60 frames refresh rate goes down to a 30 one. \$\endgroup\$
    – h0m3
    Nov 29 '17 at 15:06
1
\$\begingroup\$

That sort of problem is what DMA is for.

When you finish rendering buffer 1 wait until it starts being read out onto the video output, then kick off a DMA copy transfer to buffer 2, you can start doing your mods to buffer two as long as you stay behind the line the DMA core is copying, then wait for VBI interrupt and do the same thing going back the other way. Memory to Memory DMA transfers are generally quick and do not tie up the processor.

Depending on the hardware, reading video ram while it is being displayed is seldom a problem, it is writes you want to avoid (And even there you can just contrive to write behind the line the video hardware is outputting).

You can even do effects by playing with the video readout DMA addresses between each line, the gameboy for example did this to great effect.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.