feat(lambda-rs): Expose vsync and present modes in RenderContextBuilder
#122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add user-configurable presentation mode (VSync) support to the rendering API.
This change exposes controls for selecting the swapchain present mode, allowing
applications to choose between VSync-enabled rendering, immediate presentation,
or triple buffering (mailbox) for their desired latency/tearing tradeoffs.
Related Issues
Changes
PresentModeenum tolambda-rswithVsync,Immediate, andMailboxvariants
with_vsync(bool)convenience method toRenderContextBuilderwith_present_mode(PresentMode)for explicit mode selectionselect_present_modehelper in platform layer with intelligentfallback logic when requested mode is unavailable
WindowBuilder::with_vsyncto influence default present mode when noexplicit mode is provided to the renderer
WindowBuilderfromfalsetotrueType of Change
Affected Crates
lambda-rslambda-rs-platformlambda-rs-argslambda-rs-loggingChecklist
cargo +nightly fmt --all)cargo clippy --workspace --all-targets -- -D warnings)cargo test --workspace)Testing
cargo build --workspace cargo test --workspaceManual verification steps (if applicable):
cargo run --example minimaland observe the window uses Mailbox modePresentMode::Vsyncand verify VSync behaviorPresentMode::Immediateand verify uncapped FPSScreenshots/Recordings
Platform Testing
Additional Notes
The present mode can be configured in two ways:
Via
RenderContextBuilder(recommended for explicit control):Via
WindowBuilder(legacy/convenience):Fallback Behavior
When the requested present mode is not supported by the adapter, the platform
layer selects a fallback with similar behavior:
Immediate→ triesMailbox→AutoNoVsync→FifoMailbox→ triesFifo→AutoVsyncVsync(Fifo) → triesAutoVsync→FifoRelaxed→ other modesDefault Behavior Change
The default VSync preference in
WindowBuilderchanged fromfalsetotrue.This aligns with common expectations that applications should not tear by
default. Applications wanting uncapped frame rates should explicitly request
PresentMode::Immediateor callwith_vsync(false).