Skip to content

Commit c208085

Browse files
zbalatonkraxel
authored andcommitted
sm501: Optimise 1 pixel 2d ops
Some guests do 1x1 blits which is faster to do directly than calling a function for it so avoid overhead in this case. Signed-off-by: BALATON Zoltan <[email protected]> Reviewed-by: Peter Maydell <[email protected]> Message-id: 7cccc302d7b4c5c313bad7681ac4686417143c3e.1592686588.git.balaton@eik.bme.hu Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent 299778d commit c208085

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

hw/display/sm501.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,14 @@ static void sm501_2d_operation(SM501State *s)
794794
src_x == dst_x && src_y == dst_y) {
795795
break;
796796
}
797+
/* Some clients also do 1 pixel blits, avoid overhead for these */
798+
if (width == 1 && height == 1) {
799+
unsigned int si = (src_x + src_y * src_pitch) * bypp;
800+
unsigned int di = (dst_x + dst_y * dst_pitch) * bypp;
801+
stn_he_p(&s->local_mem[dst_base + di], bypp,
802+
ldn_he_p(&s->local_mem[src_base + si], bypp));
803+
break;
804+
}
797805
/* Check for overlaps, this could be made more exact */
798806
uint32_t sb, se, db, de;
799807
sb = src_base + src_x + src_y * (width + src_pitch);
@@ -842,9 +850,14 @@ static void sm501_2d_operation(SM501State *s)
842850
color = cpu_to_le16(color);
843851
}
844852

845-
pixman_fill((uint32_t *)&s->local_mem[dst_base],
846-
dst_pitch * bypp / sizeof(uint32_t),
847-
8 * bypp, dst_x, dst_y, width, height, color);
853+
if (width == 1 && height == 1) {
854+
unsigned int i = (dst_x + dst_y * dst_pitch) * bypp;
855+
stn_he_p(&s->local_mem[dst_base + i], bypp, color);
856+
} else {
857+
pixman_fill((uint32_t *)&s->local_mem[dst_base],
858+
dst_pitch * bypp / sizeof(uint32_t),
859+
8 * bypp, dst_x, dst_y, width, height, color);
860+
}
848861
break;
849862
}
850863
default:

0 commit comments

Comments
 (0)