From 4b592d0819e2f4563d59e6cbb2c3c236ec8f23af Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 30 Oct 2023 15:56:02 +0000 Subject: renderer: properly pass 10-bit formats to opengl --- src/helpers/MiscFunctions.cpp | 12 ++++++++++++ src/helpers/MiscFunctions.hpp | 1 + src/helpers/Monitor.hpp | 1 + 3 files changed, 14 insertions(+) (limited to 'src/helpers') diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 3cce73d2..acb9cf20 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -750,4 +750,16 @@ std::vector getBacktrace() { void throwError(const std::string& err) { Debug::log(CRIT, "Critical error thrown: {}", err); throw std::runtime_error(err); +} + +uint32_t drmFormatToGL(uint32_t drm) { + switch (drm) { + case DRM_FORMAT_XRGB8888: + case DRM_FORMAT_XBGR8888: return GL_RGBA; // doesn't matter, opengl is gucci in this case. + case DRM_FORMAT_XRGB2101010: + case DRM_FORMAT_XBGR2101010: return GL_RGB10_A2; + default: return GL_RGBA; + } + UNREACHABLE(); + return GL_RGBA; } \ No newline at end of file diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index d489a0cd..499aa90f 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -33,6 +33,7 @@ double normalizeAngleRad(double ang); std::string replaceInString(std::string subject, const std::string& search, const std::string& replace); std::vector getBacktrace(); void throwError(const std::string& err); +uint32_t drmFormatToGL(uint32_t drm); template [[deprecated("use std::format instead")]] std::string getFormat(std::format_string fmt, Args&&... args) { diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 71c84273..5e0df858 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -65,6 +65,7 @@ class CMonitor { 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. bool createdByUser = false; + uint32_t drmFormat = DRM_FORMAT_INVALID; bool pendingFrame = false; // if we schedule a frame during rendering, reschedule it after bool renderingActive = false; -- cgit v1.2.3