Skip to content

Add a multi-threaded compositor#5997

Open
Geenz wants to merge 10 commits into
developfrom
geenz/compositor
Open

Add a multi-threaded compositor#5997
Geenz wants to merge 10 commits into
developfrom
geenz/compositor

Conversation

@Geenz

@Geenz Geenz commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

This adds support for a multi-threaded compositor in the viewer to do things like separating the UI into its own thread, and eventually moving the renderer onto its own thread.

Geenz added 9 commits June 9, 2026 01:42
More or less mirrors swap chains from other APIs - and acts as an abstraction for future work.  Also gets us away from directly writing to FBO 0, which was complicating some other compositor work.
Ported from a previous LLCompositor branch - idea is to introduce thread safety between multiple OpenGL contexts.  Currently only used on LLRenderTarget and LLImageGL.
Multi-context compositor, test layers & sync

Add multi-context composition, threading, and test layers.  Also add some synchronization here - this still needs a better vsync signal, but that's likely to come as part of a new frame limiter setup.
- Supports VSync much better on macOS
- Use thread safe ref counting where we need it
- Make the swapchain less swapchain (more or less scaffolding right now) and have zero-copy writing to the back buffer.
- Simplify LLRenderTarget to be closer to its pre-compositor state
  - With the notable exception of we use LLImageGLs now instead of raw texture names
- Make leases opt-in rather than "everyone gets a lease"
@Geenz

Geenz commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

A few things to note:

  • Lots of on viewer thread asserts. Can probably back off of those - was kinda necessary initially given how much of the viewer assumed OS main (mostly in LLThread and friends, which had a knock on effect elsewhere). This helped to track a ton of races.
  • There's a good bit of race chasing in here due to that - so keep that in mind
  • The actual bits you should review are gonna be in LLCompositor and some of our platform specific bits (it'd be nice if someone could provide feedback on the macOS stuff)
  • The LLAppViewer compositable establishes a mailbox to get frames lined up for the compositor. When VSync is off this is gonna be upwards of 3 frames. When it's on, this is gonna be two. We always have a back and front buffer, all the third frame enables is us to "not care" what's going on with the compositor. Otherwise, compositor gets bounded on how fast the viewer can finish a frame
    • I anticipate this will eventually make it into a XUI (or whatever we end up with) refactor.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants