Skip to content

Multi-GPU support

Michael Tretter requested to merge m.tretter/weston:multi-gpu into main

Add Multi-GPU support to the DRM backend. This allows to run a single Weston instance on a system with multiple DRM devices. A primary DRM device is used for the renderer and as scanout. Additional DRM devices are used only as scanout and the rendering for the additional DRM devices is done on the primary DRM device.

Multi-GPU support is enabled by using the --additional-devices parameter to start Weston: weston --drm-device=card1 --additional-devices=card0

There are still various open issues, and further testing is necessary, but I would like to get some feedback on the general approach and pointers, if I am missing something important.

Test environment

I am using a setup with an Advanced Micro Devices, Inc. [AMD/ATI] Turks PRO [Radeon HD 6570/7570/8550] as renderer and an Intel Corporation HD Graphics 530 (rev 06) as scanout device.

There are various other limitations which setups can be used with this. For example, using the Intel GPU for rendering and the AMD GPU for scanout does not work, since the Upload to VRAM isn't working.

Architecture

The DRM backend assumed that there is only a single DRM device. The merge requests extracts a new struct struct drm_device from struct drm_backend which represents exactly one DRM device. This allows to add more DRM devices to the DRM backend.

There is still a single GBM device, which belongs to the primary DRM device. This device will be used for rendering.

Each DRM output keeps a pointer to the device, which they belong to. This allows to prepare the drm_output_state for the device that will actually show the output. The drm_fbs will be retrieved by importing gbm_bos from the GBM device into the DRM device of the respective output, if necessary.

The drm_pending_state is now per device instead of per backend, which made it impossible to pass the drm_pending_state as repaint_data through the repaint handler. Therefore, the drm_backend is now responsible for tracking the repaint state across repaint_begin, weston_output_maybe_repaint, repaint_flush, and repaint_cancel.

As a side note: I tried to implement the additional devices as a separate backend-kms, but gave up, since there were just too many locations that assumed the struct drm_backend to be available (e.g., the entire logging). Therefore, the Multi-GPU support is now built in into the DRM backend.

Open Issues

  • I was not able to run the DRM backend tests, yet. I have separate machines for building and testing and don't have the build environment available on my test machine, yet. I want to run the DRM backend tests, but I have to figure out, how.

  • Cursors use shm buffers, which need to be imported into the drm device that belongs to the output. This is currently not fully implemented, and cursors will be invisible if the additional device has a cursor plane.

  • I am not sure, if the error handling in the repaint handler is correct. Thus, it is probably broken, but I have to think about it.

Edited by Michael Tretter

Merge request reports