ppu aarch64: clean up

This commit is contained in:
Sigrid Solveig Haflínudóttir 2021-12-26 13:53:23 +01:00
parent 9b220a72d8
commit 68c3a81301
1 changed files with 10 additions and 14 deletions

View File

@ -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);
}
}