bevyengine / bevyengine/bevy

Multi-GPU Support

Open
#21,335 1 comment 0 reactions 0 assignees View on GitHub
A-Rendering C-Feature D-Complex S-Needs-Design X-Contentious
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Motivations

Creative technology applications, particularly large-scale installations, often run on media servers that may contain many GPUs in order to increase the number of physical outputs they can render to. While some technologies, like Nvidia's [Mosaic](https://www.nvidia.com/en-us/technologies/nvidia-mosaic/), help abstract over these multiple devices by presenting a single surface to render to, other use cases prefer fine grained management of render resources relative to each physical display. For example, an application may render to several overlapping projectors which are then "blended" together to create the illusion of a single large projection.

Support for multiple GPUs in other applications, for example [TouchDesigner](https://derivative.ca/UserGuide/Using_Multiple_Graphic_Cards), tends to be relatively poor and somewhat frustrating, requiring running multiple instances of the application per physical device and relying on techniques like shared memory in order to synchronize instances. On the contrary, as an ECS driven engine, Bevy is uniquely suited to support multiple GPUs inside a single application.

> [!IMPORTANT]
> Multiple GPUs are *not* used to increase rendering performance with respect to a single surface. Cross-GPU resource sharing is difficult, slow, and out of scope for this feature.

## Proposal

Rather than storing a single `Res`, we should change `RenderDevice` to be a component within the main world. Consequently, the render world should also become multiple, each storing a unique render device which can remain as `Res`.

`RenderTarget`s have a relationship to the `RenderDevice` that created them. This means that we can trivially exclude entities from rendering on a certain device simply by using `RenderLayers`.

## Drawbacks

The obvious downside is that this creates a bit more ceremony for the vast majority of users who will only ever encounter single GPU systems when interacting with a `RenderDevice` in the main world. While this is uncommon currently due to our render world patterns, our hope is that in the future we will be able to encourage more patterns that leverage resource creation in the main world. This would be particularly acute for engine code which would require always considering the possibility of multiple GPUs in the main world. Still, for most users who truly only care about a single device, they would simply be required to use `Single` which is only a small ergonomic regression over `Res`.

Contributor guide

Open the contributing guide

Research direction

Start by tracing RenderDevice, RenderTarget, and RenderLayers through Bevy's main-world and render-world architecture. Review how render devices and targets are currently stored and selected, then map the changes needed for multiple render worlds while preserving single-GPU ergonomics. Done means separate GPUs can render selected entities without cross-GPU resource sharing.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.