uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 68c3a8130195469e88aefaee6b91ec06c9218d85
parent 9b220a72d84f8c63addd2a4da6c6d293934ef7f7
Author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date:   Sun, 26 Dec 2021 13:53:23 +0100

ppu aarch64: clean up

Diffstat:
Msrc/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 @@ -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); } }