Sync tests for sync 19/258519/1
authorDavid Steele <david.steele@samsung.com>
Wed, 19 May 2021 17:23:25 +0000 (18:23 +0100)
committerDavid Steele <david.steele@samsung.com>
Wed, 19 May 2021 17:23:25 +0000 (18:23 +0100)
Change-Id: I12e0c00cbdaf1d49cf873d6f8908b8ce3a7e64fe

18 files changed:
automated-tests/src/dali-scene-loader-internal/CMakeLists.txt
automated-tests/src/dali-scene-loader/CMakeLists.txt
automated-tests/src/dali-shader-generator/CMakeLists.txt
automated-tests/src/dali-toolkit-internal/CMakeLists.txt
automated-tests/src/dali-toolkit-styling/CMakeLists.txt
automated-tests/src/dali-toolkit-third-party/CMakeLists.txt
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp [deleted file]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.h [deleted file]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-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-sync-impl.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-impl.h [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-object.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-object.h [new file with mode: 0644]

index eee10598a34d0d733ecdcad749db2a1319e34c2d..0270d3d1354c9ebd030116863e14c6838d14da57 100755 (executable)
@@ -42,7 +42,8 @@ SET(TEST_HARNESS_SOURCES
   ${TEST_HARNESS_DIR}/test-harness.cpp
   ${TEST_HARNESS_DIR}/test-gesture-generator.cpp
   ${TEST_HARNESS_DIR}/test-gl-abstraction.cpp
-  ${TEST_HARNESS_DIR}/test-gl-sync-abstraction.cpp
+  ${TEST_HARNESS_DIR}/test-graphics-sync-impl.cpp
+  ${TEST_HARNESS_DIR}/test-graphics-sync-object.cpp
   ${TEST_HARNESS_DIR}/test-graphics-buffer.cpp
   ${TEST_HARNESS_DIR}/test-graphics-command-buffer.cpp
   ${TEST_HARNESS_DIR}/test-graphics-controller.cpp
index 7ac60356f6728f78f05fae11e1a5614f4dc726ba..60c1b225f6939e6e7bea98501546ca92afd96a81 100755 (executable)
@@ -57,7 +57,8 @@ SET(TEST_HARNESS_SOURCES
   ${TEST_HARNESS_DIR}/test-harness.cpp
   ${TEST_HARNESS_DIR}/test-gesture-generator.cpp
   ${TEST_HARNESS_DIR}/test-gl-abstraction.cpp
-  ${TEST_HARNESS_DIR}/test-gl-sync-abstraction.cpp
+  ${TEST_HARNESS_DIR}/test-graphics-sync-impl.cpp
+  ${TEST_HARNESS_DIR}/test-graphics-sync-object.cpp
   ${TEST_HARNESS_DIR}/test-graphics-buffer.cpp
   ${TEST_HARNESS_DIR}/test-graphics-command-buffer.cpp
   ${TEST_HARNESS_DIR}/test-graphics-framebuffer.cpp
index 4ef7ac6f1e380ed46ea6f82af342a46a52987a13..517b7d3daefb86e82bb9049ce50aea5b276cbd43 100644 (file)
@@ -44,7 +44,8 @@ SET(TEST_HARNESS_SOURCES
   ${TEST_HARNESS_DIR}/test-harness.cpp
   ${TEST_HARNESS_DIR}/test-gesture-generator.cpp
   ${TEST_HARNESS_DIR}/test-gl-abstraction.cpp
-  ${TEST_HARNESS_DIR}/test-gl-sync-abstraction.cpp
+  ${TEST_HARNESS_DIR}/test-graphics-sync-impl.cpp
+  ${TEST_HARNESS_DIR}/test-graphics-sync-object.cpp
   ${TEST_HARNESS_DIR}/test-graphics-buffer.cpp
   ${TEST_HARNESS_DIR}/test-graphics-command-buffer.cpp
   ${TEST_HARNESS_DIR}/test-graphics-controller.cpp
@@ -130,4 +131,3 @@ ADD_CUSTOM_TARGET(
   ALL
   COMMAND ${SHADER_GENERATOR} ${SHADER_FOLDER} ${GENERATED_FOLDER} | grep "SHADER_SHADER_DEFINE_DEF" | grep "shader-define-def.h" > /dev/null 2>&1 && echo "test_def_correct Succeeded"
   VERBATIM)
-
index b914f96f3cb43522d2257a5818167428158edc79..0a65397e6ad0bf22cce8a846b911b0a8d98a0a20 100755 (executable)
@@ -81,7 +81,8 @@ SET(TEST_HARNESS_SOURCES
    ../dali-toolkit/dali-toolkit-test-utils/test-button.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-harness.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp
-   ../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-impl.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-object.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp
index e3d235bf0afc468a70e7ad70d114f62f0cb3ed25..4c211d12504a5b9c756f189d2d94e608c794fc52 100644 (file)
@@ -45,7 +45,8 @@ SET(TEST_HARNESS_SOURCES
    ../dali-toolkit/dali-toolkit-test-utils/test-application.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp
-   ../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-impl.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-object.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp
index d8638a2b1470f7c7f418817374cf642872bd2a67..e30acba56c27cf8b57821c85b0ba184a196aabdd 100644 (file)
@@ -31,7 +31,8 @@ SET(TEST_HARNESS_SOURCES
    ../dali-toolkit/dali-toolkit-test-utils/test-button.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-harness.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp
-   ../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-impl.cpp
+   ../dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-object.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp
index 080fd8d4a25e6eee7cbc121377a98bc41c40fa61..2983fd77b09060106f6d76f63807d95e7baca362 100755 (executable)
@@ -112,7 +112,8 @@ SET(TEST_HARNESS_SOURCES
   dali-toolkit-test-utils/test-harness.cpp
   dali-toolkit-test-utils/test-gesture-generator.cpp
   dali-toolkit-test-utils/test-gl-abstraction.cpp
-  dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
+  dali-toolkit-test-utils/test-graphics-sync-impl.cpp
+  dali-toolkit-test-utils/test-graphics-sync-object.cpp
   dali-toolkit-test-utils/test-graphics-buffer.cpp
   dali-toolkit-test-utils/test-graphics-command-buffer.cpp
   dali-toolkit-test-utils/test-graphics-controller.cpp
index 6075c8fac48657828e8fc989cf2bed146ee8484a..5e69c95111296bbd9ae29b1f680198a6c02d945e 100644 (file)
@@ -155,14 +155,14 @@ TestGlAbstraction& TestApplication::GetGlAbstraction()
   return static_cast<TestGlAbstraction&>(mGraphicsController.GetGlAbstraction());
 }
 
-TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction()
+TestGlContextHelperAbstraction& TestApplication::GetGlContextHelperAbstraction()
 {
-  return static_cast<TestGlSyncAbstraction&>(mGraphicsController.GetGlSyncAbstraction());
+  return static_cast<TestGlContextHelperAbstraction&>(mGraphicsController.GetGlContextHelperAbstraction());
 }
 
-TestGlContextHelperAbstraction& TestApplication::GetGlContextHelperAbstraction()
+TestGraphicsSyncImplementation& TestApplication::GetGraphicsSyncImpl()
 {
-  return static_cast<TestGlContextHelperAbstraction&>(mGraphicsController.GetGlContextHelperAbstraction());
+  return static_cast<TestGraphicsSyncImplementation&>(mGraphicsController.GetGraphicsSyncImpl());
 }
 
 void TestApplication::ProcessEvent(const Integration::Event& event)
index ad5d1982ca605476137587bd6385137055a6f14b..4f32cd889790d9ba0406d2da959aaa2eb7cbe2d8 100644 (file)
@@ -65,8 +65,8 @@ public:
   TestGraphicsController&  GetGraphicsController();
 
   TestGlAbstraction&              GetGlAbstraction();
-  TestGlSyncAbstraction&          GetGlSyncAbstraction();
   TestGlContextHelperAbstraction& GetGlContextHelperAbstraction();
+  TestGraphicsSyncImplementation& GetGraphicsSyncImpl();
 
   void        ProcessEvent(const Integration::Event& event);
   void        SendNotification();
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
deleted file mode 100644 (file)
index f404f32..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "test-gl-sync-abstraction.h"
-
-namespace Dali
-{
-TestSyncObject::TestSyncObject(TraceCallStack& trace)
-: synced(false),
-  mTrace(trace)
-{
-}
-
-TestSyncObject::~TestSyncObject()
-{
-}
-
-bool TestSyncObject::IsSynced()
-{
-  mTrace.PushCall("SyncObject::IsSynced", ""); // Trace the method
-  return synced;
-}
-
-TestGlSyncAbstraction::TestGlSyncAbstraction()
-{
-  Initialize();
-}
-
-/**
- * Destructor
- */
-TestGlSyncAbstraction::~TestGlSyncAbstraction()
-{
-  for(SyncIter iter = mSyncObjects.begin(), end = mSyncObjects.end(); iter != end; ++iter)
-  {
-    delete *iter;
-  }
-}
-
-/**
- * Initialize the sync objects - clear down the map
- */
-void TestGlSyncAbstraction::Initialize()
-{
-  mSyncObjects.clear();
-}
-
-/**
- * Create a sync object
- * @return the sync object
- */
-Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::CreateSyncObject()
-{
-  mTrace.PushCall("CreateSyncObject", ""); // Trace the method
-
-  TestSyncObject* syncObject = new TestSyncObject(mTrace);
-  mSyncObjects.push_back(syncObject);
-  return syncObject;
-}
-
-/**
- * Destroy a sync object
- * @param[in] syncObject The object to destroy
- */
-void TestGlSyncAbstraction::DestroySyncObject(Integration::GlSyncAbstraction::SyncObject* syncObject)
-{
-  std::stringstream out;
-  out << syncObject;
-  mTrace.PushCall("DestroySyncObject", out.str()); // Trace the method
-
-  for(SyncIter iter = mSyncObjects.begin(), end = mSyncObjects.end(); iter != end; ++iter)
-  {
-    if(*iter == syncObject)
-    {
-      delete *iter;
-      mSyncObjects.erase(iter);
-      break;
-    }
-  }
-}
-
-Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::GetLastSyncObject()
-{
-  if(!mSyncObjects.empty())
-  {
-    return mSyncObjects.back();
-  }
-  return NULL;
-}
-
-/**
- * Test method to trigger the object sync behaviour.
- * @param[in]
- * @param[in] sync The sync value to set
- */
-void TestGlSyncAbstraction::SetObjectSynced(Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync)
-{
-  TestSyncObject* testSyncObject = static_cast<TestSyncObject*>(syncObject);
-  testSyncObject->synced         = sync;
-}
-
-/**
- * Turn trace on
- */
-void TestGlSyncAbstraction::EnableTrace(bool enable)
-{
-  mTrace.Enable(enable);
-}
-
-/**
- * Reset the trace callstack
- */
-void TestGlSyncAbstraction::ResetTrace()
-{
-  mTrace.Reset();
-}
-
-/**
- * Get the trace object (allows test case to find methods on it)
- */
-TraceCallStack& TestGlSyncAbstraction::GetTrace()
-{
-  return mTrace;
-}
-
-int32_t TestGlSyncAbstraction::GetNumberOfSyncObjects()
-{
-  return static_cast<int32_t>(mSyncObjects.size());
-}
-
-} // namespace Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.h
deleted file mode 100644 (file)
index 73be9ee..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-#ifndef TEST_GL_SYNC_ABSTRACTION_H
-#define TEST_GL_SYNC_ABSTRACTION_H
-
-/*
- * Copyright (c) 2021 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <map>
-#include <sstream>
-#include <string>
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/core.h>
-#include <dali/integration-api/gl-sync-abstraction.h>
-
-#include "test-trace-call-stack.h"
-
-namespace Dali
-{
-class DALI_CORE_API TestSyncObject : public Integration::GlSyncAbstraction::SyncObject
-{
-public:
-  TestSyncObject(TraceCallStack& trace);
-  ~TestSyncObject() override;
-  bool            IsSynced() override;
-  bool            synced;
-  TraceCallStack& mTrace;
-};
-
-/**
- * Class to emulate the GL sync functions with tracing
- */
-class DALI_CORE_API TestGlSyncAbstraction : public Integration::GlSyncAbstraction
-{
-public:
-  /**
-   * Constructor
-   */
-  TestGlSyncAbstraction();
-
-  /**
-   * Destructor
-   */
-  ~TestGlSyncAbstraction() override;
-
-  /**
-   * Initialize the sync objects - clear down the map
-   */
-  void Initialize();
-
-  /**
-   * Create a sync object
-   * @return the sync object
-   */
-  Integration::GlSyncAbstraction::SyncObject* CreateSyncObject() override;
-
-  /**
-   * Destroy a sync object
-   * @param[in] syncObject The object to destroy
-   */
-  void DestroySyncObject(Integration::GlSyncAbstraction::SyncObject* syncObject) override;
-
-public: // TEST FUNCTIONS
-  Integration::GlSyncAbstraction::SyncObject* GetLastSyncObject();
-
-  /**
-   * Test method to trigger the object sync behaviour.
-   * @param[in]
-   * @param[in] sync The sync value to set
-   */
-  void SetObjectSynced(Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync);
-
-  /**
-   * Turn trace on
-   */
-  void EnableTrace(bool enable);
-
-  /**
-   * Reset the trace callstack
-   */
-  void ResetTrace();
-
-  /**
-   * Get the trace object (allows test case to find methods on it)
-   */
-  TraceCallStack& GetTrace();
-
-  /**
-   * Get the number of sync objects
-   *
-   * @return the number of sync objects
-   */
-  int32_t GetNumberOfSyncObjects();
-
-private:
-  TestGlSyncAbstraction(const TestGlSyncAbstraction&);            ///< Undefined
-  TestGlSyncAbstraction& operator=(const TestGlSyncAbstraction&); ///< Undefined
-
-  typedef std::vector<TestSyncObject*> SyncContainer;
-  typedef SyncContainer::iterator      SyncIter;
-  SyncContainer                        mSyncObjects;       ///< The sync objects
-  TraceCallStack                       mTrace{true, "gl"}; ///< the trace call stack for testing
-};
-
-} // namespace Dali
-
-#endif // TEST_GL_SYNC_ABSTRACTION_H
index b75a4022ede4df14ee8dc688518776ca71547ce0..3df3219b98c65ada48beb3be7de83646d3c77acc 100644 (file)
@@ -593,6 +593,7 @@ struct Command
 
     struct
     {
+      Graphics::SyncObject* syncObject;
     } endRenderPass;
 
     struct
@@ -774,9 +775,16 @@ public:
    * dependencies (for example, to know when target texture is ready
    * before passing it to another render pass).
    */
-  void EndRenderPass() override
+  void EndRenderPass(Graphics::SyncObject* syncObject) override
   {
-    mCallStack.PushCall("EndRenderPass", "");
+    mCommands.emplace_back(CommandType::END_RENDER_PASS);
+    auto& cmd = mCommands.back();
+
+    cmd.data.endRenderPass.syncObject = syncObject;
+
+    TraceCallStack::NamedParams namedParams;
+    namedParams["syncObject"] << std::hex << syncObject;
+    mCallStack.PushCall("EndRenderPass", namedParams.str(), namedParams);
   }
 
   void ExecuteCommandBuffers(std::vector<const CommandBuffer*>&& commandBuffers) override
index e5db6ed8937637331d60224c254660f4fbb3200d..517463fa310b0f15f918b258e584a0c3d4d397c2 100644 (file)
@@ -24,6 +24,7 @@
 #include "test-graphics-render-target.h"
 #include "test-graphics-sampler.h"
 #include "test-graphics-shader.h"
+#include "test-graphics-sync-object.h"
 #include "test-graphics-texture.h"
 
 #include <dali/integration-api/gl-defines.h>
@@ -861,6 +862,11 @@ void TestGraphicsController::ProcessCommandBuffer(TestGraphicsCommandBuffer& com
       }
       case CommandType::END_RENDER_PASS:
       {
+        if(cmd.data.endRenderPass.syncObject != nullptr)
+        {
+          auto syncObject = Uncast<TestGraphicsSyncObject>(cmd.data.endRenderPass.syncObject);
+          syncObject->InitializeResource(); // create the sync object.
+        }
         break;
       }
     }
@@ -1149,6 +1155,14 @@ Graphics::UniquePtr<Graphics::RenderTarget> TestGraphicsController::CreateRender
   return Graphics::MakeUnique<TestGraphicsRenderTarget>(mGl, renderTargetCreateInfo);
 }
 
+Graphics::UniquePtr<Graphics::SyncObject> TestGraphicsController::CreateSyncObject(
+  const Graphics::SyncObjectCreateInfo&       syncObjectCreateInfo,
+  Graphics::UniquePtr<Graphics::SyncObject>&& oldSyncObject)
+{
+  mCallStack.PushCall("CreateSyncObject", "");
+  return Graphics::MakeUnique<TestGraphicsSyncObject>(mGraphicsSyncImpl, syncObjectCreateInfo);
+}
+
 Graphics::UniquePtr<Graphics::Memory> TestGraphicsController::MapBufferRange(const Graphics::MapBufferInfo& mapInfo)
 {
   mCallStack.PushCall("MapBufferRange", "");
index 1c62119ae979ae49ce07f51b39cc1e75296dcde8..cabc414740955c4532831101a6ae7649681235e0 100644 (file)
 #include <dali/graphics-api/graphics-controller.h>
 #include "test-gl-abstraction.h"
 #include "test-gl-context-helper-abstraction.h"
-#include "test-gl-sync-abstraction.h"
 #include "test-graphics-command-buffer.h"
 #include "test-graphics-program.h"
 #include "test-graphics-reflection.h"
+#include "test-graphics-sync-impl.h"
 
 namespace Dali
 {
@@ -85,6 +85,12 @@ T* Uncast(const Graphics::RenderTarget* object)
   return const_cast<T*>(static_cast<const T*>(object));
 }
 
+template<typename T>
+T* Uncast(const Graphics::SyncObject* object)
+{
+  return const_cast<T*>(static_cast<const T*>(object));
+}
+
 class TestGraphicsController : public Dali::Graphics::Controller
 {
 public:
@@ -102,14 +108,14 @@ public:
     return mGl;
   }
 
-  Integration::GlSyncAbstraction& GetGlSyncAbstraction() override
+  Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override
   {
-    return mGlSyncAbstraction;
+    return mGlContextHelperAbstraction;
   }
 
-  Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override
+  TestGraphicsSyncImplementation& GetGraphicsSyncImpl()
   {
-    return mGlContextHelperAbstraction;
+    return mGraphicsSyncImpl;
   }
 
   void SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo) override;
@@ -273,12 +279,21 @@ public:
    */
   Graphics::UniquePtr<Graphics::RenderTarget> CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<Graphics::RenderTarget>&& oldRenderTarget) override;
 
+  /**
+   * @brief Creates new sync object
+   * Could add timeout etc to createinfo... but nah.
+   *
+   * @return pointer to the SyncObject
+   */
+  Graphics::UniquePtr<Graphics::SyncObject> CreateSyncObject(const Graphics::SyncObjectCreateInfo&       syncObjectCreateInfo,
+                                                             Graphics::UniquePtr<Graphics::SyncObject>&& oldSyncObject) override;
+
   /**
    * @brief Maps memory associated with Buffer object
    *
    * @param[in] mapInfo Filled details of mapped resource
    *
-   * @return Returns pointer to Memory object or Graphicsnullptr on error
+   * @return Returns pointer to Memory object or nullptr on error
    */
   Graphics::UniquePtr<Graphics::Memory> MapBufferRange(const Graphics::MapBufferInfo& mapInfo) override;
 
@@ -397,7 +412,7 @@ public:
   mutable std::vector<Graphics::SubmitInfo> mSubmitStack;
 
   TestGlAbstraction              mGl;
-  TestGlSyncAbstraction          mGlSyncAbstraction;
+  TestGraphicsSyncImplementation mGraphicsSyncImpl;
   TestGlContextHelperAbstraction mGlContextHelperAbstraction;
 
   bool isDiscardQueueEmptyResult{true};
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-impl.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-impl.cpp
new file mode 100644 (file)
index 0000000..17f53a7
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "test-graphics-sync-impl.h"
+
+namespace Dali
+{
+TestSyncObject::TestSyncObject(Dali::TraceCallStack& trace)
+
+: synced(false),
+  mTrace(trace)
+{
+  mTrace.PushCall("TestSyncObject cons", ""); // Trace the method
+}
+
+TestSyncObject::~TestSyncObject()
+{
+  mTrace.PushCall("TestSyncObject dstr", ""); // Trace the method
+}
+
+bool TestSyncObject::IsSynced()
+{
+  mTrace.PushCall("SyncObject::IsSynced", ""); // Trace the method
+  return synced;
+}
+
+TestGraphicsSyncImplementation::TestGraphicsSyncImplementation()
+{
+  Initialize();
+}
+
+/**
+ * Destructor
+ */
+TestGraphicsSyncImplementation::~TestGraphicsSyncImplementation()
+{
+  for(SyncIter iter = mSyncObjects.begin(), end = mSyncObjects.end(); iter != end; ++iter)
+  {
+    delete *iter;
+  }
+}
+
+/**
+ * Initialize the sync objects
+ */
+void TestGraphicsSyncImplementation::Initialize()
+{
+  mSyncObjects.clear();
+}
+
+Integration::GraphicsSyncAbstraction::SyncObject* TestGraphicsSyncImplementation::CreateSyncObject()
+{
+  mTrace.PushCall("CreateSyncObject", ""); // Trace the method
+
+  TestSyncObject* syncObject = new TestSyncObject(mTrace);
+  mSyncObjects.push_back(syncObject);
+  return syncObject;
+}
+
+/**
+ * Destroy a sync object
+ * @param[in] syncObject The object to destroy
+ */
+void TestGraphicsSyncImplementation::DestroySyncObject(Integration::GraphicsSyncAbstraction::SyncObject* syncObject)
+{
+  std::stringstream out;
+  out << syncObject;
+  mTrace.PushCall("DestroySyncObject", out.str()); // Trace the method
+
+  for(SyncIter iter = mSyncObjects.begin(), end = mSyncObjects.end(); iter != end; ++iter)
+  {
+    if(*iter == syncObject)
+    {
+      delete *iter;
+      mSyncObjects.erase(iter);
+      break;
+    }
+  }
+}
+
+Integration::GraphicsSyncAbstraction::SyncObject* TestGraphicsSyncImplementation::GetLastSyncObject()
+{
+  if(!mSyncObjects.empty())
+  {
+    return mSyncObjects.back();
+  }
+  return NULL;
+}
+
+/**
+ * Test method to trigger the object sync behaviour.
+ * @param[in]
+ * @param[in] sync The sync value to set
+ */
+void TestGraphicsSyncImplementation::SetObjectSynced(Integration::GraphicsSyncAbstraction::SyncObject* syncObject, bool sync)
+{
+  TestSyncObject* testSyncObject = static_cast<TestSyncObject*>(syncObject);
+  testSyncObject->synced         = sync;
+}
+
+/**
+ * Turn trace on
+ */
+void TestGraphicsSyncImplementation::EnableTrace(bool enable)
+{
+  mTrace.Enable(enable);
+}
+
+/**
+ * Reset the trace callstack
+ */
+void TestGraphicsSyncImplementation::ResetTrace()
+{
+  mTrace.Reset();
+}
+
+/**
+ * Get the trace object (allows test case to find methods on it)
+ */
+TraceCallStack& TestGraphicsSyncImplementation::GetTrace()
+{
+  return mTrace;
+}
+
+int32_t TestGraphicsSyncImplementation::GetNumberOfSyncObjects()
+{
+  return static_cast<int32_t>(mSyncObjects.size());
+}
+
+} // namespace Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-impl.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-impl.h
new file mode 100644 (file)
index 0000000..cbc5331
--- /dev/null
@@ -0,0 +1,123 @@
+#ifndef TEST_SYNC_IMPLEMENTATION_H
+#define TEST_SYNC_IMPLEMENTATION_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <map>
+#include <sstream>
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali/graphics-api/graphics-sync-object-create-info.h>
+#include <dali/graphics-api/graphics-sync-object.h>
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/graphics-sync-abstraction.h>
+
+#include "test-trace-call-stack.h"
+
+namespace Dali
+{
+class TestGraphicsSyncImplementation;
+
+class TestSyncObject : public Integration::GraphicsSyncAbstraction::SyncObject
+{
+public:
+  TestSyncObject(TraceCallStack& trace);
+  ~TestSyncObject() override;
+  bool            IsSynced() override;
+  bool            synced;
+  TraceCallStack& mTrace;
+};
+
+/**
+ * Class to emulate the gpu sync functions with tracing
+ */
+class TestGraphicsSyncImplementation : public Integration::GraphicsSyncAbstraction
+{
+public:
+  /**
+   * Constructor
+   */
+  TestGraphicsSyncImplementation();
+
+  /**
+   * Destructor
+   */
+  virtual ~TestGraphicsSyncImplementation();
+
+  /**
+   * Initialize the sync objects
+   */
+  void Initialize();
+
+  /**
+   * Create a sync object that can be polled
+   */
+  GraphicsSyncAbstraction::SyncObject* CreateSyncObject() override;
+
+  /**
+   * Destroy a sync object
+   */
+  void DestroySyncObject(GraphicsSyncAbstraction::SyncObject* syncObject) override;
+
+public: // TEST FUNCTIONS
+  GraphicsSyncAbstraction::SyncObject* GetLastSyncObject();
+
+  /**
+   * Test method to trigger the object sync behaviour.
+   * @param[in]
+   * @param[in] sync The sync value to set
+   */
+  void SetObjectSynced(GraphicsSyncAbstraction::SyncObject* syncObject, bool sync);
+
+  /**
+   * Turn trace on
+   */
+  void EnableTrace(bool enable);
+
+  /**
+   * Reset the trace callstack
+   */
+  void ResetTrace();
+
+  /**
+   * Get the trace object (allows test case to find methods on it)
+   */
+  TraceCallStack& GetTrace();
+
+  /**
+   * Get the number of sync objects
+   *
+   * @return the number of sync objects
+   */
+  int32_t GetNumberOfSyncObjects();
+
+  TestGraphicsSyncImplementation(const TestGraphicsSyncImplementation&) = delete;
+  TestGraphicsSyncImplementation& operator=(const TestGraphicsSyncImplementation&) = delete;
+
+private:
+  typedef std::vector<TestSyncObject*> SyncContainer;
+  typedef SyncContainer::iterator      SyncIter;
+  SyncContainer                        mSyncObjects;       ///< The sync objects
+  TraceCallStack                       mTrace{true, "gl"}; ///< the trace call stack for testing
+};
+
+} // namespace Dali
+
+#endif // TEST_GL_SYNC_ABSTRACTION_H
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-object.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-object.cpp
new file mode 100644 (file)
index 0000000..cf9b3c9
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "test-graphics-sync-object.h"
+
+namespace Dali
+{
+TestGraphicsSyncObject::TestGraphicsSyncObject(TestGraphicsSyncImplementation& syncImpl, const Graphics::SyncObjectCreateInfo& createInfo)
+: mSyncImplementation(syncImpl),
+  mSyncObject(nullptr),
+  mCreateInfo(createInfo)
+{
+}
+
+TestGraphicsSyncObject::~TestGraphicsSyncObject()
+{
+  mSyncImplementation.DestroySyncObject(mSyncObject);
+}
+
+void TestGraphicsSyncObject::InitializeResource()
+{
+  mSyncObject = static_cast<TestSyncObject*>(mSyncImplementation.CreateSyncObject());
+}
+
+bool TestGraphicsSyncObject::IsSynced()
+{
+  bool synced = false;
+  if(mSyncObject)
+  {
+    synced = mSyncObject->IsSynced();
+  }
+  return synced;
+}
+
+} // namespace Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-object.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-sync-object.h
new file mode 100644 (file)
index 0000000..c33de6c
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef DALI_TEST_GRAPHICS_SYNC_OBJECT_H_
+#define DALI_TEST_GRAPHICS_SYNC_OBJECT_H_
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali/graphics-api/graphics-sync-object-create-info.h>
+#include <dali/graphics-api/graphics-sync-object.h>
+
+#include <test-graphics-sync-impl.h>
+
+namespace Dali
+{
+class TestGraphicsSyncObject : public Graphics::SyncObject
+{
+public:
+  TestGraphicsSyncObject(TestGraphicsSyncImplementation& syncImpl, const Graphics::SyncObjectCreateInfo& createInfo);
+  ~TestGraphicsSyncObject() override;
+  void InitializeResource();
+  bool IsSynced() override;
+
+public:
+  TestGraphicsSyncImplementation& mSyncImplementation;
+  TestSyncObject*                 mSyncObject;
+  Graphics::SyncObjectCreateInfo  mCreateInfo;
+};
+
+} // namespace Dali
+
+#endif //DALI_TEST_GRAPHICS_SYNC_OBJECT_H