diff options
| author | vaxerski <vaxry@vaxry.net> | 2025-03-18 11:30:01 +0000 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2025-03-18 11:30:08 +0000 |
| commit | cca0f48b74e87f86244f5773c42d9ade84683f3b (patch) | |
| tree | 675a7eb1a9c2964733546b2f68fb94a840de943f /src | |
| parent | 60edb376f29d89859072d90e9e4d8660a07caf88 (diff) | |
renderer: add an option to disable cm and auto-skip cm if not necessary
fixes #9641
adds render:cm_enabled default true
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/ConfigDescriptions.hpp | 6 | ||||
| -rw-r--r-- | src/config/ConfigManager.cpp | 1 | ||||
| -rw-r--r-- | src/managers/ProtocolManager.cpp | 10 | ||||
| -rw-r--r-- | src/render/OpenGL.cpp | 15 |
4 files changed, 24 insertions, 8 deletions
diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index cdb69446..1cfbf0e1 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -1378,6 +1378,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = { .type = CONFIG_OPTION_BOOL, .data = SConfigOptionDescription::SBoolData{true}, }, + SConfigOptionDescription{ + .value = "render:cm_enabled", + .description = "Enable Color Management pipelines (requires restart to fully take effect)", + .type = CONFIG_OPTION_BOOL, + .data = SConfigOptionDescription::SBoolData{true}, + }, /* * cursor: diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 1c36876d..82fe2d41 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -692,6 +692,7 @@ CConfigManager::CConfigManager() { registerConfigVar("render:xp_mode", Hyprlang::INT{0}); registerConfigVar("render:ctm_animation", Hyprlang::INT{2}); registerConfigVar("render:cm_fs_passthrough", Hyprlang::INT{1}); + registerConfigVar("render:cm_enabled", Hyprlang::INT{1}); registerConfigVar("ecosystem:no_update_news", Hyprlang::INT{0}); registerConfigVar("ecosystem:no_donation_nag", Hyprlang::INT{0}); diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp index 992ace20..06987dae 100644 --- a/src/managers/ProtocolManager.cpp +++ b/src/managers/ProtocolManager.cpp @@ -98,6 +98,7 @@ void CProtocolManager::onMonitorModeChange(PHLMONITOR pMonitor) { CProtocolManager::CProtocolManager() { static const auto PENABLEEXPLICIT = CConfigValue<Hyprlang::INT>("render:explicit_sync"); + static const auto PENABLECM = CConfigValue<Hyprlang::INT>("render:cm_enabled"); static const auto PENABLEXXCM = CConfigValue<Hyprlang::INT>("experimental:xx_color_management_v4"); static const auto PDEBUGCM = CConfigValue<Hyprlang::INT>("debug:full_cm_proto"); @@ -181,14 +182,17 @@ CProtocolManager::CProtocolManager() { PROTO::ctm = makeUnique<CHyprlandCTMControlProtocol>(&hyprland_ctm_control_manager_v1_interface, 2, "CTMControl"); PROTO::hyprlandSurface = makeUnique<CHyprlandSurfaceProtocol>(&hyprland_surface_manager_v1_interface, 2, "HyprlandSurface"); PROTO::contentType = makeUnique<CContentTypeProtocol>(&wp_content_type_manager_v1_interface, 1, "ContentType"); - PROTO::colorManagement = makeUnique<CColorManagementProtocol>(&wp_color_manager_v1_interface, 1, "ColorManagement", *PDEBUGCM); - // please read the top of this file before adding another protocol - if (*PENABLEXXCM) { + if (*PENABLECM) + PROTO::colorManagement = makeUnique<CColorManagementProtocol>(&wp_color_manager_v1_interface, 1, "ColorManagement", *PDEBUGCM); + + if (*PENABLEXXCM && *PENABLECM) { PROTO::xxColorManagement = makeUnique<CXXColorManagementProtocol>(&xx_color_manager_v4_interface, 1, "XXColorManagement"); PROTO::frogColorManagement = makeUnique<CFrogColorManagementProtocol>(&frog_color_management_factory_v1_interface, 1, "FrogColorManagement"); } + // ! please read the top of this file before adding another protocol + for (auto const& b : g_pCompositor->m_pAqBackend->getImplementations()) { if (b->type() != Aquamarine::AQ_BACKEND_DRM) continue; diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 137e4a8f..e2f72fff 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -1320,8 +1320,9 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, const CB CBox newBox = box; m_RenderData.renderModif.applyToBox(newBox); - static auto PDT = CConfigValue<Hyprlang::INT>("debug:damage_tracking"); - static auto PPASS = CConfigValue<Hyprlang::INT>("render:cm_fs_passthrough"); + static const auto PDT = CConfigValue<Hyprlang::INT>("debug:damage_tracking"); + static const auto PPASS = CConfigValue<Hyprlang::INT>("render:cm_fs_passthrough"); + static const auto PENABLECM = CConfigValue<Hyprlang::INT>("render:cm_enabled"); // get the needed transform for this texture const bool TRANSFORMS_MATCH = wlTransformToHyprutils(m_RenderData.pMonitor->transform) == tex->m_eTransform; // FIXME: combine them properly!!! @@ -1378,8 +1379,12 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, const CB glTexParameteri(tex->m_iTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } - const bool skipCM = !m_RenderData.surface /* No surface - no point in CM */ - || !m_bCMSupported /* CM unsupported - hw failed to compile the shader probably */ + const bool SURFACE_HAS_CM = m_RenderData.surface && m_RenderData.surface->colorManagement && m_RenderData.surface->colorManagement->hasImageDescription(); + + const bool skipCM = !*PENABLECM /* CM disabled by the user */ + || !m_RenderData.surface /* No surface - no point in CM */ + || !m_bCMSupported /* CM unsupported - hw failed to compile the shader probably */ + || (!SURFACE_HAS_CM && m_RenderData.pMonitor->imageDescription == SImageDescription{}) /* Surface doesn't have CM and monitor isn't CM'd */ || (*PPASS && m_RenderData.pMonitor->activeWorkspace && m_RenderData.pMonitor->activeWorkspace->m_bHasFullscreenWindow && m_RenderData.pMonitor->activeWorkspace->m_efFullscreenMode == FSMODE_FULLSCREEN) /* Fullscreen window with pass cm enabled */; @@ -1391,7 +1396,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, const CB glUseProgram(shader->program); glUniform1i(shader->texType, texType); const auto imageDescription = - m_RenderData.surface.valid() && m_RenderData.surface->colorManagement.valid() ? m_RenderData.surface->colorManagement->imageDescription() : SImageDescription{}; + m_RenderData.surface && m_RenderData.surface->colorManagement ? m_RenderData.surface->colorManagement->imageDescription() : SImageDescription{}; glUniform1i(shader->sourceTF, imageDescription.transferFunction); glUniform1i(shader->targetTF, m_RenderData.pMonitor->imageDescription.transferFunction); const auto sourcePrimaries = |
