renderer: add present() for a single explicit frame - #6
Open
shadowcodex wants to merge 1 commit into
Open
Conversation
|
@shadowcodex is attempting to deploy a commit to the Eric Rowell's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
renderer.present(callback): draw exactly one frame, now.Why
loopis the only way to draw, and it ownsrequestAnimationFrame. That is the right default, but it rules out two cases:Both currently end up calling
loopand stopping it immediately, which is a scheduler round-trip to do something synchronous.What changed
presentisloop's body with the scheduling removed: resize, begin the pass, run the callback, submit.loopnow calls it, so there is one implementation of a frame, not two — a fix that skipped the resize or the submit in one path could not be made in only one of them.The signature takes
() => voidrather than(elapsedSeconds: number) => void. A caller doing its own scheduling already knows its own clock, and inventing a second one inside the renderer would give it a different origin from the one it is stepping its simulation with.Tests
A check in
scripts/gpu/entry.ts: draw a known target throughpresent()with no loop anywhere, and read the canvas back. It also covers the extraction — apresentthat dropped the resize or the submit would leave the canvas untouched and fail here.318 tests pass,
npm run typecheckclean, and Chrome/WebGPU passes the new check. WebKit did not run locally —playwright-core install webkitwas missing in my environment, unrelated to this change.Context
One of four focused PRs replacing #2. Independent of the other three. We carry it as a local patch over the published package today, so there is no urgency from our side.
Over to you
Genuine questions, not politeness: