Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Optimize Extrusion drawing #9286

Closed

Description

@kkaefer

We should move the extrusion texture step to the beginning of a frame to improve rendering performance.

Right now, the workflow of a frame is like this:

  • (main framebuffer is bound)
  • Clear main framebuffer (✅ first operation is clear -> no restore)
  • Render some layers
  • Render extrusion layer
    • Bind extrusions framebuffer
    • Clear extrusions framebuffer (✅ first operation is clear -> no restore)
    • Draw extrusions
    • Bind main framebuffer
  • Draw extrusions texture (:warning: FBO restore)
  • Render remaining layers

When binding a framebuffer and rendering operations on it, the GPU has to restore the contents of the framebuffer. The driver can optimize that when we do a clear as the first drawing operation (since that discards the contents of the framebuffer). Therefore, drawing to the main framebuffer, then binding a different framebuffer, and rebinding the main framebuffer triggers a framebuffer load on the first draw call.

Instead, we could do all operations that require binding a separate framebuffer (i.e. drawing the extrusions texture) as the first thing when rendering a frame (i.e. before calling clear on the main framebuffer) and have the following order:

  • (main framebuffer is bound)
  • Create extrusion texture
    • Bind extrusions framebuffer
    • Clear extrusions framebuffer (✅ first operation is clear -> no restore)
    • Draw extrusions
    • Bind main framebuffer
  • Clear main framebuffer (✅ first operation is clear -> no restore)
  • Render some layers
  • Render extrusion texture
  • Render remaining layers

In addition to that, the iOS OpenGL inspector reports these issues when drawing extrusions:

  • Depth testing enabled without an attached depth buffer: Your app rendered with DEPTH_TEST enabled into a framebuffer without an attached depth buffer.
  • Missing framebuffer attachments: Framebuffer Lines #2 has no attachments and therefore is not usable in its current state.

These two errors may be the reason for #9279

Activity

  1. added
    Core
    on Jun 16, 2017
  2. mourner commented on Jun 16, 2017

    @mourner
    Member

    GL JS would benefit from this too, right?

  3. kkaefer commented on Jun 16, 2017

    @kkaefer
    MemberAuthor

    Yep

  4. lbud commented on Jun 16, 2017

    @lbud
    Contributor

    This sounds good. The one tradeoff here is that we may need to create and store multiple OffscreenTextures if there are multiple extrusion layers, but it sounds like the benefits here outweigh that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Corerendering

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions