Vesa Triple Buffering

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
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Vesa Triple Buffering

Post by salil_bhagurkar »

Hello... I am writing a simple GUI... Currently i am slightly worried about the graphics performance. So i want to try triple buffering. I have tried to:

Code: Select all

mov ax,0x4f07
mov bx,0x0002
mov ecx,(video buffer address)
int 0x10
But this doesn't work... I have a VBE 3.0 and the mode supports hardware triple buffering... What am i supposed to do?
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

Hey... somebody going to reply to this?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Vesa Triple Buffering

Post by Brendan »

Hi,
salil_bhagurkar wrote:Hello... I am writing a simple GUI... Currently i am slightly worried about the graphics performance. So i want to try triple buffering. I have tried to:

Code: Select all

mov ax,0x4f07
mov bx,0x0002
mov ecx,(video buffer address)
int 0x10
But this doesn't work... I have a VBE 3.0 and the mode supports hardware triple buffering... What am i supposed to do?
Do you check if the function returns an error (e.g. does AX = 0x004F on return, and if it doesn't what does AX equal)?

Also, are you putting the physical address of display memory in ECX, or the offset from the start of display memory in ECX? For example, if video display memory is mapped at the physical address 0xE0000000, then you'd want to set ECX to 0x00010000 to make the pixel at 0xE0010000 the first pixel displayed (not 0xE0010000).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

Okay.. i do get an error with ax=0x4f...
Now on the next part of what you said Brendan...

I allocate a video buffer of 1024*768*4 and put that address in ecx. Now this address is like 0x110000... So as you say if we add it to 0xe0000000 we get 0xe1100000... Is that a valid address?

I did not know that you are supposed to add the offset to 0xe0000000. But the new address still doesn't seem out of range... So why the error... (Sorry if i'm being dumb.. i can't get to my fault...)
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,
salil_bhagurkar wrote:Okay.. i do get an error with ax=0x4f...
If VBE returned AX = 0x004F, then the function returned "success"...
salil_bhagurkar wrote:I allocate a video buffer of 1024*768*4 and put that address in ecx.
Um...

Imagine you're using 1024 * 768 with 256 colours and it takes 1 MB of the video card's memory for this video mode. Because the video card has more than 1 MB of memory you can have more than one frame of video data in the video card's memory at the same time.

To tell the video card to display the first frame from the video card's memory you'd use "ecx = 0x00000000". To tell the video card to display the second frame from the video card's memory you'd use "ecx = 0x00100000".

For example, if the video card's RAM is mapped at 0xE0000000 in the physical address space and the video mode uses 1 MB of the video card's memory, then you could do something like:
  • - use VBE to tell the video card to display data from offset 0x00000000 in it's memory
    - upload a new frame of video data into the video card at 0xE0100000 in the physical address space
    - use VBE to tell the video card to display data from offset 0x00100000 in it's memory
    - upload a new frame of video data into the video card at 0xE0200000 in the physical address space
    - use VBE to tell the video card to display data from offset 0x00200000 in it's memory
    - upload a new frame of video data into the video card at 0xE0000000 in the physical address space
    - use VBE to tell the video card to display data from offset 0x00000000 in it's memory
    - upload a new frame of video data into the video card at 0xE0100000 in the physical address space
    - use VBE to tell the video card to display data from offset 0x00100000 in it's memory
    - upload a new frame of video data into the video card at 0xE0200000 in the physical address space
    - use VBE to tell the video card to display data from offset 0x00200000 in it's memory
Of course you could probably use the same function for other things, like scrolling (e.g. pretend the video mode is 1024 * 4096, fill it with data and then use VBE to select which 768 screen lines are actually displayed). This might actually be an easier way to get used to things and make sure the function does what I think it does. For example, get any sort of video displayed on the screen and then try something like this:

Code: Select all

    mov ebp,0
.foo:
    mov ax,0x4f07
    mov bx,0x0002
    mov ecx,ebp
    int 0x10

    *put a small delay here*

    add ebp,4       ;Let it roll over from 65535 to 0
    and ebp,0xFFF
    jmp .foo
This should slowly scroll the screen to the left...


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

Okay.. Thats great info... I am sorry... I guess i just forgot about 0x4f... So now i understand about video memory... I have one more question:
I have a shared internal graphics card which takes up memory ranging from 4MB to 64MB from my 128MB of total RAM.. To get a good application speed (i don't play graphic games) i set it to 4MB from my BIOS. So if i set a mode of 1024*768 32 bpp it requires about 3MB of LFB space.. Now there is no space for a second frame. So will the BIOS return an error?

Also in my 1024*768 32 bpp mode i get a frame rate of 8 fps only... But if i use MMX registers i get up to 17 fps. But 17 is still low as compared to other people whom i have heard getting 25 fps...
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

I tried the code... I passed 0x300000 (3 MB) in ecx after writing to 0xe0300000... But BIOS returns 0x14f...
Post Reply