Repository navigation
feat(core): add ctx.resetState() for raw WebGL in effects - #272
Merged
Merged
Conversation
…ects Closes #268 (parts 1, 2 and 4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HvSd5bHZgXPhSZ8RoTxUAn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HvSd5bHZgXPhSZ8RoTxUAn
|
🚀 Cloudflare Pages preview — 4d12c8f This branch URL stays the same across pushes. Latest deploy: https://980c155e.vfx-js.pages.dev |
- resetState() also resets clearColor; the player's per-frame clears rely on it. - ctx.gl docs: only ctx.draw/blit/clear turn off scissor, so call resetState() before render() returns too. List clearColor, transform feedback and UNPACK_COLORSPACE_CONVERSION_WEBGL in the assumed state. - Note that transform feedback must be ended before resetState(). - Tests: dispose no-op, object spread, and the remaining reset calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HvSd5bHZgXPhSZ8RoTxUAn
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.
Implements parts 1 and 4 of #268.
Changes
EffectContext.resetState(). It writes back the GL state the pipeline assumes, without anygetParameterper call (the texture unit count is queried once and cached):drawBuffers([BACK]), viewport to the whole canvasDEPTH_TEST,CULL_FACE,STENCIL_TEST,SCISSOR_TEST,BLEND,POLYGON_OFFSET_FILL,RASTERIZER_DISCARD,SAMPLE_ALPHA_TO_COVERAGE,SAMPLE_COVERAGEdisableddepthMask(true),depthFunc(LESS),colorMask(true × 4),stencilMask(~0),frontFace(CCW),cullFace(BACK),clearColor(0, 0, 0, 0)(the player's per-frame clears rely on it without setting it)ARRAY/PIXEL_PACK/PIXEL_UNPACK/UNIFORM/COPY_READ/COPY_WRITEbuffer bindings unboundTEXTURE0init()/update()too.ctx.gldoc comment now lists the state VFX-JS relies on. Onlyctx.draw/ctx.blit/ctx.clearturn off scissor; the rest of the frame doesn't, so the docs say to callresetState()before the nextctx.*call and beforerender()returns. It also notes that transform feedback must be ended first.skills/vfx-js/references/effects.md: addresetState()to the context table and a rule for raw GL use.@vfx-js/coreminor.Not included
ctx.rawGL(fn): it would only wraptry { fn(ctx.gl) } finally { ctx.resetState() }, so it was left out. It can be added later without a breaking change.Testing
pnpm --filter @vfx-js/core test(451 passed, 6 new forresetState)pnpm --filter @vfx-js/core lintpnpm --filter docs test