diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 664e07cd..bad134b1 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -532,6 +532,9 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string if (ARGS[argno] == "mirror") { newrule.mirrorOf = ARGS[argno + 1]; argno++; + } else if (ARGS[argno] == "bitdepth") { + newrule.enable10bit = ARGS[argno + 1] == "10"; + argno++; } else { Debug::log(ERR, "Config error: invalid monitor syntax"); parseError = "invalid syntax at \"" + ARGS[argno] + "\""; diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 036b9d62..549beab8 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -38,6 +38,7 @@ struct SMonitorRule { bool disabled = false; wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL; std::string mirrorOf = ""; + bool enable10bit = false; }; struct SMonitorAdditionalReservedArea { diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 7064ee28..476dd2ce 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -39,6 +39,7 @@ public: bool dpmsStatus = true; bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it. + bool enabled10bit = false; // as above, this can be TRUE even if 10 bit failed. // mirroring CMonitor* pMirrorOf = nullptr; diff --git a/src/includes.hpp b/src/includes.hpp index 607eb539..1ed27319 100644 --- a/src/includes.hpp +++ b/src/includes.hpp @@ -100,6 +100,8 @@ extern "C" { #include #include +#include + #ifndef NO_XWAYLAND #include #include diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index ed94552c..3247e499 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -950,7 +950,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale && ((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) || pMonitorRule->offset == Vector2D(-1, -1)) - && pMonitor->transform == pMonitorRule->transform) { + && pMonitor->transform == pMonitorRule->transform + && pMonitorRule->enable10bit == pMonitor->enabled10bit) { Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str()); return true; @@ -1160,6 +1161,31 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR pMonitor->vecPixelSize = pMonitor->vecSize; + if (pMonitorRule->enable10bit) { + // try 10b RGB + wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XRGB2101010); + pMonitor->enabled10bit = true; + + if (!wlr_output_test(pMonitor->output)) { + Debug::log(ERR, "Output %s -> 10 bit enabled, but failed format DRM_FORMAT_XRGB2101010. Trying BGR.", pMonitor->output->name); + + wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XBGR2101010); + + if (!wlr_output_test(pMonitor->output)) { + Debug::log(ERR, "Output %s -> 10 bit enabled, but failed format DRM_FORMAT_XBGR2101010. Falling back to 8 bit.", pMonitor->output->name); + + wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XRGB8888); + } else { + Debug::log(LOG, "10bit format DRM_FORMAT_XBGR2101010 succeeded for output %s", pMonitor->output->name); + } + } else { + Debug::log(LOG, "10bit format DRM_FORMAT_XRGB2101010 succeeded for output %s", pMonitor->output->name); + } + } else { + wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XRGB8888); + pMonitor->enabled10bit = false; + } + if (!wlr_output_commit(pMonitor->output)) { Debug::log(ERR, "Couldn't commit output named %s", pMonitor->output->name); return true;