Test harness sync 30/291030/7
authorDavid Steele <david.steele@samsung.com>
Thu, 6 Apr 2023 11:19:54 +0000 (12:19 +0100)
committerDavid Steele <david.steele@samsung.com>
Fri, 23 Jun 2023 12:08:32 +0000 (13:08 +0100)
Change-Id: Ib91bad483649170eedb76ac6a4e1755517d29b1a

12 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-program.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-program.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp

index 1d20a6a..38169a2 100644 (file)
 #include "test-gl-abstraction.h"
 #include "test-trace-call-stack.h"
 
-static const bool TRACE{
-  false};
+static const bool TRACE{false};
+
+uint32_t GetGLDataTypeSize(GLenum type)
+{
+  // There are many more types than what are covered here, but
+  // they are not supported in dali.
+  switch(type)
+  {
+    case GL_FLOAT: // "float", 1 float, 4 bytes
+      return 4;
+    case GL_FLOAT_VEC2: // "vec2", 2 floats, 8 bytes
+      return 8;
+    case GL_FLOAT_VEC3: // "vec3", 3 floats, 12 bytes
+      return 12;
+    case GL_FLOAT_VEC4: // "vec4", 4 floats, 16 bytes
+      return 16;
+    case GL_INT: // "int", 1 integer, 4 bytes
+      return 4;
+    case GL_FLOAT_MAT2: // "mat2", 4 floats, 16 bytes
+      return 16;
+    case GL_FLOAT_MAT3: // "mat3", 3 vec3, 36 bytes
+      return 36;
+    case GL_FLOAT_MAT4: // "mat4", 4 vec4, 64 bytes
+      return 64;
+    default:
+      return 0;
+  }
+}
 
 namespace Dali
 {
@@ -145,6 +171,12 @@ void TestGlAbstraction::Initialize()
     {"uLightCameraProjectionMatrix", GL_FLOAT_MAT4, 1},
     {"uLightCameraViewMatrix", GL_FLOAT_MAT4, 1}};
 
+  int offset = 0;
+  for(uint32_t i = 0; i < mActiveUniforms.size(); ++i)
+  {
+    mActiveUniforms[i].offset = offset;
+    offset += mActiveUniforms[i].size * GetGLDataTypeSize(mActiveUniforms[i].type);
+  }
   // WARNING: IF YOU CHANGE THIS LIST, ALSO CHANGE UNIFORMS IN test-graphics-reflection.cpp
 }
 
@@ -196,6 +228,17 @@ bool TestGlAbstraction::TextureRequiresConverting(const GLenum imageGlFormat, co
   return ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
 }
 
+void TestGlAbstraction::SetActiveUniforms(const std::vector<ActiveUniform>& uniforms)
+{
+  mActiveUniforms = uniforms;
+  int offset      = 0;
+  for(uint32_t i = 0; i < uniforms.size(); ++i)
+  {
+    mActiveUniforms[i].offset = offset;
+    offset += mActiveUniforms[i].size * GetGLDataTypeSize(mActiveUniforms[i].type);
+  }
+}
+
 } // namespace Dali
 
 bool BlendEnabled(const Dali::TraceCallStack& callStack)
index cc27d9e..2ca98dc 100644 (file)
@@ -51,9 +51,10 @@ struct UniformData
 
 struct ActiveUniform
 {
-  std::string name;
-  GLenum      type;
-  GLint       size;
+  std::string name{};
+  GLenum      type{GL_FLOAT};
+  GLint       size{0};
+  GLint       offset{0};
 };
 
 class DALI_CORE_API TestGlAbstraction : public Dali::Integration::GlAbstraction
@@ -457,6 +458,10 @@ public:
 
   inline void DeleteBuffers(GLsizei n, const GLuint* buffers) override
   {
+    TraceCallStack::NamedParams namedParams;
+    namedParams["n"] << n;
+    namedParams["id"] << buffers[0];
+    mBufferTrace.PushCall("DeleteBuffers", namedParams.str(), namedParams);
   }
 
   inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) override
