mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 05:09:49 +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!");
|
||||
}
|
||||
|
||||
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!");
|
||||
}
|
||||
bool isHeadlessOnly = true;
|
||||
wlr_multi_for_each_backend(
|
||||
m_sWLRBackend,
|
||||
[](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) {
|
||||
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 {
|
||||
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};
|
||||
std::transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
if (DRMV) {
|
||||
std::string name = std::string{DRMV->name, DRMV->name_len};
|
||||
std::transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
|
||||
if (name.contains("nvidia"))
|
||||
m_bNvidia = true;
|
||||
if (name.contains("nvidia"))
|
||||
m_bNvidia = true;
|
||||
|
||||
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});
|
||||
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});
|
||||
} else {
|
||||
Debug::log(LOG, "No primary DRM driver information found");
|
||||
}
|
||||
|
||||
drmFreeVersion(DRMV);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue