Use stack variable instead of global when computing matrix 28/226228/1
authorCheng-Shiun Tsai <cheng.tsai@samsung.com>
Fri, 21 Feb 2020 14:12:22 +0000 (14:12 +0000)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 28 Feb 2020 05:39:48 +0000 (14:39 +0900)
This is to solve a synchronization problem with multiple DALi instances

Change-Id: I146880175b6e6b5644b232c17a3a1fc51103fc53

dali/internal/render/renderers/render-renderer.cpp

index 9324d86..e3f1684 100644 (file)
@@ -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() );
   }
 }