Change a window’s VSync without disturbing another window - #186
Conversation
|
Thanks, the direction is right: swap interval is a per-context runtime knob on all three platforms, so a live Issues1. Linux regression: 2. Non-GL builds record a change that did not happen. 3. 4. Getter reports the cached bool, not the driver. Tests needed per platformThe CI matrix only compile-checks. This change is behavioural, so each platform needs a runtime test that creates a window, toggles Linux / X11
Windows
macOS
Emscripten
A single |
relh
left a comment
There was a problem hiding this comment.
[Codex, acting on behalf of relh]
Reviewed 604d266. The issues in André's existing review still apply at this head: Linux now attempts VSync setup even for vsync = false and can reject otherwise usable contexts without a supported extension; non-OpenGL backends can report a changed cached state without changing presentation; and setters can change the current window context. I found no additional distinct issue to add inline. The three-OS compile checks do not exercise those runtime/backend paths; this pass was source review only.
# Conflicts: # src/windy/platforms/macos/platform.nim
|
The review was right: the earlier compile-only checks did not establish runtime behavior. I fixed the context side effects, rejection of changes on application-owned presentation backends, and driver readback on Mac/Windows and GLX EXT/MESA. Linux now checks advertised extensions; the old branch accepted enable on my Mesa/Xvfb setup even though no swap-control extension was advertised. My first probe then crashed while attempting unsupported driver readback; that probe crash is not evidence that the setter itself crashed. The final integrated Mac test preserves a peer context, reads driver intervals 0 → 1 → 0, and renders 30 swaps in 33 ms → 311 ms → 6 ms. The native CPU build rejects the setter without changing its option. On Mesa/Xvfb, creating and retaining a disabled window works and unsupported enable is rejected. That server has no swap-control extension, so it cannot prove the successful EXT/MESA/SGI paths. The single focused runtime test is in the existing CI matrix, including Windows CPU and an OpenGL run with Mesa. The first Windows attempt exposed a test setup error: nim r put its executable in the cache, away from the Mesa DLLs. The updated command places it beside the DLLs. I am checking the final run rather than treating compile success as validation. Physical Windows/Linux pacing, successful SGI/MESA operation, and non-CPU alternative presentation backends still need runtime evidence. I have kept those limits in the PR description instead of marking the whole review satisfied. |
A game may need to change OpenGL VSync without recreating its window. The previous PR could switch the current rendering context, report a change on a backend it did not control, or call a GLX extension the server did not support.
The setter now preserves the caller’s context. macOS and Windows read the driver’s interval; Linux checks advertised extensions and verifies EXT/MESA readback. An initially disabled Linux window works without swap control. Unsupported enable requests raise an error; SGI cannot turn an already enabled interval off. CPU, Metal, DirectX, and Vulkan setters reject changes because the application owns presentation there. Browser VSync remains controlled by the browser.
Validation:
Physical Windows/Linux pacing, SGI/MESA success paths, and native non-CPU alternative backends still need runtime evidence. These limits are not covered by the Mac result.
Current CI run passed on Linux, macOS, and Windows. The runtime limits above still apply.