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