summaryrefslogtreecommitdiff
path: root/src/render/Renderer.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2026-04-04 23:20:44 +0100
committerVaxry <43317083+vaxerski@users.noreply.github.com>2026-04-04 19:00:34 -0400
commit3a7bd8fea2ca9711da5523dc185c05ea30ec0f35 (patch)
tree0d8a0a87dcf65aa916f9c88d68eebff056057169 /src/render/Renderer.cpp
parent1c2bd2c818ba7d3cfc0a073f73f660d5ee23de1d (diff)
renderer: add a cm settings cache
Diffstat (limited to 'src/render/Renderer.cpp')
-rw-r--r--src/render/Renderer.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 9d9a4ddb..d3237970 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -1612,6 +1612,7 @@ void IHyprRenderer::renderSessionLockMissing(PHLMONITOR pMonitor) {
bool IHyprRenderer::beginRender(PHLMONITOR pMonitor, CRegion& damage, eRenderMode mode, SP<IHLBuffer> buffer, SP<IFramebuffer> fb, bool simple) {
m_renderPass.clear();
+ clearCMSettingsCache();
m_renderMode = mode;
m_renderData.pMonitor = pMonitor;
@@ -1765,8 +1766,22 @@ static bool isHDR2SDR(const NColorManagement::SImageDescription& imageDescriptio
targetImageDescription.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22);
}
+void IHyprRenderer::clearCMSettingsCache() {
+ m_cmSettingsCache.clear();
+}
+
SCMSettings IHyprRenderer::getCMSettings(const NColorManagement::PImageDescription imageDescription, const NColorManagement::PImageDescription targetImageDescription,
SP<CWLSurfaceResource> surface, bool modifySDR, float sdrMinLuminance, int sdrMaxLuminance) {
+ const auto srcId = imageDescription->id();
+ const auto dstId = targetImageDescription->id();
+ void* sPtr = m_renderData.surface.get();
+
+ for (auto const& entry : m_cmSettingsCache) {
+ if (entry.srcDescId == srcId && entry.dstDescId == dstId && entry.surfacePtr == sPtr && entry.modifySDR == modifySDR && entry.sdrMinLuminance == sdrMinLuminance &&
+ entry.sdrMaxLuminance == sdrMaxLuminance)
+ return entry.settings;
+ }
+
const auto sdrEOTF = NTransferFunction::fromConfig();
NColorManagement::eTransferFunction srcTF;
@@ -1799,7 +1814,7 @@ SCMSettings IHyprRenderer::getCMSettings(const NColorManagement::PImageDescripti
((m_renderData.pMonitor->m_sdrSaturation > 0 && m_renderData.pMonitor->m_sdrSaturation != 1.0f) ||
(m_renderData.pMonitor->m_sdrBrightness > 0 && m_renderData.pMonitor->m_sdrBrightness != 1.0f));
- return {
+ auto result = SCMSettings{
.sourceTF = srcTF,
.targetTF = targetImageDescription->value().transferFunction,
.srcTFRange = {.min = imageDescription->value().getTFMinLuminance(needsSDRmod ? sdrMinLuminance : -1),
@@ -1818,6 +1833,10 @@ SCMSettings IHyprRenderer::getCMSettings(const NColorManagement::PImageDescripti
.sdrSaturation = needsSDRmod && m_renderData.pMonitor->m_sdrSaturation > 0 ? m_renderData.pMonitor->m_sdrSaturation : 1.0f,
.sdrBrightnessMultiplier = needsSDRmod && m_renderData.pMonitor->m_sdrBrightness > 0 ? m_renderData.pMonitor->m_sdrBrightness : 1.0f,
};
+
+ m_cmSettingsCache.push_back({srcId, dstId, sPtr, modifySDR, sdrMinLuminance, sdrMaxLuminance, result});
+
+ return result;
}
void IHyprRenderer::renderMirrored() {