Skip to content

Custom renderer follow-ups: present handed-over GL textures, restore manual refresh mode - #92

Merged
diiviocity merged 2 commits into
vlang:masterfrom
diiviocity:feat/custom-renderer-followups
Oct 21, 2026
Merged

diiviocity merged 2 commits into
vlang:masterfrom
diiviocity:feat/custom-renderer-followups

Conversation

@diiviocity

Copy link
Copy Markdown
Member

Follow-ups to #47 (stacked on its integration commit — merge #47 first; this diff shrinks to these two commits once it lands).

gl_surface: present a handed-over texture without waiting for other work
set_gl_surface_texture only recorded the request; the new texture reached the screen when the next drawn frame synced it. On GL/D3D that arrives with the per-vsync re-present, but on Metal an idle on_demand window draws nothing and the update would sit until unrelated work invalidated the window. The producer's update now asks for one frame itself — the scheduler's queue is mutex guarded, so the ask is safe from the player thread.

Add the manual refresh mode back on top of the frame scheduler
RefreshMode.manual restores the fully ask-driven loop the old on_demand mode had: gg's ui_mode suppresses the frame callback between explicit asks (fully dark idle on GL too), refresh()/request_refresh() wake the loop through the coordinator's new mutex-guarded wake_fn hook, pending visual deadlines (tooltips, long-press) and running animations schedule their own continuation wakes, and the keep-alive thread stays off. on_demand and continuous keep flowing frame callbacks gated by the coordinator. Also fixes the double ui_mode: key the merge had left in new_context.

Verified: full tree parses clean under the latest upstream V (v fmt -c); the scheduler design was runtime-verified earlier (test files + the acceptance fixture under xvfb). Note the upstream V compiler panic/hang on full-module builds of current master is repo-wide and predates both PRs.

set_gl_surface_texture only recorded the request; the new texture reached
the screen when the next drawn frame synced it. On GL/D3D that arrives
with the per-vsync re-present, but on Metal an idle on_demand window draws
nothing and the update would sit until unrelated work invalidated the
window. Ask for one frame from the producer side — the scheduler's queue
is mutex guarded, so the ask is safe from the player thread.
.manual restores the fully ask-driven loop the on_demand mode had before
the scheduler took over: gg's ui_mode suppresses the frame callback
between asks, refresh()/request_refresh() wake it through the
coordinator's new wake_fn hook, and pending visual deadlines schedule
their own one-shot wake via the after() timer. on_demand and continuous
keep flowing frame callbacks and stay gated by the coordinator.

Also fixes the double ui_mode key the merge left in new_context.
@diiviocity
diiviocity force-pushed the feat/custom-renderer-followups branch from 032d240 to 678216e Compare October 21, 2026 01:25
@diiviocity
diiviocity merged commit 047232e into vlang:master Oct 21, 2026
0 of 6 checks passed
diiviocity added a commit that referenced this pull request Oct 21, 2026
V has no Go-style if-let: the checker rejected the statement expression
introduced in #92 and the calculator example failed to build. Split it
into a plain binding plus an if.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant