up to 8-vec

main
Henri Vasserman 2024-11-30 13:59:28 +02:00
parent 85281120a3
commit a659854c41
1 changed files with 12 additions and 9 deletions

View File

@ -27,19 +27,22 @@ Picture *Picture_new(SDL_Renderer *rend,
return p;
}
typedef uint32_t uint32_4 __attribute__ ((vector_size (4 * sizeof(uint32_t))));
typedef uint32_t uint32_8 __attribute__ ((vector_size (8 * sizeof(uint32_t))));
void Picture_render(Picture *p, SDL_Renderer *rend) {
int w = p->w, h = p->h;
uint32_4 c = {p->color, p->color, p->color, p->color};
const uint32_4 y0 = { 0, 0, 0, 0 };
const uint32_4 x0 = { 0, 1, 2, 3 };
uint32_4 y = y0 + p->y1;
uint32_8 c = {
p->color, p->color, p->color, p->color,
p->color, p->color, p->color, p->color
};
const uint32_8 y0 = { 0, 0, 0, 0, 0, 0, 0, 0 };
const uint32_8 x0 = { 0, 1, 2, 3, 4, 5, 6, 7 };
uint32_8 y = y0 + p->y1;
for (int j = 0, r = 0; j < h; j++, y += 1) {
uint32_4 x = x0 + p->x1;
for (int i = 0; i < w; i += 4, r += 4, x += 4) {
uint32_4 z = (x ^ y) % 9;
uint32_4 f = (z==0) & c;
uint32_8 x = x0 + p->x1;
for (int i = 0; i < w; i += 8, r += 8, x += 8) {
uint32_8 z = (x ^ y) % 9;
uint32_8 f = (z==0) & c;
memcpy(&p->pixels[r], (uint32_t*)&f, sizeof(f));
}
}