Expose independent frame presentation and emulated VBlank advancement

Open
#238 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
backend, game-dev

Research direction

Start with the referenced VSync implementation in psyz/src/psyz/libapi.c and Psyz_VideoVSync plus browser waiting in psyz/src/platform/sdl3_common.h; compare their responsibilities with related issue #232. Define an API contract that separates presentation, elapsed-time VBlank processing, and optional display waiting while specifying controller sampling, callbacks, suspension/resumption, and statistics. Done when the new opt-in path covers those behaviors and the existing PsyQ-compatible VSync behavior is preserved.

Written by the indexing model from the issue text.

Description

An application with a fixed simulation rate and interpolated rendering needs to present frames without waiting for, or generating, another emulated VBlank. We encountered this while adapting a game to run its simulation at 30 Hz and render at up to 120 Hz in the browser.

Currently VSync(0) combines presentation, waiting, controller sampling and kernel/VBlank callbacks. VSync(-1) reads the emulated clock, but does not perform the corresponding VBlank processing. There is no public presentation-only path in the tested revision.

Example workload

  1. Run an Emscripten application from requestAnimationFrame on a 120 Hz display.
  2. Advance game simulation in fixed 1/30-second steps and interpolate between snapshots.
  3. Present one frame per browser callback, while preserving the NTSC or PAL VBlank rate.

Calling VSync(0) for every rendered frame also invokes its waiting and VBlank processing. Reading VSync(-1) alone does not provide the missing presentation and interrupt-processing operations. The application needs these responsibilities to be independently accessible.

Requested capability

Provide an opt-in API to:

  • Present the current GPU output without waiting for another browser callback.
  • Advance emulated VBlank processing from elapsed emulated time, independently of rendered-frame count.
  • Wait for a display opportunity when the application does not already own the host frame loop.

Keep the existing PsyQ-compatible VSync behavior. Controller sampling, callbacks, suspension/resumption and presentation statistics need an explicit contract for the new path. Game simulation and object interpolation remain application responsibilities.

Local experiment

A local prototype separates non-waiting presentation from a VBlank pump. In the same Rewired browser test, over eight-second windows:

Path Simulation steps/s Render submissions/s Browser RAF callbacks/s Emulated VBlanks/s
Previous Rewired VSync loop 29.98 59.96 119.92 Not recorded
Separate presentation / clock 29.99 119.72 119.97 59.98

Rewired experiment: rendering increases while simulation remains unchanged

These are measurements of our port, which already has local PsyZ patches, not an unmodified-Psyz benchmark. Render submissions and RAF callbacks are not proof of physical screen presentation. This is an API request, not a claim that legacy VSync cannot support any high-refresh application.

Reference

Tested dependency: PsyZ 35c673ecf1c4ba799a812d701918c2c52935475b.

Related: #232. This issue focuses on API separation; changing browser main-loop ownership is a separate concern.

Dominant language
C
Stars
107
Forks
26
Avg merge
2d 21h
Merged PRs (30d)
5

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Xeeynamo/psyz

All issues in Xeeynamo/psyz

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.