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?
VGA speed (and one other vga issue)
Re: VGA speed (and one other vga issue)
afaik it woun't improve with VESAIs this just cos of the VGA mode (will it increase with a better mode, such as a VESA mode)
copy 4bytes at a time, that speeds it up tremendously (At least on emulators).lukem_95 wrote:I have a put_pixel function that uses pokeb to poke the data into the correct address space
Where is the problem? There are bitwise operations, you just have to extract the bits you want to read/write...how do i read the pixel in 16 colour mode?
- Combuster
- 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:
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.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.
In VGA mode, use the VGA registers to select the correct plane you want to read from, and extract the corresponding bit.how do i read the pixel in 16 colour mode?
Re: VGA speed (and one other vga issue)
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.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?
Re: VGA speed (and one other vga issue)
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.lukem_95 wrote:I have a put_pixel function that uses pokeb to poke the data into the correct address space.
JAL
wow... i am failing big time at both of these things
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:
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
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;
}
}
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
- Combuster
- 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:
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/
There's a pdf version of a book available that goes into speed and vga matters. Enjoy the read: http://www.byte.com/abrash/
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!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:
JAL
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
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