From 68c3a8130195469e88aefaee6b91ec06c9218d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Sun, 26 Dec 2021 13:53:23 +0100 Subject: [PATCH] ppu aarch64: clean up --- src/devices/ppu_aarch64.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/devices/ppu_aarch64.c b/src/devices/ppu_aarch64.c index b6cf37a..6491336 100644 --- a/src/devices/ppu_aarch64.c +++ b/src/devices/ppu_aarch64.c @@ -4,25 +4,21 @@ void ppu_redraw(Ppu *p, Uint32 *screen) { - /* FIXME(sigrid): do this better */ - Uint32 *rgba = __builtin_assume_aligned(screen, 16); - Uint8 *fg = __builtin_assume_aligned(p->fg.pixels, 16); - Uint8 *bg = __builtin_assume_aligned(p->bg.pixels, 16); - Uint8 *palette = __builtin_assume_aligned((Uint8*)p->palette, 16); - uint8x16x4_t pal = vld4q_u8(palette); enum { R, G, B, A }; + uint8x16x4_t pal = vld4q_u8((Uint8*)p->palette); + Uint8 *fg = p->fg.pixels; + Uint8 *bg = p->bg.pixels; int i; - for(i = 0; i < p->width * p->height; i += 16, fg += 16, bg += 16, rgba += 16) { + for(i = 0; i < p->width * p->height; i += 16, fg += 16, bg += 16, screen += 16) { uint8x16_t fg8 = vld1q_u8(fg); uint8x16_t bg8 = vld1q_u8(bg); - uint8x16_t bgmask = vceqzq_u8(fg8); - uint8x16_t px8 = vorrq_u8(vandq_u8(bg8, bgmask), vandq_u8(fg8, vceqzq_u8(bgmask))); + uint8x16_t px8 = vbslq_u8(vceqzq_u8(fg8), bg8, fg8); uint8x16x4_t px = { - vqtbl1q_u8(pal.val[R], px8), - vqtbl1q_u8(pal.val[G], px8), - vqtbl1q_u8(pal.val[B], px8), - vqtbl1q_u8(pal.val[A], px8), + vqtbl1q_u8(pal.val[0], px8), + vqtbl1q_u8(pal.val[1], px8), + vqtbl1q_u8(pal.val[2], px8), + vdupq_n_u8(0xff), }; - vst4q_u8((uint8_t*)rgba, px); + vst4q_u8((uint8_t*)screen, px); } }