Make mat2 type uniform also use matrix stride 16/318716/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 22 Jan 2025 13:05:50 +0000 (22:05 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 22 Jan 2025 13:31:45 +0000 (22:31 +0900)
Dali use mat2 type as Vector4 property.
But if we just use Vector4 type as mat2 uniform,
matrix stride information not be applied.

To fix this issue, let we also check matrixStride value
of uniform reflection, and use it.

Change-Id: I310dd565f73d2af3a58e3a7c40e07db902eb6877
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/render/renderers/render-renderer.cpp

index a24911722f5220784872adfb69c704e14b951268..a69db41421ffb1116e5e17e62a53593e6bbe5b37 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -933,14 +933,16 @@ void Renderer::WriteDynUniform(
 
   const auto valueAddress = propertyValue->GetValueAddress(updateBufferIndex);
 
-  if(propertyValue->GetType() == Property::MATRIX3 &&
-     uniform.matrixStride > 0 &&
-     uniform.matrixStride != uint32_t(-1))
+  if((propertyValue->GetType() == Property::MATRIX3 || propertyValue->GetType() == Property::VECTOR4) &&
+     uniform.matrixStride != uint32_t(-1) &&
+     uniform.matrixStride > 0)
   {
-    for(int i = 0; i < 3; ++i)
+    // If the property is Vector4 type and matrixStride is valid integer, then we should treat it as mat2 type uniforms.
+    const uint32_t matrixRow = (propertyValue->GetType() == Property::MATRIX3) ? 3 : 2;
+    for(uint32_t i = 0; i < matrixRow; ++i)
     {
-      ubo->Write(reinterpret_cast<const float*>(valueAddress) + i * 3,
-                 sizeof(float) * 3,
+      ubo->Write(reinterpret_cast<const float*>(valueAddress) + i * matrixRow,
+                 sizeof(float) * matrixRow,
                  dest + (i * uniform.matrixStride));
     }
   }