Page 1 of 1

Page flipping in vbe

Posted: Thu Jun 10, 2010 6:01 am
by AlfaOmega08
Is it possible to use page flipping (ping-pong buffering) which works like this: http://en.wikipedia.org/wiki/Multiple_b ... e_Flipping.
Suppose I have two buffers:
One at 0xE0000000 (the typical vesa frame buffer)
Another created using malloc (my back buffer).

Instead of rendering the back buffer and then copying it to the front one, i'd like to change the frame buffer pointer to point to the back buffer, then rendering on the old front buffer, and switch again.
Can this be done in Vesa VBE?

Re: Page flipping in vbe

Posted: Thu Jun 10, 2010 1:32 pm
by Selenic
To have double-buffering, both buffers must be in video memory; although the buffer pointer can usually be changed, it must stay within vram and not into main memory (because the video card only even touches vram - you have to manage moving data between that and main memory. Depending on the exact graphics card, this may not be true (think integrated graphics which only have main memory to use), but in general it is)

Anyway, there's already a thread about this, which explains everything else.

Re: Page flipping in vbe

Posted: Thu Jun 10, 2010 2:04 pm
by NickJohnson
@selenic: Actually, I don't think that thread really answers the OP's question. His question is about how to change the pointer to the current framebuffer for a VBE mode. Unfortunately, I don't know the answer either.

Also, double buffering != page flipping.

Re: Page flipping in vbe

Posted: Thu Jun 10, 2010 3:10 pm
by StephanvanSchaik
AlfaOmega08 wrote:Is it possible to use page flipping (ping-pong buffering) which works like this: http://en.wikipedia.org/wiki/Multiple_b ... e_Flipping.
Suppose I have two buffers:
One at 0xE0000000 (the typical vesa frame buffer)
Another created using malloc (my back buffer).

Instead of rendering the back buffer and then copying it to the front one, i'd like to change the frame buffer pointer to point to the back buffer, then rendering on the old front buffer, and switch again.
Can this be done in Vesa VBE?
Should be possible with AX=4F07h, BL=00h; AX=4F07h, BL=02h (encouraged); AX=4F07, BL=80h and AX=4F07, BL=82h (encouraged). AX=4F07h or function 07h is used to get and set the display start. BL=00h is used to set the display start, BL=02h is used to schedule a display start, BL=80h is used to set the display start during vertical retrace, BL=82h is the same as 80h but an alternative function. BH should be equal to 00h when using these functions. Other than that: ECX should be the display start address in bytes in case of BL=02h and BL=82h. In case of BL=00h and BL=80h CX is the first displayed pixel in the scan line and DX is the first displayed scan line. When the function is called you'll get the return status in AX.

The reason why functions 02h and 82h are encouraged is because they allow correct page flipping in all colour depths, whilst functions 00h and 80h might have issues in the 24bpp modes where three bytes are used to represent a pixel. That might cause problems when using some (x,y) start addresses since a given combination might not work.

The problem with using 02h and 82h is that they only exist in VBE 3.0 (afaik), whilst 00h exists since VBE 1.2 and 80h since VBE 2.0.


Regards,
Stephan J.R. van Schaik.

Re: Page flipping in vbe

Posted: Thu Jun 10, 2010 3:25 pm
by Selenic
NickJohnson wrote:@selenic: Actually, I don't think that thread really answers the OP's question. His question is about how to change the pointer to the current framebuffer for a VBE mode. Unfortunately, I don't know the answer either.
Hmm, I suppose not, actually. Nonetheless, it's a related thread, so it may still be of help.
NickJohnson wrote:Also, double buffering != page flipping.
That's a terminology fail on my part. I thought they meant the same thing, but now I see that they don't. My point about not being able to have one page in memory still stands, as does the comment about having to send most modifications to vram twice (for the two different buffers) if you don't have a hardware blitter available.

Speaking of hardware blitters, this from Wikipedia looks promising:
Wikipedia wrote:VBE/AF provides a low-level, standard interface to common acceleration functions available on most hardware. Some of the functions supported in the standard are access to hardware cursors, Bit Block Transfers (Bit Blt) , off screen sprites, hardware panning, drawing and other functions.

Re: Page flipping in vbe

Posted: Thu Jun 10, 2010 3:51 pm
by Combuster
For the record, VBE/AF is practically nonexistant.