Skip to content

Cache validated FBO configurations in debug builds#8491

Merged
mvaligursky merged 2 commits intomainfrom
mv_fbo-validation
Mar 3, 2026
Merged

Cache validated FBO configurations in debug builds#8491
mvaligursky merged 2 commits intomainfrom
mv_fbo-validation

Conversation

@mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Mar 2, 2026

Summary

  • Cache validated framebuffer configurations per device to avoid repeated gl.checkFramebufferStatus calls in debug builds
  • The check causes an expensive GPU sync (~16ms per call), which adds up significantly when loading multiple octree splat files that each trigger packGpuMemory
  • Uses DeviceCache to store a Set of validated configuration keys per device, keyed by color buffer formats, depth/stencil config, sample count, and FBO type
  • First render target of each unique configuration is still validated; subsequent ones with the same format combination skip the check entirely

…bufferStatus calls

In debug builds, gl.checkFramebufferStatus causes an expensive GPU sync (~16ms per call).
This caches validated framebuffer format configurations per device using DeviceCache, so
the check only runs once per unique combination of color formats, depth/stencil config,
and sample count. Subsequent render targets with the same configuration skip the check.

This is a debug-mode-only optimization - checkFramebufferStatus is already stripped from
production builds via Debug.call.

Made-with: Cursor
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes WebGL debug-mode render target initialization by caching framebuffer (FBO) completeness validation results per device, avoiding repeated gl.checkFramebufferStatus calls for previously validated attachment format configurations.

Changes:

  • Added a per-device cache (DeviceCacheSet) of validated FBO configuration keys.
  • Skips gl.checkFramebufferStatus when an equivalent configuration was already validated.
  • Clears cached validations on context loss via DeviceCache’s devicelost hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mvaligursky mvaligursky merged commit fec14d1 into main Mar 3, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv_fbo-validation branch March 3, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue performance Relating to load times or frame rate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants