Page 1 of 1

VGA speed (and one other vga issue)

Posted: Mon Feb 18, 2008 11:17 am
by lukem95
I am currently using VGA mode 320x200x256 and plotting pixels takes forever (about two seconds to fill the screen in virtualpc, slightly less in bochs/qemu). Is this just cos of the VGA mode (will it increase with a better mode, such as a VESA mode), or is it just my method of plotting pixels.

I have a put_pixel function that uses pokeb to poke the data into the correct address space. Should i use double buffering? Is there much speed increase?

and finally, for plotting my font i read the background colour and use this so i don't overwrite it when nothing should be written (if that makes sense).

how do i read the pixel in 16 colour mode?

Re: VGA speed (and one other vga issue)

Posted: Mon Feb 18, 2008 11:51 am
by bluecode
Is this just cos of the VGA mode (will it increase with a better mode, such as a VESA mode)
afaik it woun't improve with VESA
lukem_95 wrote:I have a put_pixel function that uses pokeb to poke the data into the correct address space
copy 4bytes at a time, that speeds it up tremendously (At least on emulators).
how do i read the pixel in 16 colour mode?
Where is the problem? There are bitwise operations, you just have to extract the bits you want to read/write...

Posted: Mon Feb 18, 2008 12:09 pm
by Combuster
I am currently using VGA mode 320x200x256 and plotting pixels takes forever (about two seconds to fill the screen in virtualpc, slightly less in bochs/qemu). Is this just cos of the VGA mode (will it increase with a better mode, such as a VESA mode), or is it just my method of plotting pixels.
Enable AGP if applicable, perform larger writes, do not overdraw (if you have to, do consider doublebuffering), use MTRRs to enable write-combining if do you not intend to use the VGA read/write modes. Limit VGA register accesses to a minimum. Do not read from video memory. Use a real machine.
how do i read the pixel in 16 colour mode?
In VGA mode, use the VGA registers to select the correct plane you want to read from, and extract the corresponding bit.

Re: VGA speed (and one other vga issue)

Posted: Mon Feb 18, 2008 12:29 pm
by Ready4Dis
lukem_95 wrote:I am currently using VGA mode 320x200x256 and plotting pixels takes forever (about two seconds to fill the screen in virtualpc, slightly less in bochs/qemu). Is this just cos of the VGA mode (will it increase with a better mode, such as a VESA mode), or is it just my method of plotting pixels.

I have a put_pixel function that uses pokeb to poke the data into the correct address space. Should i use double buffering? Is there much speed increase?

and finally, for plotting my font i read the background colour and use this so i don't overwrite it when nothing should be written (if that makes sense).

how do i read the pixel in 16 colour mode?
Use a double buffer, and try to avoid plotting single pixels. A single memory copy to vga memory is much faster than a ton of peek/poke calls even in an emulator. Easiest way is to implement a few different types and benchmark them to find out the fastest method, and try it on a real pc, not emulator for a real test.

Re: VGA speed (and one other vga issue)

Posted: Mon Feb 18, 2008 1:58 pm
by jal
lukem_95 wrote:I have a put_pixel function that uses pokeb to poke the data into the correct address space.
put_pixel most likely calculates the destination address every time you put a pixel, right? That's a bit superfluous if you are writing contiguous pixels. Basic rule: never use a putpixel function unless you are actually writing random pixels.


JAL

Posted: Wed Feb 20, 2008 4:24 pm
by lukem95
wow... i am failing big time at both of these things :D

but i'm leaving speed optimisation till iv done some more GUI stuff, written a few drivers, and am ready to start making my GUI usable.

but for now, i put a pixel (in 16 colour mode) by using:

Code: Select all

void put_pixel_16(unsigned x, unsigned y, unsigned c)
{
	unsigned wd_in_bytes, off, mask, p, pmask;

	wd_in_bytes = g_wd / 8;
	off = wd_in_bytes * y + x / 8;
	x = (x & 7) * 1;
	mask = 0x80 >> x;
	pmask = 1;
	for(p = 0; p < 4; p++)
	{
		set_plane(p);
		if(pmask & c)
			vpokeb(off, vpeekb(off) | mask);
		else
			vpokeb(off, vpeekb(off) & ~mask);
		pmask <<= 1;
	}
}
now i'm ashamed to say i dont understand this code (well... i sort of do), but i cannot find a piece of text explaining how to plot pixels in 16 colour mode, so im having to use this.

Can somebody point me to something that explains what has to be done (with the bit masks etc), and then hopefully i'll understand how to read the pixel information at a certain offset.

thankyou, lukem

Posted: Thu Feb 21, 2008 1:18 am
by Combuster
pixel-access is the slowest way of writing 16-color screens. Each bit in the pixel is located in a different bank. you choose the bank (set_plane), read the original value, then write the new value with the appropriate bit masked out.

There's a pdf version of a book available that goes into speed and vga matters. Enjoy the read: http://www.byte.com/abrash/

Posted: Thu Feb 21, 2008 2:02 am
by jal
lukem_95 wrote:but i'm leaving speed optimisation till iv done some more GUI stuff, written a few drivers, and am ready to start making my GUI usable.

but for now, i put a pixel (in 16 colour mode) by using:
You started this thread complaining about slow performance in 256 colour mode. Now you say you do not want to optimize, and you are using 16 colour mode. That's slightly inconsistent!


JAL

Posted: Thu Feb 21, 2008 9:40 am
by lukem95
thanks for the link, ill give it a read when the server is back up (im getting a java error atm)

and yeah, im really just fiddling with VGA at the moment, i have two modes that i switch between, a 256 colour and a 16 colour mode.

sorry about the inconsistencies, i always feels im spamming a forum if i have too many topics at once. But i guess its poor practise to go so OT :S