Normal quotes
This commit is contained in:
parent
5e10794a24
commit
18011c595a
352 changed files with 6040 additions and 6040 deletions
32
45-02.md
32
45-02.md
|
|
@ -5,15 +5,15 @@
|
|||
Of course, VGA display memory has its own performance problems. The
|
||||
fastest ISA bus VGA can, at best, support sustained write times of about
|
||||
10 cycles per word-sized write on a 486/33; 15 or 20 cycles is more
|
||||
common, even for relatively fast SuperVGAs; the worst case I’ve seen is
|
||||
common, even for relatively fast SuperVGAs; the worst case I've seen is
|
||||
65 cycles per byte. However, intermittent writes, mixed with a lot of
|
||||
register and cache-only code, can effectively execute in one cycle,
|
||||
thanks to the caching design of many VGAs and the 486’s 4-deep write
|
||||
thanks to the caching design of many VGAs and the 486's 4-deep write
|
||||
buffer, which stores pending writes while the CPU continues executing
|
||||
instructions. Display memory reads tend to take longer, because
|
||||
coprocessing isn’t possible—one microsecond is a reasonable rule of
|
||||
thumb for VGA reads, although there’s considerable variation. So VGA
|
||||
memory tends not to be as bad as VGA I/O, but lord knows it isn’t
|
||||
coprocessing isn't possible—one microsecond is a reasonable rule of
|
||||
thumb for VGA reads, although there's considerable variation. So VGA
|
||||
memory tends not to be as bad as VGA I/O, but lord knows it isn't
|
||||
*good*.
|
||||
|
||||
* * * * *
|
||||
|
|
@ -102,8 +102,8 @@ bit-mask register. When you must use the bit mask, arrange drawing so
|
|||
that you can set the bit mask once, then do a lot of drawing with that
|
||||
mask. For example, draw a whole edge at once, then the middle, then the
|
||||
other edge, rather than setting the bit mask several times on each scan
|
||||
line to draw the edge and middle bytes together. Don’t read from display
|
||||
memory if you don’t have to. Write each pixel once and only once.
|
||||
line to draw the edge and middle bytes together. Don't read from display
|
||||
memory if you don't have to. Write each pixel once and only once.
|
||||
|
||||
It is indeed a strange concept: The key to fast graphics is staying away
|
||||
from the graphics adapter as much as possible.
|
||||
|
|
@ -111,12 +111,12 @@ from the graphics adapter as much as possible.
|
|||
### Dirty-Rectangle Animation {#Heading5}
|
||||
|
||||
The relative slowness of VGA hardware is part of the appeal of the
|
||||
technique that I call “dirty-rectangle” animation, in which a complete
|
||||
technique that I call "dirty-rectangle" animation, in which a complete
|
||||
copy of the contents of display memory is maintained in offscreen system
|
||||
(nondisplay) memory. All drawing is done to this system buffer. As
|
||||
offscreen drawing is done, a list is maintained of the bounding
|
||||
rectangles for the drawn-to areas; these are the *dirty rectangles*,
|
||||
“dirty” in the sense that that have been altered and no longer match the
|
||||
"dirty" in the sense that that have been altered and no longer match the
|
||||
contents of the screen. After all drawing for a frame is completed, all
|
||||
the dirty rectangles for that frame are copied to the screen in a burst,
|
||||
and then the cycle of off-screen drawing begins again.
|
||||
|
|
@ -124,8 +124,8 @@ and then the cycle of off-screen drawing begins again.
|
|||
Why, exactly, would we want to go through all this complication, rather
|
||||
than simply drawing to the screen in the first place? The reason is
|
||||
visual quality. If we were to do all our drawing directly to the screen,
|
||||
there’d be a lot of flicker as objects were erased and then redrawn.
|
||||
Similarly, overlapped drawing done with the painter’s algorithm (in
|
||||
there'd be a lot of flicker as objects were erased and then redrawn.
|
||||
Similarly, overlapped drawing done with the painter's algorithm (in
|
||||
which farther objects are drawn first, so that nearer objects obscure
|
||||
them) would flicker as farther objects were visible for short periods.
|
||||
With dirty-rectangle animation, only the finished pixels for any given
|
||||
|
|
@ -144,21 +144,21 @@ solves these problems.
|
|||
|
||||
Well, then, if we want good visual quality, why not use page flipping?
|
||||
For one thing, not all adapters and all modes support page flipping. The
|
||||
CGA and MCGA don’t, and neither do the VGA’s 640x480 16-color or 320x200
|
||||
CGA and MCGA don't, and neither do the VGA's 640x480 16-color or 320x200
|
||||
256-color modes, or many SuperVGA modes. In contrast, *all* adapters
|
||||
support dirty-rectangle animation. Another advantage of dirty-rectangle
|
||||
animation is that it’s generally faster. While it may seem strange that
|
||||
animation is that it's generally faster. While it may seem strange that
|
||||
it would be faster to draw off-screen and then copy the result to the
|
||||
screen, that is often the case, because dirty-rectangle animation
|
||||
usually reduces the number of times the VGA’s hardware needs to be
|
||||
usually reduces the number of times the VGA's hardware needs to be
|
||||
touched, especially in 256-color modes.
|
||||
|
||||
This reduction comes about because when dirty rectangles are erased,
|
||||
it’s done in system memory, not in display memory, and since most
|
||||
it's done in system memory, not in display memory, and since most
|
||||
objects move a good deal less than their full width (that is, the new
|
||||
and old positions overlap), display memory is written to fewer times
|
||||
than with page flipping. (In 16-color modes, this is not necessarily the
|
||||
case, because of the parallelism obtained from the VGA’s planar
|
||||
case, because of the parallelism obtained from the VGA's planar
|
||||
hardware.) Also, read/modify/write operations are performed in fast
|
||||
system memory rather than slow display memory, so display memory rarely
|
||||
needs to be read. This is particularly good because display memory is
|
||||
|
|
|
|||
Loading…
Reference in a new issue