@@ -697,13 +702,21 @@ public:
   inline void GenBuffers(GLsizei n, GLuint* buffers) override
   {
     // avoids an assert in GpuBuffers
-    *buffers = 1u;
+    static GLuint id = 1;
 
-    std::ostringstream o;
-    o << n;
     TraceCallStack::NamedParams namedParams;
-    namedParams["n"] << o.str();
-    mBufferTrace.PushCall("GenBuffers", o.str(), namedParams);
+    namedParams["n"] << n;
+
+    // Allocate some buffer names
+    bool first = true;
+    while(n)
+    {
+      namedParams["buffers"] << (first ? "" : ", ") << id;
+      first      = false;
+      *buffers++ = id++;
+      --n;
+    }
+    mBufferTrace.PushCall("GenBuffers", namedParams.str(), namedParams);
   }
 
   inline void GenerateMipmap(GLenum target) override
@@ -800,10 +813,7 @@ public:
     *type = mAttribTypes[index];
   }
 
-  inline void SetActiveUniforms(const std::vector<ActiveUniform>& uniforms)
-  {
-    mActiveUniforms = uniforms;
-  }
+  void SetActiveUniforms(const std::vector<ActiveUniform>& uniforms);
 
   inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
   {
@@ -865,6 +875,9 @@ public:
       case GL_PROGRAM_BINARY_FORMATS_OES:
         *params = mBinaryFormats;
         break;
+      case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
+        *params = mUniformBufferOffsetAlignment;
+        break;
     }
   }
 
@@ -1882,6 +1895,44 @@ public:
 
   inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override
   {
+    for(int i = 0; i < uniformCount; ++i)
+    {
+      if(i < int(mActiveUniforms.size()))
+      {
+        switch(pname)
+        {
+          case GL_UNIFORM_TYPE:
+          {
+            params[i] = mActiveUniforms[i].type;
+            break;
+          }
+          case GL_UNIFORM_SIZE:
+          {
+            params[i] = mActiveUniforms[i].size;
+            break;
+          }
+          case GL_UNIFORM_NAME_LENGTH:
+          {
+            params[i] = mActiveUniforms[i].name.length();
+            break;
+          }
+          case GL_UNIFORM_BLOCK_INDEX:
+          {
+            params[i] = -1;
+            break;
+          }
+          case GL_UNIFORM_OFFSET:
+          {
+            params[i] = mActiveUniforms[i].offset;
+            break;
+          }
+          case GL_UNIFORM_MATRIX_STRIDE:
+          {
+            break;
+          }
+        }
+      }
+    }
   }
 
   inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override
@@ -2169,7 +2220,10 @@ public: // TEST FUNCTIONS
   {
     mProgramBinaryLength = length;
   }
