VBE video memory cache

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

VBE video memory cache

Post by salil_bhagurkar »

Hello all..

I had posted a topic on the VBE fps long back. That time I was getting around 15 fps from my best SSE VBE-LFB code and that was pretty slow. You could see four screen splits in one paint.

Now I just found this setting in my BIOS which allows me to set the video memory cache mode (UC or USWC). It was at UC by default and I changed it to USWC. Doing this gave me an fps of 100 approximately. I have two questions.

1. What is UC (Is it Uncached?) and what is USWC and how did this work?

2. All linux distros that I have used and winxp seem to do this through their code, as the screen painting is fast and the same irrespective of the BIOS setting (UC/USWC). How do they do it?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: VBE video memory cache

Post by Brendan »

Hi,
salil_bhagurkar wrote:1. What is UC (Is it Uncached?) and what is USWC and how did this work?
Yes, UC is uncached. It means if you write 16 bytes, then it costs 16 separate single-byte transfers over the PCI bus (where each separate transfer has it's own overheads).

"USWC" (or normally just "WC") is "write combining". In this case the CPU buffers writes and tries to combine them, so that (for e.g.) if you write 16 adjacent byte then the CPU might combine them into a single transfer consisting of a burst of 4 dwords over the PCI bus (with a lot less overhead, because it's one large transfer rather than 16 separate transfers).
salil_bhagurkar wrote:2. All linux distros that I have used and winxp seem to do this through their code, as the screen painting is fast and the same irrespective of the BIOS setting (UC/USWC). How do they do it?
Windows and Linux (and all other decent OSs) would try to program the MTRRs (and/or the PAT) so that video memory is "write combining" (or perhaps "write through" if write combining isn't supported), so you get the same speed-up as the "USWC" BIOS setting.

In addition, it's possible that these OSs have proper video drivers, and could be using bus-mastering and 2D bit blits, so the video card gets the data from RAM itself (without wasting CPU time to shift the data from RAM to the video card). They could also be using hardware accelerated graphics for a lot of other stuff too, to minimize CPU time spent.

Lastly, it might be possible that even with "uncached" your code may be slightly less than good (e.g. not using a double buffer, and/or not optimizing transfers to display memory, and/or reading data from display memory when you should be reading it from RAM, and/or not supporting anything to avoid updating pixels that haven't changed). Of course I'm just guessing, as you didn't say how much data you're transferring per frame (e.g. even 100 FPS is very slow for 320 * 200 * 8 bpp on a modern computer with a PCIe video card).


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

Re: VBE video memory cache

Post by salil_bhagurkar »

Thanks a lot for that Brendan. I think i will look up MTRRs...

And yes, i am using a double buffer.
Transfer to video memory are done through SSE (16 bytes)

And lastly i completely forgot to mention that the 15 fps was for 1024 x 768 x 32 bpp...
The new around 100 fps is also at 1024 x 768 x 32 bpp..
Pretty good eh? :D
Post Reply