About migrating framebuffers in multi-GPU compositors

Hoosier, Matt Matt.Hoosier at garmin.com
Thu Mar 24 13:43:02 UTC 2022


On Thu, 2022-03-24 at 11:56 +0200, Pekka Paalanen wrote:

On Wed, 23 Mar 2022 14:19:08 +0000

"Hoosier, Matt" <

<mailto:Matt.Hoosier at garmin.com>

Matt.Hoosier at garmin.com

> wrote:


Hi,


I recently had a reason to wade through Mutter's code to support

systems with more than one GPU. I was a bit surprised to see that

it supports several different strategies for dealing with

scanning out a buffer on a KMS output not associated with the GPU

where the buffer was originally rendered.


Hi,


indeed. The reason for multiple paths is that different systems

don't support all ways, or do support some of the ways but the

performance might be abysmal. Knowing which path to take is a

difficult problem, and other than benchmarking (which I didn't

implement in Mutter) you can't really know if what you picked is

going to be fine.


In particular, the approach of using the secondary GPU's OpenGL

implementation to blit into a dumb buffer was really unexpected.

Typically, dumb buffers get described as a really slow, uncached

mapping of GPU memory into the CPU.


The support got added here (by Pekka):


<https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/615>

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/615



That MR is using the primary GPU to blit, not the secondary GPU.


If a secondary GPU can have a hardware accelerated OpenGL context,

I don't know why anyone would deliberately use dumb buffers on that

device with OpenGL. GBM offers better ways.



This MR cover letter has a better overview of all the methods:

<https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/810>

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/810

Ah, even nicer. Thanks!

In the ranked-order list of strategies there, the zero-copy technique is less preferred than the secondary GPU copy technique. Seems like you'd rarely ever fall through to the zero-copy strategy even if the GPU drivers do both support it. Anything subtle going on there that's good to be aware of? Like maybe a given driver typically supports secondary-GPU-copy XOR zero-copy, so you're fairly likely to reach the second strategy on systems that can handle it.




If I follow this right, the blit occurs directly between video

memory owned by the primary GPU into dumb-buffer memory owned by

the secondary GPU, without laboriously using the CPU to do PIO.


Correct.


Does this imply that the two GPUs' drivers have to be at least

minimally aware of each other to negotiate some kind of DMA path

directly between the two?


I don't know the details. It depends on whether you can map

secondary GPU memory to be written by the primary GPU. The specific

use case here is iGPU as primary and virtual as secondary, which

means that video memory for both is more or less "system RAM". No

discrete VRAM involved.

Oh interesting. I hadn't realized that on the hybrid GPU systems even the dGPU uses system RAM. But on thinking about it, that's probably the only efficient way for the hardware to be designed.



It is accomplished through the kernel dmabuf framework where

drivers export and import dmabuf.

Right, makes sense.

So I wonder how I should reason about a system that's configured with 2x of the same discrete graphics card (AMD, if it matters). The compositor would arbitrarly pick whichever of those happened to enumerate first as the primary, and then it's down to the driver details as to which of the four migration paths gets chosen? For the moment, let's assume that none of the stock applications is bothering to use any sort of advanced dmabuf hinting to pick the right GPU node to correspond to the output on which it will eventually display.

Thanks!
Matt

________________________________

CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be Garmin confidential and/or Garmin legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20220324/714d5419/attachment.htm>


More information about the wayland-devel mailing list