Draw actors at their sprite's height, and update each one once a frame
Closes Defects item 26 and Performance item 32. akgl_actor_render set dest.h from curSprite->width, so every actor was drawn square and a non-square sprite was stretched or squashed. Invisible in the fixtures because they are all square, so tests/actor.c gets a 48x24 sprite and a render backend whose draw_texture records the rectangle it is handed instead of drawing it. That recording backend is the first coverage akgl_actor_render has had at all -- every other test in the file stubs renderfunc out. akgl_game_update looped over AKGL_TILEMAP_MAX_LAYERS with the actor sweep nested inside it and never compared an actor's layer to the layer it was on, so every live actor's updatefunc ran sixteen times a frame. The sweep is hoisted out: updating an actor is not a per-layer operation, and akgl_render_2d_draw_world already walks the layers for the half that is. AKGL_ITERATOR_OP_LAYERMASK is honoured rather than ignored now, so a caller who wants one layer can still ask, and gets each of those actors once. Counting is the assertion, deliberately. The defect was invisible in the frame total because the tilemap blits are three orders of magnitude larger, so a timing test would have measured the rasterizer. tests/game.c counts calls into a stub updatefunc and reports 16 against the old code. PERFORMANCE.md records the timing side as what it honestly is: the gap between the akgl_game_update and draw_world rows of the same run, 92 us before and noise in both directions after. The absolute table is not re-taken -- a later run on this machine read every row about 15% high, including rows nothing has touched. 25/25 pass, reindent --check clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -712,11 +712,13 @@ static akerr_ErrorContext *bench_scene(void)
|
||||
* @brief Time a whole frame the way akgl_game_update runs one.
|
||||
*
|
||||
* This is the number a host actually gets, and it is not the sum of the parts.
|
||||
* akgl_game_update's update sweep is nested inside a loop over
|
||||
* #AKGL_TILEMAP_MAX_LAYERS and does not filter by layer, so every live actor is
|
||||
* updated sixteen times per frame rather than once. The gap between this
|
||||
* benchmark and the scene benchmark plus the logic frame in tests/perf.c is that
|
||||
* multiplier, and TODO.md carries it as a defect.
|
||||
*
|
||||
* It used to be measurably worse than that: the update sweep was nested inside
|
||||
* a loop over #AKGL_TILEMAP_MAX_LAYERS that never filtered by layer, so every
|
||||
* live actor updated sixteen times a frame, and this benchmark sat about 92 us
|
||||
* above the scene benchmark below it. That gap *was* the multiplier. Since
|
||||
* 0.5.0 the two are equal within run-to-run noise, which is the shape of the
|
||||
* fix rather than a number worth quoting on its own.
|
||||
*/
|
||||
static akerr_ErrorContext *bench_game_update(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user