From 43e285669442b03970f68512ddc9d1019b86c946 Mon Sep 17 00:00:00 2001 From: Cheng-Shiun Tsai Date: Fri, 21 Feb 2020 14:12:22 +0000 Subject: [PATCH] Use stack variable instead of global when computing matrix This is to solve a synchronization problem with multiple DALi instances Change-Id: I146880175b6e6b5644b232c17a3a1fc51103fc53 --- dali/internal/render/renderers/render-renderer.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp index 9324d86..e3f1684 100644 --- a/dali/internal/render/renderers/render-renderer.cpp +++ b/dali/internal/render/renderers/render-renderer.cpp @@ -35,8 +35,6 @@ namespace Internal namespace { -static Matrix gModelViewProjectionMatrix( false ); ///< a shared matrix to calculate the MVP matrix, dont want to store it in object to reduce storage overhead -static Matrix3 gNormalMatrix; ///< a shared matrix to calculate normal matrix, dont want to store it in object to reduce storage overhead /** * Helper to set view and projection matrices once per program @@ -86,17 +84,19 @@ inline void SetMatrices( Program& program, loc = program.GetUniformLocation( Program::UNIFORM_MVP_MATRIX ); if( Program::UNIFORM_UNKNOWN != loc ) { - Matrix::Multiply( gModelViewProjectionMatrix, modelViewMatrix, projectionMatrix ); - program.SetUniformMatrix4fv( loc, 1, gModelViewProjectionMatrix.AsFloat() ); + Matrix modelViewProjectionMatrix(false); + Matrix::Multiply( modelViewProjectionMatrix, modelViewMatrix, projectionMatrix ); + program.SetUniformMatrix4fv( loc, 1, modelViewProjectionMatrix.AsFloat() ); } loc = program.GetUniformLocation( Program::UNIFORM_NORMAL_MATRIX ); if( Program::UNIFORM_UNKNOWN != loc ) { - gNormalMatrix = modelViewMatrix; - gNormalMatrix.Invert(); - gNormalMatrix.Transpose(); - program.SetUniformMatrix3fv( loc, 1, gNormalMatrix.AsFloat() ); + Matrix3 normalMatrix; + normalMatrix = modelViewMatrix; + normalMatrix.Invert(); + normalMatrix.Transpose(); + program.SetUniformMatrix3fv( loc, 1, normalMatrix.AsFloat() ); } } -- 2.7.4