From: Cheng-Shiun Tsai Date: Fri, 21 Feb 2020 14:12:22 +0000 (+0000) Subject: Use stack variable instead of global when computing matrix X-Git-Tag: dali_1.9.1~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=43e285669442b03970f68512ddc9d1019b86c946 Use stack variable instead of global when computing matrix This is to solve a synchronization problem with multiple DALi instances Change-Id: I146880175b6e6b5644b232c17a3a1fc51103fc53 --- 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() ); } }