Page flipping in vbe

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
AlfaOmega08
Member
Member
Posts: 226
Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy

Page flipping in vbe

Post 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?
Please, correct my English...
Motherboard: ASUS Rampage II Extreme
CPU: Core i7 950 @ 3.06 GHz OC at 3.6 GHz
RAM: 4 GB 1600 MHz DDR3
Video: nVidia GeForce 210 GTS... it sucks...
Selenic
Member
Member
Posts: 123
Joined: Sat Jan 23, 2010 2:56 pm

Re: Page flipping in vbe

Post 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.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: Page flipping in vbe

Post 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.
StephanvanSchaik
Member
Member
Posts: 127
Joined: Sat Sep 29, 2007 5:43 pm
Location: Amsterdam, The Netherlands

Re: Page flipping in vbe

Post 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.
Selenic
Member
Member
Posts: 123
Joined: Sat Jan 23, 2010 2:56 pm

Re: Page flipping in vbe

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Page flipping in vbe

Post by Combuster »

For the record, VBE/AF is practically nonexistant.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply