mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-01-17 10:15:42 +00:00
Improve KMS debuggability and avoid known broken cases
This commit is contained in:
parent
e383ab9956
commit
d8877982ff
@ -15,6 +15,7 @@
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
|
||||
#include "src/config.h"
|
||||
#include "src/logging.h"
|
||||
#include "src/platform/common.h"
|
||||
#include "src/round_robin.h"
|
||||
@ -298,6 +299,9 @@ namespace platf {
|
||||
return -1;
|
||||
}
|
||||
|
||||
version_t ver { drmGetVersion(fd.el) };
|
||||
BOOST_LOG(info) << path << " -> "sv << ((ver && ver->name) ? ver->name : "UNKNOWN");
|
||||
|
||||
// Open the render node for this card to share with libva.
|
||||
// If it fails, we'll just share the primary node instead.
|
||||
char *rendernode_path = drmGetRenderDeviceNameFromFd(fd.el);
|
||||
@ -316,12 +320,21 @@ namespace platf {
|
||||
}
|
||||
|
||||
if (drmSetClientCap(fd.el, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) {
|
||||
BOOST_LOG(error) << "Couldn't expose some/all drm planes for card: "sv << path;
|
||||
BOOST_LOG(error) << "GPU driver doesn't support universal planes: "sv << path;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (drmSetClientCap(fd.el, DRM_CLIENT_CAP_ATOMIC, 1)) {
|
||||
BOOST_LOG(warning) << "Couldn't expose some properties for card: "sv << path;
|
||||
BOOST_LOG(warning) << "GPU driver doesn't support atomic mode-setting: "sv << path;
|
||||
#if defined(SUNSHINE_BUILD_X11)
|
||||
// We won't be able to capture the mouse cursor with KMS on non-atomic drivers,
|
||||
// so fall back to X11 if it's available and the user didn't explicitly force KMS.
|
||||
if (window_system == window_system_e::X11 && config::video.capture != "kms") {
|
||||
BOOST_LOG(info) << "Avoiding KMS capture under X11 due to lack of atomic mode-setting"sv;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
BOOST_LOG(warning) << "Cursor capture may fail without atomic mode-setting support!"sv;
|
||||
}
|
||||
|
||||
plane_res.reset(drmModeGetPlaneResources(fd.el));
|
||||
@ -640,8 +653,7 @@ namespace platf {
|
||||
}
|
||||
|
||||
if (!fb->handles[0]) {
|
||||
BOOST_LOG(error)
|
||||
<< "Couldn't get handle for DRM Framebuffer ["sv << plane->fb_id << "]: Possibly not permitted: do [sudo setcap cap_sys_admin+p sunshine]"sv;
|
||||
BOOST_LOG(error) << "Couldn't get handle for DRM Framebuffer ["sv << plane->fb_id << "]: Probably not permitted"sv;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -909,12 +921,14 @@ namespace platf {
|
||||
|
||||
if (!prop_crtc_w || !prop_crtc_h || !prop_crtc_x || !prop_crtc_y) {
|
||||
BOOST_LOG(error) << "Cursor plane is missing required plane CRTC properties!"sv;
|
||||
BOOST_LOG(error) << "Atomic mode-setting must be enabled to capture the cursor!"sv;
|
||||
cursor_plane_id = -1;
|
||||
captured_cursor.visible = false;
|
||||
return;
|
||||
}
|
||||
if (!prop_src_x || !prop_src_y || !prop_src_w || !prop_src_h) {
|
||||
BOOST_LOG(error) << "Cursor plane is missing required plane SRC properties!"sv;
|
||||
BOOST_LOG(error) << "Atomic mode-setting must be enabled to capture the cursor!"sv;
|
||||
cursor_plane_id = -1;
|
||||
captured_cursor.visible = false;
|
||||
return;
|
||||
@ -1072,8 +1086,7 @@ namespace platf {
|
||||
}
|
||||
|
||||
if (!fb->handles[0]) {
|
||||
BOOST_LOG(error)
|
||||
<< "Couldn't get handle for DRM Framebuffer ["sv << plane->fb_id << "]: Possibly not permitted: do [sudo setcap cap_sys_admin+p sunshine]"sv;
|
||||
BOOST_LOG(error) << "Couldn't get handle for DRM Framebuffer ["sv << plane->fb_id << "]: Probably not permitted"sv;
|
||||
return capture_e::error;
|
||||
}
|
||||
|
||||
@ -1647,8 +1660,9 @@ namespace platf {
|
||||
}
|
||||
|
||||
if (!fb->handles[0]) {
|
||||
BOOST_LOG(error)
|
||||
<< "Couldn't get handle for DRM Framebuffer ["sv << plane->fb_id << "]: Possibly not permitted: do [sudo setcap cap_sys_admin+p sunshine]"sv;
|
||||
BOOST_LOG(error) << "Couldn't get handle for DRM Framebuffer ["sv << plane->fb_id << "]: Probably not permitted"sv;
|
||||
BOOST_LOG((window_system != window_system_e::X11 || config::video.capture == "kms") ? fatal : error)
|
||||
<< "You must run [sudo setcap cap_sys_admin+p $(readlink -f sunshine)] for KMS display capture to work!"sv;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user