Skip to content

Reuse one renderbuffer for all draping. #10611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2021
Merged

Conversation

astojilj
Copy link
Contributor

@astojilj astojilj commented Apr 23, 2021

Every framebuffer currently instantiate own renderbuffer of (1024 x 1024 x depth24_stencil8 =) 4MB. Renderbuffers are lazily instantiated, when stencil is needed for draping and it is rarely needed as proxy tiles raster approach covers most of stenciling needs. E.g. when zooming out, 3 out of 50 render cache / pool framebuffers may need stenciling. This memory was accumulated and not released, with potential to grow up to (50 render cache tiles + 5 pool tiles) * 4MB = 220MB of renderbuffers. The PR is replacing this with one render buffer attached to all 55 framebuffers.

Verified on macos, iOS and Android (Nexus 5).

Spector capture information before 131MB (left) - after 11MB (right). Renderbuffer memory on screenshot includes depth FBO's renderbuffer (screen size) + 4MB for draping.
Screen Shot 2021-04-23 at 20 11 47

Every framebuffer currently instantiate own renderbuffer of (1024 x 1024 x depth24_stencil8 =) 4MB. Renderbuffers are lazily instantiated, when stencil is needed for draping and it is needed seldomly as proxy tiles raster cover most of stencil needs. E.g. when zooming out, 3 out of 50 render cache / pool framebuffers may need stencilling. This memory was accumulated and not released with potential growth to up to (50 render cache tiles + 5 pool tiles) * 4MB = 220MB of renderbuffers. The PR is replacing this with one render buffer attached to all 55 framebuffers.
@astojilj astojilj added performance ⚡ Speed, stability, CPU usage, memory usage, or power usage 3d 📐 labels Apr 23, 2021
@astojilj astojilj requested review from ansis and karimnaaji April 23, 2021 17:42
@astojilj astojilj self-assigned this Apr 23, 2021
Copy link
Contributor

@karimnaaji karimnaaji left a comment

Choose a reason for hiding this comment

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

Looks good, nice find! I added a minor commit with no functional change to make it a bit more explicit that we're sharing these renderbuffers.

}

_initFBOPool() {
while (this.pool.length < Math.min(FBO_POOL_SIZE, this.proxyCoords.length)) {
this.pool.push(this._createFBO());
this.pool.push(this._createFBO(this.pool.length > 0 ? this.pool[0].fb.depthAttachment.current : null));
Copy link
Contributor

Choose a reason for hiding this comment

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

Pushed a small simplification to make it more explicit that we're sharing the depth stencil between these framebuffers with this change in e9768c5 (with this.pool.length > 0 ? this.pool[0].fb.depthAttachment.current : null) here and this.pool[index % FBO_POOL_SIZE].fb.depthAttachment.current line 1001, I didn't find it immediately obvious where the depth attachment was coming from at framebuffer creation time).

@karimnaaji karimnaaji merged commit cfcd6cb into main Apr 29, 2021
@karimnaaji karimnaaji deleted the astojilj-reuseRenderBuffer branch April 29, 2021 19:16
@karimnaaji karimnaaji added this to the v2.3 milestone May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3d 📐 performance ⚡ Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants