Avoid broken fallback to cross-adapter NVENC encoding with KMS
This commit is contained in:
@@ -108,6 +108,7 @@ namespace platf {
|
|||||||
using obj_prop_t = util::safe_ptr<drmModeObjectProperties, drmModeFreeObjectProperties>;
|
using obj_prop_t = util::safe_ptr<drmModeObjectProperties, drmModeFreeObjectProperties>;
|
||||||
using prop_t = util::safe_ptr<drmModePropertyRes, drmModeFreeProperty>;
|
using prop_t = util::safe_ptr<drmModePropertyRes, drmModeFreeProperty>;
|
||||||
using prop_blob_t = util::safe_ptr<drmModePropertyBlobRes, drmModeFreePropertyBlob>;
|
using prop_blob_t = util::safe_ptr<drmModePropertyBlobRes, drmModeFreePropertyBlob>;
|
||||||
|
using version_t = util::safe_ptr<drmVersion, drmFreeVersion>;
|
||||||
|
|
||||||
using conn_type_count_t = std::map<std::uint32_t, std::uint32_t>;
|
using conn_type_count_t = std::map<std::uint32_t, std::uint32_t>;
|
||||||
|
|
||||||
@@ -364,6 +365,12 @@ namespace platf {
|
|||||||
return drmModeGetResources(fd.el);
|
return drmModeGetResources(fd.el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
is_nvidia() {
|
||||||
|
version_t ver { drmGetVersion(fd.el) };
|
||||||
|
return ver && ver->name && strncmp(ver->name, "nvidia-drm", 10) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
is_cursor(std::uint32_t plane_id) {
|
is_cursor(std::uint32_t plane_id) {
|
||||||
auto props = plane_props(plane_id);
|
auto props = plane_props(plane_id);
|
||||||
@@ -604,6 +611,12 @@ namespace platf {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip non-Nvidia cards if we're looking for CUDA devices
|
||||||
|
if (mem_type == mem_type_e::cuda && !card.is_nvidia()) {
|
||||||
|
BOOST_LOG(debug) << file << " is not a CUDA device"sv;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto end = std::end(card);
|
auto end = std::end(card);
|
||||||
for (auto plane = std::begin(card); plane != end; ++plane) {
|
for (auto plane = std::begin(card); plane != end; ++plane) {
|
||||||
// Skip unused planes
|
// Skip unused planes
|
||||||
@@ -1576,7 +1589,7 @@ namespace platf {
|
|||||||
|
|
||||||
// A list of names of displays accepted as display_name
|
// A list of names of displays accepted as display_name
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
kms_display_names() {
|
kms_display_names(mem_type_e hwdevice_type) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (!fs::exists("/dev/dri")) {
|
if (!fs::exists("/dev/dri")) {
|
||||||
@@ -1608,6 +1621,12 @@ namespace platf {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip non-Nvidia cards if we're looking for CUDA devices
|
||||||
|
if (hwdevice_type == mem_type_e::cuda && !card.is_nvidia()) {
|
||||||
|
BOOST_LOG(debug) << file << " is not a CUDA device"sv;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto crtc_to_monitor = kms::map_crtc_to_monitor(card.monitors(conn_type_count));
|
auto crtc_to_monitor = kms::map_crtc_to_monitor(card.monitors(conn_type_count));
|
||||||
|
|
||||||
auto end = std::end(card);
|
auto end = std::end(card);
|
||||||
|
|||||||
@@ -766,13 +766,13 @@ namespace platf {
|
|||||||
|
|
||||||
#ifdef SUNSHINE_BUILD_DRM
|
#ifdef SUNSHINE_BUILD_DRM
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
kms_display_names();
|
kms_display_names(mem_type_e hwdevice_type);
|
||||||
std::shared_ptr<display_t>
|
std::shared_ptr<display_t>
|
||||||
kms_display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config);
|
kms_display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
verify_kms() {
|
verify_kms() {
|
||||||
return !kms_display_names().empty();
|
return !kms_display_names(mem_type_e::unknown).empty();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -798,7 +798,7 @@ namespace platf {
|
|||||||
if (sources[source::WAYLAND]) return wl_display_names();
|
if (sources[source::WAYLAND]) return wl_display_names();
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_DRM
|
#ifdef SUNSHINE_BUILD_DRM
|
||||||
if (sources[source::KMS]) return kms_display_names();
|
if (sources[source::KMS]) return kms_display_names(hwdevice_type);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_X11
|
#ifdef SUNSHINE_BUILD_X11
|
||||||
if (sources[source::X11]) return x11_display_names();
|
if (sources[source::X11]) return x11_display_names();
|
||||||
|
|||||||
Reference in New Issue
Block a user