Skip to content

Commit 414ef8a

Browse files
committed
use fast blits whenever possible - much faster scrolling
1 parent 417c06d commit 414ef8a

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

sys/dev/pci/mgafb.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mgafb.c,v 1.1 2026/03/17 10:03:02 macallan Exp $ */
1+
/* $NetBSD: mgafb.c,v 1.2 2026/03/17 12:51:37 macallan Exp $ */
22

33
/*
44
* Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
3333
*/
3434

3535
#include <sys/cdefs.h>
36-
__KERNEL_RCSID(0, "$NetBSD: mgafb.c,v 1.1 2026/03/17 10:03:02 macallan Exp $");
36+
__KERNEL_RCSID(0, "$NetBSD: mgafb.c,v 1.2 2026/03/17 12:51:37 macallan Exp $");
3737

3838
#include "opt_mgafb.h"
3939

@@ -1827,8 +1827,13 @@ mgafb_blit_rect(struct mgafb_softc *sc,
18271827
src_right = adj_srcy * pitch + srcx + w - 1;
18281828

18291829
mgafb_wait_fifo(sc, 7);
1830-
MGA_WRITE4(sc, MGA_DWGCTL, MGA_DWGCTL_COPY);
1831-
MGA_WRITE4(sc, MGA_SGN, sgn);
1830+
if ((srcx & 127) == (dstx & 127) && (sgn == 0)) {
1831+
/* fast copy */
1832+
MGA_WRITE4(sc, MGA_DWGCTL, MGA_DWGCTL_FASTCOPY);
1833+
} else {
1834+
MGA_WRITE4(sc, MGA_DWGCTL, MGA_DWGCTL_COPY);
1835+
MGA_WRITE4(sc, MGA_SGN, sgn);
1836+
}
18321837
MGA_WRITE4(sc, MGA_AR5, (uint32_t)ar5);
18331838
/* AR3 = scan start, AR0 = scan end */
18341839
if (sgn & MGA_SGN_BLIT_LEFT) {

sys/dev/pci/mgafbreg.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mgafbreg.h,v 1.1 2026/03/17 10:03:02 macallan Exp $ */
1+
/* $NetBSD: mgafbreg.h,v 1.2 2026/03/17 12:51:37 macallan Exp $ */
22

33
/*
44
* Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -62,16 +62,23 @@
6262
#define MGA_MACCESS_WRAM_INIT 0x00008000 /* trigger WRAM init cycle */
6363

6464
#define MGA_DWGCTL_BITBLT 0x00000008UL /* opcode: screen-to-screen */
65+
#define MGA_DWGCTL_FASTBLT 0x0000000cUL /* opcode: screen-to-screen */
6566
#define MGA_DWGCTL_RPL 0x00000000UL /* atype: replace */
6667
#define MGA_DWGCTL_BOP_COPY 0x000C0000UL /* bop: GXcopy */
6768
#define MGA_DWGCTL_SHIFTZERO 0x00004000UL /* shfzero: no pixel shift */
69+
#define MGA_DWGCTL_SGNZERO 0x00002000UL /* shfzero: no pixel shift */
6870
#define MGA_DWGCTL_BFCOL 0x04000000UL /* bfcol: source from WRAM */
6971

7072
/* Combined DWGCTL value for a plain screen-to-screen copy. */
7173
#define MGA_DWGCTL_COPY \
7274
(MGA_DWGCTL_BITBLT | MGA_DWGCTL_RPL | MGA_DWGCTL_BOP_COPY | \
7375
MGA_DWGCTL_SHIFTZERO | MGA_DWGCTL_BFCOL)
7476

77+
/* fast copy */
78+
#define MGA_DWGCTL_FASTCOPY \
79+
(MGA_DWGCTL_FASTBLT | MGA_DWGCTL_RPL | 0x000a0000 | \
80+
MGA_DWGCTL_SHIFTZERO | MGA_DWGCTL_SGNZERO | MGA_DWGCTL_BFCOL)
81+
7582
#define MGA_DWGCTL_TRAP 0x00000004UL /* opcode: trap/fill */
7683
#define MGA_DWGCTL_SOLID 0x00000800UL /* solid: fill from FCOL */
7784
#define MGA_DWGCTL_ARZERO 0x00001000UL /* arzero: AR regs = 0 */

0 commit comments

Comments
 (0)