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.

Render to a single context in HeadlessView #6212

Closed

Description

@mikemorris

The current HeadlessView rendering architecture was designed when each mbgl::Map rendered on its own thread, which necessitated the use of a unique GL context per map, as contexts are bound to a single thread. https://www.opengl.org/wiki/Memory_Model#Multiple_threads_and_contexts describes this in more detail.

Since #2909 moved all rendering onto the main thread, these per-map contexts should no longer be necessary. Because calls to glXMakeContextCurrent trigger an implicit glFlush, swapping these contexts could be causing unnecessary synchronization and possibly GL pipeline stalls.

I think that this change in combination with #477 could possibly remove all implicit flushes from the Node.js render pipeline.

I'm hoping to avoid revisiting old nightmares in cutting-room-floor/node-mapbox-gl-native#5 and cutting-room-floor/node-mapbox-gl-native#64 while implementing this. 😄

/cc @kkaefer @tmpsantos @tiagovignatti @miccolis

Activity

  1. added
    Node.js
    Core
    on Aug 30, 2016
  2. self-assigned this
    on Aug 30, 2016
  3. jfirebaugh commented on Sep 7, 2016

    @jfirebaugh
    Contributor

    This is going to require some careful review and perhaps modifications to the internals of Map, which currently makes optimizations based on the assumption that the View provides each Map with a unique context.

    I'm thinking mainly of gl::Config. If it's only used when actually painting (and not, say, opportunistically binding / uploading buffers as data comes in), and headless rendering only ever paints once per map, then this is probably safe. Otherwise, we need to ensure that setDirty() gets called whenever it's possible that the shared context was modified by another Map object.

  4. jfirebaugh commented on Sep 7, 2016

    @jfirebaugh
    Contributor

    Or better yet, have the view provide the gl::Config, and share it between Maps that are sharing a context.

  5. mikemorris commented on Sep 7, 2016

    @mikemorris
    ContributorAuthor

    Making a note to track #5938 and #5620, which fix a few bits of GL context state not yet tracked by gl::Config.

  6. tmpsantos commented on Sep 8, 2016

    @tmpsantos
    Contributor

    This is going to require some careful review and perhaps modifications to the internals of Map, which currently makes optimizations based on the assumption that the View provides each Map with a unique context.

    We already have the GLContextMode::Shared mode for that no?

  7. jfirebaugh commented on Sep 8, 2016

    @jfirebaugh
    Contributor

    GLContextMode::Shared indicates we're sharing the context with code we don't have control over, so must treat the gl::Config as dirty after every frame. But we can do better in this case.

  8. added
    archived
    on Nov 18, 2018
  9. stale commented on Nov 20, 2018

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

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

Metadata

Metadata

Assignees

Labels

CoreNode.jsarchived

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions