apps/examples/circle-raster: add acc precalc method
This commit is contained in:
parent
ab3c032313
commit
dd158dee01
@ -76,6 +76,26 @@ static void benchmark(struct state *state) {
|
|||||||
|
|
||||||
profile_end("int32_t acc");
|
profile_end("int32_t acc");
|
||||||
|
|
||||||
|
profile_start("int32_t acc precalc");
|
||||||
|
|
||||||
|
for (int i = 0; i < 1000; ++i) {
|
||||||
|
int32_t const rsi = (int32_t)state->r * (int32_t)state->r;
|
||||||
|
int32_t acc = (int32_t)(sqrtf(state->r * state->r - (state->r - 1) * (state->r - 1)));
|
||||||
|
for (int32_t iy = (int32_t)state->r - 1; iy >= 0; --iy) {
|
||||||
|
while (acc * acc < rsi - iy * iy) acc++;
|
||||||
|
for (int32_t ix = -acc; ix < acc; ++ix) {
|
||||||
|
/* lower portion */
|
||||||
|
x = (float)ix;
|
||||||
|
y = (float)iy;
|
||||||
|
/* upper portion */
|
||||||
|
x = (float)ix;
|
||||||
|
y = (float)(int32_t)(~(uint32_t)iy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
profile_end("int32_t acc precalc");
|
||||||
|
|
||||||
(void)x; (void)y;
|
(void)x; (void)y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +105,7 @@ void game_tick(void) {
|
|||||||
if (!ctx.udata) {
|
if (!ctx.udata) {
|
||||||
ctx.udata = ccalloc(1, sizeof (struct state));
|
ctx.udata = ccalloc(1, sizeof (struct state));
|
||||||
struct state *state = ctx.udata;
|
struct state *state = ctx.udata;
|
||||||
state->r = 10;
|
state->r = 24;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user