Skip to content

perf: skip redundant bindTexture in setTextureAt - #12

Draft
roncarbot wants to merge 2 commits into
devfrom
feature/render-perf
Draft

perf: skip redundant bindTexture in setTextureAt#12
roncarbot wants to merge 2 commits into
devfrom
feature/render-perf

Conversation

@roncarbot

Copy link
Copy Markdown

Summary

  • In TextureContextWebGL.setTextureAt, when the sampler already holds the requested texture, call bindTexture with check=true so the GL bind is skipped.
  • Still activates the texture unit and runs commit() so wrap/filter updates remain correct.

Measurements (Diggy_fixed, coolmath pixel-federation, with renderer E1)

Metric Baseline This PR (E1+E2) Delta
median frame ms 99.9 99.9 0
bindTexture/frame 233.26 ~0 -233
draw/frame 233.26 233.26 0

Frame time flat on Diggy (CPU/draw-bound at ~11 fps); clear GPU state-change proxy win.

SWF compatibility

  • Diggy title screen visual OK (960×720 canvas, PLAY UI, FPS overlay).

Companion: @awayjs/renderer PR awayjs/renderer#35

Test plan

  • Diggy / Burrito / FireBoy on localhost awayfl host
  • Confirm filters/RTT/mask paths still bind textures when sampler changes

When a sampler already holds the requested texture, avoid a second GL
bindTexture. Diggy stress: bindTexture/frame 233 → ~0 with no visual
regression on title screen.
Track the active sampler unit and skip gl.activeTexture when the unit
already holds the requested texture with unchanged sampler params.
Pairs with bindTexture skip; Diggy title median frame 99.9→83.4 ms on
SwiftShader harness (draws unchanged).
@roncarbot

Copy link
Copy Markdown
Author

E3 follow-up (c00c1c4)

Skip redundant gl.activeTexture when the sampler unit is already active and holds the same texture with unchanged wrap/filter params (_activateTextureUnit + _activeTextureUnit cache).

Diggy title @ SwiftShader harness

Metric E2 only E2+E3
median frame ms 99.9 83.4
bindTexture/frame ~0 ~0
draw/frame 233 233

Visual OK (title screen screenshot retained). Draws unchanged — CPU win from fewer GL state calls on software GL.

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