diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-16 09:33:39 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-16 09:33:39 +0300 |
| commit | a075a2941f8fcdae155495da634cf63368c950b7 (patch) | |
| tree | a33b5636ef7b9e4879cb8ab52220e805a5e30348 /tests/common/test_gl.c | |
| parent | c2832a63547e6328afde25bb3b8145267eadef47 (diff) | |
Pace frame requests by the frame presented after them
A frame request now only records intent. Each loop step resolves it after
the callbacks that present, so a request made before the present waits for
that frame. An animation that asked first got two REFRESH events per frame
on X11 and with GL.
With no frame in flight, the REFRESH comes one refresh interval after the
last present or answer, so a request without a present cannot spin.
Queued events now go before an owed REFRESH. Input reaches the application
before it draws, and a queued REFRESH pays an owed one for the same surface.
The loop prepare only peeks at a lost event, so deliver can report it as a
final loss. A failed push from another thread wakes the loop.
Signals and posts run at the end of a step, after descriptors and timers.
A signal handler now sees the output that came with it.
A render-thread GL swap counts as in flight on Wayland.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/common/test_gl.c')
| -rw-r--r-- | tests/common/test_gl.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/common/test_gl.c b/tests/common/test_gl.c index 1bb5bec..0b91bff 100644 --- a/tests/common/test_gl.c +++ b/tests/common/test_gl.c @@ -146,6 +146,25 @@ int main(int argc, char **argv) clear(GL_COLOR_BUFFER_BIT_); REQUIRE((yasl_gl_present(primary) == 0), "swap resized GL surface"); + /* An animation that asks for each next frame gets one REFRESH per frame + * shown, even though GL surfaces also get a REFRESH when a frame is shown. */ + REQUIRE(yasl_surface_request_frame(primary) == 0, "request a frame"); + int frames = 0; + double animation_end = seconds_now() + 1.0; + while (seconds_now() < animation_end) { + yasl_event event = {0}; + int result = yasl_wait_event(&event, 50); + REQUIRE(result >= 0, "wait during animation"); + if (result == 0 || event.type != YASL_EVENT_REFRESH || event.surface != primary) + continue; + frames++; + REQUIRE(yasl_surface_request_frame(primary) == 0, "request the next frame"); + clear(GL_COLOR_BUFFER_BIT_); + REQUIRE(yasl_gl_present(primary) == 0, "present an animation frame"); + } + fprintf(stderr, "%d REFRESH events in 1 s of GL animation\n", frames); + REQUIRE(frames >= 20 && frames <= 75, "one REFRESH per frame shown"); + REQUIRE(yasl_surface_create(&(struct yasl_surface_options){.title="invalid attrs", .width=100, .height=100, .type=YASL_SURFACE_GL, .gl = {.major = -1}}) == NULL && errno == EINVAL, "reject invalid GL context options"); cpu = yasl_surface_create(&(struct yasl_surface_options){.title="CPU surface", .width=100, .height=100}); |
