Brendan wrote:Hi,
mallard wrote:If you're going to write the same byte(s) to multiple bitplanes, you can use the slightly more advanced features of the VGA and get even better performance...
Yes; but software should never work like that.
Why on earth not? If your video driver model provides a higher-level API than just simple pixel access, it's fairly easy to provide these sorts of optimisations, while keeping application software generic. I know 2D acceleration has gone out of fashion these days, but it's still there and still provides advantages over the simple "framebuffer" model, especially when, like on the VGA, there isn't a nice byte-aligned linear framebuffer.
Brendan wrote:
Mostly (to avoid tearing and other unwanted effects) you should have a buffer in normal RAM, do all the drawing in that buffer, then copy from buffer to display memory as fast as possible (e.g. while avoiding areas that weren't changed, and using a "rep movsd" to minimise PCI bus transactions).
While that's a perfectly reasonable and common approach (and one that Michael talks about), it's not necessarily the fastest way to do it, depending on the circumstances. (Also, note that there's not enough time to write the entire screen is the vertical refresh interval and the VGA doesn't have enough memory to do page-flipping at 640x480x4bpp, so tearing is inevitable when a high proportion of the screen changes).
There's always a cost/benefit tradeoff. My video driver model requires that the driver provide read/write/seek methods on what appears to be a linear framebuffer. That means that for VGA, the driver has to convert the data between planar and linear formats and the best optimisation that can be done is limiting plane switches to 4 per read/write operation. That's mostly good enough for my purposes.
However, if I were, for instance, implementing a unicode-based software text-mode within the VGA driver, better use of the VGA hardware would certainly be considered.