Skip to content

Commit

Permalink
vga: optimize horizontal pel panning in 256-color modes
Browse files Browse the repository at this point in the history
Do not go through the panning buffer unless the address wraps in the middle
of the line.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Jan 18, 2024
1 parent 973a724 commit 4d6c310
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hw/display/vga-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ static void *vga_draw_line8d2(VGACommonState *vga, uint8_t *d,

palette = vga->last_palette;
hpel = (hpel >> 1) & 3;

/* For 256 color modes, we can adjust the source address and write directly
* to the destination, even if horizontal pel panning is active. However,
* the loop below assumes that the address does not wrap in the middle of a
* plane. If that happens...
*/
if (addr + (width >> 3) * 4 < VGA_VRAM_SIZE) {
addr += hpel * 4;
hpel = 0;
}

/* ... use the panning buffer as in planar modes. */
if (hpel) {
width += 8;
d = vga->panning_buf;
Expand Down

0 comments on commit 4d6c310

Please sign in to comment.