Bug 495788 - Corrupted screenshare on multi-GPU system
Summary: Corrupted screenshare on multi-GPU system
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: screencasting (show other bugs)
Version: 6.2.2
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-04 12:20 UTC by shibe99
Modified: 2024-11-04 21:34 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Example of OBS running on integrated GPU (using DRI_PRIME=1!) and attempting to screenshare (760.35 KB, image/png)
2024-11-04 12:20 UTC, shibe99
Details
output of wayland-info (18.71 KB, text/plain)
2024-11-04 12:21 UTC, shibe99
Details

Note You need to log in before you can comment on or make changes to this bug.
Description shibe99 2024-11-04 12:20:45 UTC
Created attachment 175513 [details]
Example of OBS running on integrated GPU (using DRI_PRIME=1!) and attempting to screenshare

SUMMARY
I have a system with two GPUs, the one built-in to the 7800x3d and my dedicated GPU is a Radeon RX580. When running applications on a different GPU, I can not use the screensharing portal from that application as it results in corrrupted output. Applications running on the other GPU display properly but if from inside that application I attempt to screenshare I get something like what I've attached.

I have reproduced it both ways. In my usual setup I have all display outputs connected to the dedicated GPU, and if I open OBS/Firefox/Chrome (or any other application with screensharing functionality) I get corrupted output. If I switch all my outputs to my iGPU, restart KDE and then run OBS on my dedicated GPU, then I get corrupted output.

For what it is worth, this does not seem to be a kde-only issue either, the same happens in Hyprland using their portal. If I were to guess it is because my dedicated GPU does not support modifiers at all (only LINEAR it seems), and otherwise uses INVALID/internal modifiers. But I have a feeling this might still be a portal bug since I don't think portals should give buffers with internal modifiers but maybe a linear copy instead. I have attached wayland-info output for this as well.



STEPS TO REPRODUCE
1. Use a multi-gpu setup, open an application using an alternate GPU and attempt to screenshare
2. Select any window/display/etc in the screen share portal

OBSERVED RESULT
Corrupted output


SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.2
KDE Frameworks Version: 6.7.0
Qt Version: 6.8.0
Kernel Version: 6.11.6-cb3.0.lto.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 7800X3D 8-Core Processor
Memory: 30.5 GiB of RAM
Graphics Processor: AMD Radeon Graphics


ADDITIONAL INFORMATION
Here is some output from OBS that might be useful
info: [pipewire] Created stream 0x5f42746152e0
info: [pipewire] Stream 0x5f42746152e0 state: "connecting" (error: none)
info: [pipewire] Playing stream 0x5f42746152e0
info: [pipewire] Stream 0x5f42746152e0 state: "paused" (error: none)
info: [pipewire] Negotiated format:
info: [pipewire]     Format: 12 (Spa:Enum:VideoFormat:BGRA)
info: [pipewire]     Modifier: 0x0
info: [pipewire]     Size: 1920x1080
info: [pipewire]     Framerate: 0/1
info: [pipewire] Negotiated format:
info: [pipewire]     Format: 12 (Spa:Enum:VideoFormat:BGRA)
info: [pipewire]     Modifier: 0xffffffffffffff
info: [pipewire]     Size: 1920x1080
info: [pipewire]     Framerate: 0/1
Comment 1 shibe99 2024-11-04 12:21:06 UTC
Created attachment 175514 [details]
output of wayland-info
Comment 2 Zamundaaa 2024-11-04 21:34:29 UTC
> If I were to guess it is because my dedicated GPU does not support modifiers at all (only LINEAR it seems), and otherwise uses INVALID/internal modifiers. But I have a feeling this might still be a portal bug since I don't think portals should give buffers with internal modifiers but maybe a linear copy instead
The problem is that with implicit modifiers, there's no way to tell the other application that we're making the buffer linear.

Maybe we can special case the situation where the receiving application requests explicit modifiers and we don't support them (-> definitely on another GPU), and claim only a linear modifier as supported... that *might* work out for your case.
For a more general fix for when the receiving application only does implicit modifiers, we'd likely need pipewire to add new API and apps would need to use it, so that we can tell them the buffer is linear.