@@ -1441,6 +1441,8 @@ void CHyprOpenGLImpl::renderTextureWithDamage(SP<CTexture> tex, const CBox& box,
1441
1441
scissor (nullptr );
1442
1442
}
1443
1443
1444
+ static std::map<std::pair<uint32_t , uint32_t >, std::array<GLfloat, 9 >> primariesConversionCache;
1445
+
1444
1446
void CHyprOpenGLImpl::passCMUniforms (const CShader& shader, const NColorManagement::SImageDescription& imageDescription,
1445
1447
const NColorManagement::SImageDescription& targetImageDescription, bool modifySDR) {
1446
1448
glUniform1i (shader.sourceTF , imageDescription.transferFunction );
@@ -1470,14 +1472,19 @@ void CHyprOpenGLImpl::passCMUniforms(const CShader& shader, const NColorManageme
1470
1472
glUniform1f (shader.sdrBrightness ,
1471
1473
modifySDR && m_RenderData.pMonitor ->sdrBrightness > 0 && targetImageDescription.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ ?
1472
1474
m_RenderData.pMonitor ->sdrBrightness :
1475
+
1473
1476
1 .0f );
1474
- const auto mat = imageDescription.getPrimaries ().convertMatrix (targetImageDescription.getPrimaries ()).mat ();
1475
- const GLfloat glConvertMatrix[9 ] = {
1476
- mat[0 ][0 ], mat[1 ][0 ], mat[2 ][0 ], //
1477
- mat[0 ][1 ], mat[1 ][1 ], mat[2 ][1 ], //
1478
- mat[0 ][2 ], mat[1 ][2 ], mat[2 ][2 ], //
1479
- };
1480
- glUniformMatrix3fv (shader.convertMatrix , 1 , false , glConvertMatrix);
1477
+ const auto cacheKey = std::make_pair (imageDescription.getId (), targetImageDescription.getId ());
1478
+ if (!primariesConversionCache.contains (cacheKey)) {
1479
+ const auto mat = imageDescription.getPrimaries ().convertMatrix (targetImageDescription.getPrimaries ()).mat ();
1480
+ const std::array<GLfloat, 9 > glConvertMatrix = {
1481
+ mat[0 ][0 ], mat[1 ][0 ], mat[2 ][0 ], //
1482
+ mat[0 ][1 ], mat[1 ][1 ], mat[2 ][1 ], //
1483
+ mat[0 ][2 ], mat[1 ][2 ], mat[2 ][2 ], //
1484
+ };
1485
+ primariesConversionCache.insert (std::make_pair (cacheKey, glConvertMatrix));
1486
+ }
1487
+ glUniformMatrix3fv (shader.convertMatrix , 1 , false , &primariesConversionCache[cacheKey][0 ]);
1481
1488
}
1482
1489
1483
1490
void CHyprOpenGLImpl::passCMUniforms (const CShader& shader, const SImageDescription& imageDescription) {
0 commit comments