-
+  inline void SetUniformBufferOffsetAlignment(GLint align)
+  {
+    mUniformBufferOffsetAlignment = align;
+  }
   inline bool GetVertexAttribArrayState(GLuint index)
   {
     if(index >= MAX_ATTRIBUTE_CACHE_SIZE)
@@ -2582,6 +2636,7 @@ public:
   GLint                                 mNumBinaryFormats;
   GLint                                 mBinaryFormats;
   GLint                                 mProgramBinaryLength;
+  GLint                                 mUniformBufferOffsetAlignment{1};
   bool                                  mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
   bool                                  mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
   bool                                  mGetProgramBinaryCalled;
index 42b53b1..456d978 100644 (file)
 
 namespace Dali
 {
-TestGraphicsBuffer::TestGraphicsBuffer(TraceCallStack& callStack, TestGlAbstraction& glAbstraction, uint32_t size, Graphics::BufferUsageFlags usage)
+TestGraphicsBuffer::TestGraphicsBuffer(const Graphics::BufferCreateInfo& createInfo, TestGraphicsController& controller, TestGlAbstraction& glAbstraction, TraceCallStack& callStack)
 : mCallStack(callStack),
+  mController(controller),
   mGl(glAbstraction),
-  mUsage(usage)
+  mCreateInfo(createInfo),
+  mUsage(createInfo.usage)
 {
-  memory.resize(size);
-  mGl.GetBufferTrace().EnableLogging(false);
+  if(createInfo.propertiesFlags & int(Graphics::BufferPropertiesFlagBit::CPU_ALLOCATED))
+  {
+    mCpuOnly = true;
+  }
+  else
+  {
+    mGl.GenBuffers(1, &mId);
+  }
+  memory.resize(createInfo.size);
+}
+
+TestGraphicsBuffer::~TestGraphicsBuffer()
+{
+  // Not strictly parameters, but useful for testing
+  TraceCallStack::NamedParams namedParams;
+  namedParams["usage"] << "0x" << std::hex << mCreateInfo.usage;
+  namedParams["propertiesFlags"] << mCreateInfo.propertiesFlags;
+
+  mCallStack.PushCall("Buffer::~Buffer", namedParams.str(), namedParams);
+  if(!mCpuOnly && mId)
+  {
+    mGl.DeleteBuffers(1, &mId);
+  }
+}
+
+void TestGraphicsBuffer::DiscardResource()
+{
+  mController.DiscardBuffer(this);
 }
 
 void TestGraphicsBuffer::Bind()
 {
   mCallStack.PushCall("Buffer::Bind", "");
-  if(!mId)
+  if(!mCpuOnly && mId > 0)
   {
-    mGl.GenBuffers(1, &mId);
+    mGl.BindBuffer(GetTarget(), mId);
   }
-  mGl.BindBuffer(GetTarget(), mId);
 }
 
 void TestGraphicsBuffer::Unbind()
 {
   mCallStack.PushCall("Buffer::Unbind", "");
-  if(mId)
+  if(!mCpuOnly)
   {
-    mGl.BindBuffer(GetTarget(), 0);
+    if(mId)
+    {
+      mGl.BindBuffer(GetTarget(), 0);
+    }
   }
 }
 
@@ -58,15 +88,19 @@ void TestGraphicsBuffer::Upload(uint32_t offset, uint32_t size)
   namedParams["offset"] << offset;
   namedParams["size"] << size;
   mCallStack.PushCall("Buffer::Upload", o.str(), namedParams);
-  if(size <= memory.size() && mCreated)
-  {
-    // Use subData to avoid re-allocation
-    mGl.BufferSubData(GetTarget(), static_cast<GLintptr>(static_cast<unsigned long>(offset)), static_cast<GLsizeiptr>(static_cast<unsigned long>(size)), &memory[offset]);
-  }
-  else
+
+  if(!mCpuOnly)
   {
-    mGl.BufferData(GetTarget(), static_cast<GLsizeiptr>(static_cast<unsigned long>(size)), &memory[0], GL_STATIC_DRAW); //@todo Query - do we need other usages?
-    mCreated = true;
+    if(size <= memory.size() && mCreated)
+    {
+      // Use subData to avoid re-allocation
+      mGl.BufferSubData(GetTarget(), static_cast<GLintptr>(static_cast<unsigned long>(offset)), static_cast<GLsizeiptr>(static_cast<unsigned long>(size)), &memory[offset]);
+    }
+    else
+    {
+      mGl.BufferData(GetTarget(), static_cast<GLsizeiptr>(static_cast<unsigned long>(size)), &memory[0], GL_STATIC_DRAW); //@todo Query - do we need other usages?
+      mCreated = true;
+    }
   }
 }
 
index 1dc2715..220ae06 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_GRAPHICS_BUFFER_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -17,6 +17,7 @@
  * limitations under the License.
  */
 
+#include <dali/graphics-api/graphics-buffer-create-info.h>
 #include <dali/graphics-api/graphics-buffer.h>
 #include <dali/graphics-api/graphics-types.h>
 
 namespace Dali
 {
 class TestGraphicsProgram;
+class TestGraphicsController;
 class UniformBufferBindingDescriptor;
+
 class TestGraphicsBuffer : public Graphics::Buffer
 {
 public:
-  TestGraphicsBuffer(TraceCallStack& callStack, TestGlAbstraction& glAbstraction, uint32_t size, Graphics::BufferUsageFlags usage);
+  TestGraphicsBuffer(const Graphics::BufferCreateInfo& createInfo, TestGraphicsController& controller, TestGlAbstraction& glAbstraction, TraceCallStack& callStack);
+  ~TestGraphicsBuffer();
+  void DiscardResource();
+
   void   Bind();
   void   Unbind();
   void   Upload(uint32_t offset, uint32_t size);
@@ -38,17 +44,21 @@ public:
 
   bool IsCPUAllocated() const
   {
-    return true;
+    return mCpuOnly;
   }
 
   void BindAsUniformBuffer(const TestGraphicsProgram* program, const Dali::UniformBufferBindingDescriptor& uboBinding) const;
 
-  TraceCallStack&            mCallStack;
-  TestGlAbstraction&         mGl;
-  std::vector<uint8_t>       memory;
+  TraceCallStack&         mCallStack;
+  TestGraphicsController& mController;
+  TestGlAbstraction&      mGl;
+  std::vector<uint8_t>    memory;
+
+  Graphics::BufferCreateInfo mCreateInfo;
   Graphics::BufferUsageFlags mUsage;
   GLuint                     mId{0};
   bool                       mCreated{false};
+  bool                       mCpuOnly{false};
 };
 
 } // namespace Dali
index 14c6d50..4bac7a6 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "test-graphics-controller.h"
 
+#include <dali/graphics-api/graphics-types.h>
 #include "test-graphics-buffer.h"
 #include "test-graphics-command-buffer.h"
 #include "test-graphics-framebuffer.h"
 #include "test-graphics-texture.h"
 
 #include <dali/integration-api/gl-defines.h>
+#include <any>
 #include <cstdio>
 #include <iostream>
+#include <memory>
 #include <sstream>
 
-#include <any>
-
 namespace Dali
 {
+namespace
+{
+template<class T>
+struct TestGraphicsDeleter
+{
+  TestGraphicsDeleter() = default;
+  void operator()(T* object)
+  {
+    // Discard resource
+    object->DiscardResource();
+  }
+};
+
+} //namespace
+
 std::ostream& operator<<(std::ostream& o, const Graphics::BufferCreateInfo& bufferCreateInfo)
 {
   return o << "usage:" << std::hex << bufferCreateInfo.usage << ", size:" << std::dec << bufferCreateInfo.size;
@@ -1185,10 +1201,25 @@ bool TestGraphicsController::IsDrawOnResumeRequired()
 
 Graphics::UniquePtr<Graphics::Buffer> TestGraphicsController::CreateBuffer(const Graphics::BufferCreateInfo& createInfo, Graphics::UniquePtr<Graphics::Buffer>&& oldBuffer)
 {
-  std::ostringstream oss;
-  oss << "bufferCreateInfo:" << createInfo;
-  mCallStack.PushCall("CreateBuffer", oss.str());
-  return Graphics::MakeUnique<TestGraphicsBuffer>(mCallStack, mGl, createInfo.size, createInfo.usage);
+  TraceCallStack::NamedParams namedParams;
+  namedParams["usage"] << "0x" << std::hex << createInfo.usage;
+  namedParams["propertiesFlags"] << createInfo.propertiesFlags;
+  namedParams["size"] << createInfo.size;
+  mCallStack.PushCall("CreateBuffer", namedParams.str(), namedParams);
+
+  auto ptr = Graphics::MakeUnique<TestGraphicsBuffer, TestGraphicsDeleter<TestGraphicsBuffer>>(createInfo, *this, mGl, mCallStack);
+  mAllocatedBuffers.push_back(ptr.get());
+  return ptr;
+}
+
+void TestGraphicsController::DiscardBuffer(TestGraphicsBuffer* buffer)
+{
+  auto iter = std::find(mAllocatedBuffers.begin(), mAllocatedBuffers.end(), buffer);
+  if(iter != mAllocatedBuffers.end())
+  {
+    mAllocatedBuffers.erase(iter);
+  }
+  delete buffer;
 }
 
 Graphics::UniquePtr<Graphics::CommandBuffer> TestGraphicsController::CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, Graphics::UniquePtr<Graphics::CommandBuffer>&& oldCommandBuffer)
@@ -1258,7 +1289,8 @@ Graphics::UniquePtr<Graphics::Program> TestGraphicsController::CreateProgram(con
   }
 
   mProgramCache.emplace_back();
-  mProgramCache.back().programImpl = new TestGraphicsProgramImpl(mGl, programCreateInfo, mVertexFormats, mCustomUniforms);
+  mProgramCache.back().programImpl = new TestGraphicsProgramImpl(mGl, programCreateInfo, mVertexFormats, mCustomUniforms, mCustomUniformBlocks);
+
   for(auto& shader : *(programCreateInfo.shaderState))
   {
     auto graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
@@ -1329,8 +1361,24 @@ Graphics::MemoryRequirements TestGraphicsController::GetTextureMemoryRequirement
 
 Graphics::MemoryRequirements TestGraphicsController::GetBufferMemoryRequirements(Graphics::Buffer& buffer) const
 {
+  static GLint uniformAlign{0};
+
+  Graphics::MemoryRequirements reqs{};
   mCallStack.PushCall("GetBufferMemoryRequirements", "");
-  return Graphics::MemoryRequirements{};
+
+  auto gfxBuffer = Uncast<TestGraphicsBuffer>(&buffer);
+  if(gfxBuffer->mCreateInfo.usage & (0 | Graphics::BufferUsage::UNIFORM_BUFFER))
+  {
+    if(!uniformAlign)
+    {
+      // Throw off the shackles of constness
+      auto& gl = *const_cast<TestGlAbstraction*>(&mGl);
+      gl.GetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uniformAlign);
+    }
+    reqs.size      = gfxBuffer->mCreateInfo.size;
+    reqs.alignment = uint32_t(uniformAlign);
+  }
+  return reqs;
 }
 
 Graphics::TextureProperties TestGraphicsController::GetTextureProperties(const Graphics::Texture& texture)
index 81b93d2..ade48d7 100644 (file)
@@ -2,7 +2,7 @@
 #define TEST_GRAPHICS_CONTROLLER_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -207,6 +207,8 @@ public:
    */
   Graphics::UniquePtr<Graphics::Buffer> CreateBuffer(const Graphics::BufferCreateInfo& bufferCreateInfo, Graphics::UniquePtr<Graphics::Buffer>&& oldBuffer) override;
 
+  void DiscardBuffer(TestGraphicsBuffer* buffer);
+
   /**
    * @brief Creates new CommandBuffer object
    *
@@ -384,6 +386,11 @@ public: // Test Functions
     mCustomUniforms = customUniforms;
   }
 
+  void AddCustomUniformBlock(const TestGraphicsReflection::TestUniformBlockInfo& blockInfo)
+  {
+    mCustomUniformBlocks.push_back(blockInfo);
+  }
+
   void ClearSubmitStack()
   {
     mSubmitStack.clear();
@@ -427,11 +434,14 @@ public:
   };
   std::vector<ProgramCache> mProgramCache;
 
+  std::vector<TestGraphicsBuffer*> mAllocatedBuffers;
+
   struct PipelineCache
   {
   };
 
-  std::vector<UniformData> mCustomUniforms;
+  std::vector<UniformData>                                  mCustomUniforms;
+  std::vector<TestGraphicsReflection::TestUniformBlockInfo> mCustomUniformBlocks;
 };
 
 } // namespace Dali
index 8f2e0c7..2706305 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
 
 namespace Dali
 {
-TestGraphicsProgramImpl::TestGraphicsProgramImpl(TestGlAbstraction& gl, const Graphics::ProgramCreateInfo& createInfo, Property::Array& vertexFormats, std::vector<UniformData>& customUniforms)
+TestGraphicsProgramImpl::TestGraphicsProgramImpl(TestGlAbstraction& gl, const Graphics::ProgramCreateInfo& createInfo, Property::Array& vertexFormats, std::vector<UniformData>& customUniforms, std::vector<TestGraphicsReflection::TestUniformBlockInfo>& customUniformBlocks)
 : mGl(gl),
   mId(gl.CreateProgram()),
   mCreateInfo(createInfo),
-  mReflection(gl, mId, vertexFormats, createInfo, customUniforms)
+  mReflection(gl, mId, vertexFormats, createInfo, customUniforms, customUniformBlocks)
 {
   // Ensure active sampler uniforms are set
   mGl.SetCustomUniforms(customUniforms);
index 3899bec..8641800 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_GRAPHICS_PROGRAM_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -27,7 +27,7 @@ namespace Dali
 class TestGraphicsProgramImpl
 {
 public:
-  TestGraphicsProgramImpl(TestGlAbstraction& gl, const Graphics::ProgramCreateInfo& createInfo, Property::Array& vertexFormats, std::vector<UniformData>& customUniforms);
+  TestGraphicsProgramImpl(TestGlAbstraction& gl, const Graphics::ProgramCreateInfo& createInfo, Property::Array& vertexFormats, std::vector<UniformData>& customUniforms, std::vector<TestGraphicsReflection::TestUniformBlockInfo>& customUniformBlocks);
 
   // For API
   const TestGraphicsReflection& GetReflection() const
index 6cb90ba..2822c0a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
 #include <dali/public-api/object/property-map.h>
 #include <string>
 #include <vector>
+
+extern "C"
+{
+  void tet_infoline(const char* str);
+  void tet_printf(const char* format, ...);
+}
+
 namespace Dali
 {
 namespace
@@ -103,7 +110,7 @@ constexpr int GetSizeForType(Property::Type type)
 
 } // namespace
 
-TestGraphicsReflection::TestGraphicsReflection(TestGlAbstraction& gl, uint32_t programId, Property::Array& vfs, const Graphics::ProgramCreateInfo& createInfo, std::vector<UniformData>& customUniforms)
+TestGraphicsReflection::TestGraphicsReflection(TestGlAbstraction& gl, uint32_t programId, Property::Array& vfs, const Graphics::ProgramCreateInfo& createInfo, std::vector<UniformData>& customUniforms, std::vector<TestGraphicsReflection::TestUniformBlockInfo>& customUniformBlocks)
 : mGl(gl),
   mCustomUniforms(customUniforms)
 {
@@ -226,6 +233,10 @@ TestGraphicsReflection::TestGraphicsReflection(TestGlAbstraction& gl, uint32_t p
   mDefaultUniformBlock.size = offset;
 
   mUniformBlocks.push_back(mDefaultUniformBlock);
+  for(auto& element : customUniformBlocks)
+  {
+    mUniformBlocks.push_back(element);
+  }
 }
 
 uint32_t TestGraphicsReflection::GetVertexAttributeLocation(const std::string& name) const
@@ -247,11 +258,13 @@ uint32_t TestGraphicsReflection::GetVertexAttributeLocation(const std::string& n
 
 Dali::Graphics::VertexInputAttributeFormat TestGraphicsReflection::GetVertexAttributeFormat(uint32_t location) const
 {
+  tet_infoline("Warning, TestGraphicsReflection::GetVertexAttributeFormat is unimplemented\n");
   return Dali::Graphics::VertexInputAttributeFormat{};
 }
 
 std::string TestGraphicsReflection::GetVertexAttributeName(uint32_t location) const
 {
+  tet_infoline("Warning, TestGraphicsReflection::GetVertexAttributeName is unimplemented\n");
   return 0u;
 }
 
@@ -272,7 +285,11 @@ uint32_t TestGraphicsReflection::GetUniformBlockCount() const
 
 uint32_t TestGraphicsReflection::GetUniformBlockBinding(uint32_t index) const
 {
-  return 0u;
+  if(index >= mUniformBlocks.size())
+  {
+    return 0;
+  }
+  return mUniformBlocks[index].binding;
 }
 
 uint32_t TestGraphicsReflection::GetUniformBlockSize(uint32_t index) const
@@ -316,11 +333,13 @@ bool TestGraphicsReflection::GetUniformBlock(uint32_t index, Dali::Graphics::Uni
 
 std::vector<uint32_t> TestGraphicsReflection::GetUniformBlockLocations() const
 {
+  tet_infoline("Warning, TestGraphicsReflection::GetUniformBlockLocations is unimplemented\n");
   return std::vector<uint32_t>{};
 }
 
 std::string TestGraphicsReflection::GetUniformBlockName(uint32_t blockIndex) const
 {
+  tet_infoline("Warning, TestGraphicsReflection::GetUniformBlockName is unimplemented\n");
   return std::string{};
 }
 
@@ -362,11 +381,13 @@ uint32_t TestGraphicsReflection::GetUniformBlockMemberOffset(uint32_t blockIndex
 
 bool TestGraphicsReflection::GetNamedUniform(const std::string& name, Dali::Graphics::UniformInfo& out) const
 {
+  tet_infoline("Warning, TestGraphicsReflection::GetNamedUniform is unimplemented\n");
   return true;
 }
 
 const std::vector<Dali::Graphics::UniformInfo>& TestGraphicsReflection::GetSamplers() const
 {
+  tet_infoline("Warning, TestGraphicsReflection::GetSamplers is unimplemented\n");
   static std::vector<Dali::Graphics::UniformInfo> samplers{};
   return samplers;
 }
index e968bd5..e701e17 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_GRAPHICS_REFLECTION_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -26,7 +26,9 @@ namespace Dali
 class TestGraphicsReflection : public Graphics::Reflection
 {
 public:
-  TestGraphicsReflection(TestGlAbstraction& gl, uint32_t program_id, Property::Array& vertexFormats, const Graphics::ProgramCreateInfo& createInfo, std::vector<UniformData>& customUniforms);
+  class TestUniformBlockInfo;
+
+  TestGraphicsReflection(TestGlAbstraction& gl, uint32_t program_id, Property::Array& vertexFormats, const Graphics::ProgramCreateInfo& createInfo, std::vector<UniformData>& customUniforms, std::vector<TestUniformBlockInfo>& customUniformBlocks);
 
   uint32_t                                        GetVertexAttributeLocation(const std::string& name) const override;
   Dali::Graphics::VertexInputAttributeFormat      GetVertexAttributeFormat(uint32_t location) const override;
index 782904c..4d86364 100644 (file)
@@ -31,7 +31,7 @@ class TestGraphicsTexture : public Graphics::Texture
 public:
   TestGraphicsTexture(TestGlAbstraction& glAbstraction, const Graphics::TextureCreateInfo& createInfo);
 
-  ~TestGraphicsTexture();
+  ~TestGraphicsTexture() override;
 
   /**
    * Initialize the texture: allocate gl mem, apply default samplers
index 2316036..1284793 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -248,11 +248,15 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const Trace
 
       for(auto iter = params.mParams.begin(); iter != params.mParams.end(); ++iter)
       {
-        auto        paramIter = mCallStack[i].namedParams.find(iter->parameterName);
-        std::string value     = paramIter->value.str();
-        std::string iValue    = iter->value.str();
-
-        if(paramIter == mCallStack[i].namedParams.end() || value.compare(iValue))
+        auto paramIter = mCallStack[i].namedParams.find(iter->parameterName);
+        if(paramIter == mCallStack[i].namedParams.end())
+        {
+          match = false;
+          break;
+        }
+        std::string value  = paramIter->value.str();
+        std::string iValue = iter->value.str();
+        if(value.compare(iValue))
         {
           match = false;
           break;