mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 20:25:58 +01:00
renderer: Allow headless mode in hyprland (#4794)
* allow headless * clang-format * fix redundant logic lol
This commit is contained in:
parent
6c24cee88f
commit
bc15a8f600
2 changed files with 30 additions and 13 deletions
|
@ -127,13 +127,26 @@ void CCompositor::initServer() {
|
||||||
throwError("wlr_backend_autocreate() failed!");
|
throwError("wlr_backend_autocreate() failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iDRMFD = wlr_backend_get_drm_fd(m_sWLRBackend);
|
bool isHeadlessOnly = true;
|
||||||
if (m_iDRMFD < 0) {
|
wlr_multi_for_each_backend(
|
||||||
Debug::log(CRIT, "Couldn't query the DRM FD!");
|
m_sWLRBackend,
|
||||||
throwError("wlr_backend_get_drm_fd() failed!");
|
[](wlr_backend* backend, void* isHeadlessOnly) {
|
||||||
}
|
if (!wlr_backend_is_headless(backend))
|
||||||
|
*(bool*)isHeadlessOnly = false;
|
||||||
|
},
|
||||||
|
&isHeadlessOnly);
|
||||||
|
|
||||||
m_sWLRRenderer = wlr_gles2_renderer_create_with_drm_fd(m_iDRMFD);
|
if (isHeadlessOnly) {
|
||||||
|
m_sWLRRenderer = wlr_renderer_autocreate(m_sWLRBackend);
|
||||||
|
} else {
|
||||||
|
m_iDRMFD = wlr_backend_get_drm_fd(m_sWLRBackend);
|
||||||
|
if (m_iDRMFD < 0) {
|
||||||
|
Debug::log(CRIT, "Couldn't query the DRM FD!");
|
||||||
|
throwError("wlr_backend_get_drm_fd() failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sWLRRenderer = wlr_gles2_renderer_create_with_drm_fd(m_iDRMFD);
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_sWLRRenderer) {
|
if (!m_sWLRRenderer) {
|
||||||
Debug::log(CRIT, "m_sWLRRenderer was NULL! This usually means wlroots could not find a GPU or enountered some issues.");
|
Debug::log(CRIT, "m_sWLRRenderer was NULL! This usually means wlroots could not find a GPU or enountered some issues.");
|
||||||
|
|
|
@ -31,16 +31,20 @@ CHyprRenderer::CHyprRenderer() {
|
||||||
} else {
|
} else {
|
||||||
Debug::log(LOG, "m_sWLRSession is null, omitting full DRM node checks");
|
Debug::log(LOG, "m_sWLRSession is null, omitting full DRM node checks");
|
||||||
|
|
||||||
const auto DRMV = drmGetVersion(g_pCompositor->m_iDRMFD);
|
const auto DRMV = drmGetVersion(g_pCompositor->m_iDRMFD);
|
||||||
|
|
||||||
std::string name = std::string{DRMV->name, DRMV->name_len};
|
if (DRMV) {
|
||||||
std::transform(name.begin(), name.end(), name.begin(), tolower);
|
std::string name = std::string{DRMV->name, DRMV->name_len};
|
||||||
|
std::transform(name.begin(), name.end(), name.begin(), tolower);
|
||||||
|
|
||||||
if (name.contains("nvidia"))
|
if (name.contains("nvidia"))
|
||||||
m_bNvidia = true;
|
m_bNvidia = true;
|
||||||
|
|
||||||
Debug::log(LOG, "Primary DRM driver information: {} v{}.{}.{} from {} description {}", name, DRMV->version_major, DRMV->version_minor, DRMV->version_patchlevel,
|
Debug::log(LOG, "Primary DRM driver information: {} v{}.{}.{} from {} description {}", name, DRMV->version_major, DRMV->version_minor, DRMV->version_patchlevel,
|
||||||
std::string{DRMV->date, DRMV->date_len}, std::string{DRMV->desc, DRMV->desc_len});
|
std::string{DRMV->date, DRMV->date_len}, std::string{DRMV->desc, DRMV->desc_len});
|
||||||
|
} else {
|
||||||
|
Debug::log(LOG, "No primary DRM driver information found");
|
||||||
|
}
|
||||||
|
|
||||||
drmFreeVersion(DRMV);
|
drmFreeVersion(DRMV);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue