summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2022-10-27 13:26:47 +0100
committervaxerski <vaxry@vaxry.net>2022-10-27 13:26:47 +0100
commit7d6ccca69537b65ef4fe165fed92085ffe8cf990 (patch)
treeb756ef78b2b3f0d19c5ecc06ad931ecd6048ff6d /src
parent28c81fc71ec2593cdac6cbf945369b201c1e3e71 (diff)
add 10bit support to displays
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp3
-rw-r--r--src/config/ConfigManager.hpp1
-rw-r--r--src/helpers/Monitor.hpp1
-rw-r--r--src/includes.hpp2
-rw-r--r--src/render/Renderer.cpp28
5 files changed, 34 insertions, 1 deletions
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 <wlr/types/wlr_touch.h>
#include <wlr/types/wlr_switch.h>
+#include <drm_fourcc.h>
+
#ifndef NO_XWAYLAND
#include <wlr/xwayland.h>
#include <X11/Xproto.h>
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;