diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2024-04-02 12:31:35 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2024-04-18 11:17:27 +0200 |
commit | ab75ecb79be3b856f63bef4c91aef0dc17d405cb (patch) | |
tree | 04370c6fac0ffbe5a5b9af31ac40a69aa86e4450 /hw | |
parent | 748e62dbf5065c7d166c827425c7797389b5f9fe (diff) |
vga: optimize computation of dirty memory region
The depth == 0 and depth == 15 have to be special cased because
width * depth / 8 does not provide the correct scanline length.
However, thanks to the recent reorganization of vga_draw_graphic()
the correct value of VRAM bits per pixel is available in "bits".
Use it (via the same "bwidth" computation that is used later in
the function), thus restricting the slow path to the wraparound case.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/display/vga.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/hw/display/vga.c b/hw/display/vga.c index 77f59e8c11..77d709a3d6 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1574,22 +1574,16 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) /* Horizontal pel panning bit 3 is only used in text mode. */ hpel = bits <= 8 ? s->params.hpel & 7 : 0; - - region_start = (s->params.start_addr * 4); - region_end = region_start + (ram_addr_t)s->params.line_offset * height; - region_end += width * depth / 8; /* scanline length */ - region_end -= s->params.line_offset; + bwidth = DIV_ROUND_UP(width * bits, 8); /* scanline length */ if (hpel) { - region_end += 4; + bwidth += 4; } - if (region_end > s->vbe_size || depth == 0 || depth == 15) { + + region_start = (s->params.start_addr * 4); + region_end = region_start + (ram_addr_t)s->params.line_offset * (height - 1) + bwidth; + if (region_end > s->vbe_size) { /* - * We land here on: - * - wraps around (can happen with cirrus vbe modes) - * - depth == 0 (256 color palette video mode) - * - depth == 15 - * - * Take the safe and slow route: + * On wrap around take the safe and slow route: * - create a dirty bitmap snapshot for all vga memory. * - force shadowing (so all vga memory access goes * through vga_read_*() helpers). @@ -1667,10 +1661,6 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) s->params.line_compare, sr(s, VGA_SEQ_CLOCK_MODE)); #endif addr1 = (s->params.start_addr * 4); - bwidth = DIV_ROUND_UP(width * bits, 8); - if (hpel) { - bwidth += 4; - } y_start = -1; d = surface_data(surface); linesize = surface_stride(surface); |