Adding graphics sync object 88/258488/2
authorDavid Steele <david.steele@samsung.com>
Wed, 19 May 2021 14:46:26 +0000 (15:46 +0100)
committerDavid Steele <david.steele@samsung.com>
Wed, 19 May 2021 15:58:28 +0000 (16:58 +0100)
Capture requires a pollable sync object so that we can
know when a texture has been written to on the GPU.

Added Graphics::SyncObject, which can be added to
CommandBuffer::END_RENDER_PASS. This is a pollable object
that will test positive when the render pass has been
flushed.

This is owned by RenderTracker; a container of which
is owned by RenderManager separately to the RenderInstruction
which communicates when a sync object is needed.

Renamed Integration::GlSyncAbstraction to Integration::GraphicsSyncAbstraction

Change-Id: I4b5aa27755f1261532a188a9235d088c8bd4ec57
Signed-off-by: David Steele <david.steele@samsung.com>
31 files changed:
automated-tests/src/dali-internal/CMakeLists.txt
automated-tests/src/dali/CMakeLists.txt
automated-tests/src/dali/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali/dali-test-suite-utils/test-application.h
automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp [deleted file]
automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h [deleted file]
automated-tests/src/dali/dali-test-suite-utils/test-graphics-command-buffer.h
automated-tests/src/dali/dali-test-suite-utils/test-graphics-controller.cpp
automated-tests/src/dali/dali-test-suite-utils/test-graphics-controller.h
automated-tests/src/dali/dali-test-suite-utils/test-graphics-sync-impl.cpp [new file with mode: 0644]
automated-tests/src/dali/dali-test-suite-utils/test-graphics-sync-impl.h [new file with mode: 0644]
automated-tests/src/dali/dali-test-suite-utils/test-graphics-sync-object.cpp [new file with mode: 0644]
automated-tests/src/dali/dali-test-suite-utils/test-graphics-sync-object.h [new file with mode: 0644]
automated-tests/src/dali/utc-Dali-RenderTask.cpp
build/tizen/CMakeLists.txt
dali/graphics-api/file.list
dali/graphics-api/graphics-command-buffer.h
dali/graphics-api/graphics-controller.h
dali/graphics-api/graphics-framebuffer.h
dali/graphics-api/graphics-sync-object-create-info.h [new file with mode: 0644]
dali/graphics-api/graphics-sync-object.h [new file with mode: 0644]
dali/graphics-api/graphics-types.h
dali/integration-api/file.list
dali/integration-api/gl-sync-abstraction.h [deleted file]
dali/integration-api/graphics-sync-abstraction.h [new file with mode: 0644]
dali/internal/common/core-impl.cpp
dali/internal/render/common/render-manager.cpp
dali/internal/render/common/render-manager.h
dali/internal/render/common/render-tracker.cpp
dali/internal/render/common/render-tracker.h
dali/internal/update/manager/update-manager.h

index d4576f6d38d8c7d6d7d3e46fc6a028e6c6c1ed28..12b9d388f9b7e0ff752c9f244e05c2bb8658cb69 100644 (file)
@@ -31,7 +31,6 @@ LIST(APPEND TC_SOURCES
         ../dali/dali-test-suite-utils/dali-test-suite-utils.cpp
         ../dali/dali-test-suite-utils/test-application.cpp
         ../dali/dali-test-suite-utils/test-gl-abstraction.cpp
-        ../dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp
         ../dali/dali-test-suite-utils/test-graphics-buffer.cpp
         ../dali/dali-test-suite-utils/test-graphics-command-buffer.cpp
         ../dali/dali-test-suite-utils/test-graphics-controller.cpp
@@ -42,6 +41,8 @@ LIST(APPEND TC_SOURCES
         ../dali/dali-test-suite-utils/test-graphics-sampler.cpp
         ../dali/dali-test-suite-utils/test-graphics-shader.cpp
         ../dali/dali-test-suite-utils/test-graphics-texture.cpp
+        ../dali/dali-test-suite-utils/test-graphics-sync-impl.cpp
+        ../dali/dali-test-suite-utils/test-graphics-sync-object.cpp
         ../dali/dali-test-suite-utils/test-native-image.cpp
         ../dali/dali-test-suite-utils/test-platform-abstraction.cpp
         ../dali/dali-test-suite-utils/test-render-controller.cpp
index b92c6dd1089253d596d786fb570920416daca748..a352f262904bec1e51e77d3e1c9de517dcbe80aa 100644 (file)
@@ -111,7 +111,6 @@ LIST(APPEND TC_SOURCES
         dali-test-suite-utils/test-application.cpp
         dali-test-suite-utils/test-gesture-generator.cpp
         dali-test-suite-utils/test-gl-abstraction.cpp
-        dali-test-suite-utils/test-gl-sync-abstraction.cpp
         dali-test-suite-utils/test-graphics-buffer.cpp
         dali-test-suite-utils/test-graphics-command-buffer.cpp
         dali-test-suite-utils/test-graphics-controller.cpp
@@ -122,6 +121,8 @@ LIST(APPEND TC_SOURCES
         dali-test-suite-utils/test-graphics-shader.cpp
         dali-test-suite-utils/test-graphics-texture.cpp
         dali-test-suite-utils/test-graphics-sampler.cpp
+        dali-test-suite-utils/test-graphics-sync-impl.cpp
+        dali-test-suite-utils/test-graphics-sync-object.cpp
         dali-test-suite-utils/test-native-image.cpp
         dali-test-suite-utils/test-platform-abstraction.cpp
         dali-test-suite-utils/test-render-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/dali-test-suite-utils/test-gl-sync-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-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/dali-test-suite-utils/test-gl-sync-abstraction.h b/automated-tests/src/dali/dali-test-suite-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/dali-test-suite-utils/test-graphics-sync-impl.cpp b/automated-tests/src/dali/dali-test-suite-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/dali-test-suite-utils/test-graphics-sync-impl.h b/automated-tests/src/dali/dali-test-suite-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/dali-test-suite-utils/test-graphics-sync-object.cpp b/automated-tests/src/dali/dali-test-suite-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/dali-test-suite-utils/test-graphics-sync-object.h b/automated-tests/src/dali/dali-test-suite-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
index 7fe384bea3726abd9e897086418bef6a77205cc1..4909fe38add7f7036e77bcf8a080e226325a640c 100644 (file)
@@ -1792,7 +1792,7 @@ int UtcDaliRenderTaskSignalFinished(void)
   tet_infoline("Testing RenderTask::SignalFinished()");
 
   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
-  TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
+  auto& sync = application.GetGraphicsSyncImpl();
 
   CameraActor offscreenCameraActor = CameraActor::New();
 
@@ -1834,7 +1834,7 @@ int UtcDaliRenderTaskSignalFinished(void)
   application.SendNotification();
   DALI_TEST_CHECK(!finished);
 
-  Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
+  Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
   DALI_TEST_CHECK(lastSyncObj != NULL);
 
   application.Render();
@@ -2013,8 +2013,8 @@ int UtcDaliRenderTaskOnce01(void)
 
   // SETUP AN OFFSCREEN RENDER TASK
   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
-  TestGlSyncAbstraction& sync      = application.GetGlSyncAbstraction();
-  TraceCallStack&        drawTrace = application.GetGlAbstraction().GetDrawTrace();
+  auto&           sync      = application.GetGraphicsSyncImpl();
+  TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
   drawTrace.Enable(true);
 
   Actor rootActor = Actor::New();
@@ -2034,7 +2034,7 @@ int UtcDaliRenderTaskOnce01(void)
 
   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
 
-  Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
+  Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
   DALI_TEST_CHECK(lastSyncObj != NULL);
   sync.SetObjectSynced(lastSyncObj, true);
 
@@ -2051,8 +2051,8 @@ int UtcDaliRenderTaskOnce02(void)
 
   // SETUP AN OFFSCREEN RENDER TASK
   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
-  TestGlSyncAbstraction& sync      = application.GetGlSyncAbstraction();
-  TraceCallStack&        drawTrace = application.GetGlAbstraction().GetDrawTrace();
+  auto&           sync      = application.GetGraphicsSyncImpl();
+  TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
   drawTrace.Enable(true);
 
   Actor rootActor = Actor::New();
@@ -2081,7 +2081,7 @@ int UtcDaliRenderTaskOnce02(void)
 
   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
 
-  Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
+  Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
   DALI_TEST_CHECK(lastSyncObj != NULL);
   sync.SetObjectSynced(lastSyncObj, true);
 
@@ -2099,8 +2099,8 @@ int UtcDaliRenderTaskOnce03(void)
 
   // SETUP A CONTINUOUS OFFSCREEN RENDER TASK
   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
-  TestGlSyncAbstraction& sync      = application.GetGlSyncAbstraction();
-  TraceCallStack&        drawTrace = application.GetGlAbstraction().GetDrawTrace();
+  auto&           sync      = application.GetGraphicsSyncImpl();
+  TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
   drawTrace.Enable(true);
 
   Actor rootActor = Actor::New();
@@ -2124,7 +2124,7 @@ int UtcDaliRenderTaskOnce03(void)
   //                                                   drawn   sig    finished  Keep updating
   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
 
-  Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
+  Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
   DALI_TEST_CHECK(lastSyncObj != NULL);
   sync.SetObjectSynced(lastSyncObj, true);
 
@@ -2143,8 +2143,8 @@ int UtcDaliRenderTaskOnce04(void)
 
   // SETUP AN OFFSCREEN RENDER TASK
   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
-  TestGlSyncAbstraction& sync      = application.GetGlSyncAbstraction();
-  TraceCallStack&        drawTrace = application.GetGlAbstraction().GetDrawTrace();
+  auto&           sync      = application.GetGraphicsSyncImpl();
+  TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
   drawTrace.Enable(true);
 
   Actor rootActor = Actor::New();
@@ -2178,7 +2178,7 @@ int UtcDaliRenderTaskOnce04(void)
   //   FAILS                                          drawn   sig    finished  Keep updating
   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, true, __LINE__));
 
-  Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
+  Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
   DALI_TEST_CHECK(lastSyncObj != NULL);
   sync.SetObjectSynced(lastSyncObj, true);
 
@@ -2338,8 +2338,8 @@ int UtcDaliRenderTaskOnceNoSync04(void)
   application.SendNotification();
 
   DALI_TEST_CHECK(UpdateRender(application, drawTrace, true, finished, false, false, __LINE__));
-  TestGlSyncAbstraction&                      sync        = application.GetGlSyncAbstraction();
-  Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
+  auto&                                             sync        = application.GetGraphicsSyncImpl();
+  Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
   DALI_TEST_CHECK(lastSyncObj == NULL);
 
   newTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
@@ -2465,7 +2465,7 @@ int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
   tet_infoline("Testing RenderTask::FinishInvisibleSourceActor()");
 
   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
-  TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
+  auto& sync = application.GetGraphicsSyncImpl();
 
   CameraActor offscreenCameraActor = CameraActor::New();
 
@@ -2514,7 +2514,7 @@ int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
   application.SendNotification();
   DALI_TEST_CHECK(!finished);
 
-  Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
+  Integration::GraphicsSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
   DALI_TEST_CHECK(lastSyncObj != NULL);
 
   application.Render();
index 8dadbc7206131c0427a5a505074ceba0cdfbdcbd..434e27deb13a103d8beeeaad51b38781cc1b6c35 100644 (file)
@@ -366,7 +366,8 @@ IF( ENABLE_LINK_TEST )
     linker-test.cpp
     ${DALI_TEST_SUITE_DIR}/test-application.cpp
     ${DALI_TEST_SUITE_DIR}/test-gl-abstraction.cpp
-    ${DALI_TEST_SUITE_DIR}/test-gl-sync-abstraction.cpp
+    ${DALI_TEST_SUITE_DIR}/test-graphics-sync-impl.cpp
+    ${DALI_TEST_SUITE_DIR}/test-graphics-sync-object.cpp
     ${DALI_TEST_SUITE_DIR}/test-graphics-buffer.cpp
     ${DALI_TEST_SUITE_DIR}/test-graphics-command-buffer.cpp
     ${DALI_TEST_SUITE_DIR}/test-graphics-controller.cpp
index fe4f7d349e74837ba49f36707ae89d485e1d0553..6836fbd4e8472c3008a2646b82bff233472c3969 100644 (file)
@@ -25,6 +25,8 @@ SET( GRAPHICS_API_HEADERS ${GRAPHICS_API_HEADERS}
    ${graphics_src_dir}/graphics-sampler.h
    ${graphics_src_dir}/graphics-shader-create-info.h
    ${graphics_src_dir}/graphics-shader.h
+   ${graphics_src_dir}/graphics-sync-object-create-info.h
+   ${graphics_src_dir}/graphics-sync-object.h
    ${graphics_src_dir}/graphics-texture-create-info.h
    ${graphics_src_dir}/graphics-texture.h
    ${graphics_src_dir}/graphics-types.h
index 4ef92c54974529e272236fcc9663e8bf5573596b..2ac5417c378bcced7af40fce39450b00ec426df5 100644 (file)
@@ -25,10 +25,11 @@ namespace Dali::Graphics
 {
 class Buffer;
 class Pipeline;
-class Texture;
-class Sampler;
 class RenderTarget;
 class RenderPass;
+class Sampler;
+class SyncObject;
+class Texture;
 
 /**
  * @brief Uniform buffer bindings.
@@ -195,8 +196,15 @@ public:
    * the Controller may use end RP marker in order to resolve resource
    * dependencies (for example, to know when target texture is ready
    * before passing it to another render pass).
+   *
+   * The caller may query the sync object to determine when this render
+   * pass has actually finished on the GPU.
+   *
+   * @param[in] syncObject If non-null, this object will ensure an
+   * appropriate fence sync object is created after the render pass is
+   * executed.
    */
-  virtual void EndRenderPass() = 0;
+  virtual void EndRenderPass(Graphics::SyncObject* syncObject) = 0;
 
   /**
    * @brief Executes a list of secondary command buffers
index 024b0da00ef9ae51e670d38c1790d9cb2d7839ff..7aa13b0e010f810badf4d5d08312c9a1e28bbe76 100644 (file)
@@ -34,6 +34,7 @@
 #include "graphics-render-target-create-info.h"
 #include "graphics-sampler-create-info.h"
 #include "graphics-shader-create-info.h"
+#include "graphics-sync-object-create-info.h"
 #include "graphics-texture-create-info.h"
 
 namespace Dali
@@ -41,23 +42,23 @@ namespace Dali
 namespace Integration
 {
 class GlAbstraction;
-class GlSyncAbstraction;
 class GlContextHelperAbstraction;
 } // namespace Integration
 
 namespace Graphics
 {
-class CommandBuffer;
 class Command;
-class RenderTarget;
-class RenderPass;
+class CommandBuffer;
 class Buffer;
-class Texture;
-class Shader;
 class Framebuffer;
+class Memory;
 class Pipeline;
+class RenderPass;
+class RenderTarget;
 class Sampler;
-class Memory;
+class Shader;
+class SyncObject;
+class Texture;
 
 /**
  * @brief Controller class controls render loop
@@ -70,7 +71,6 @@ class Controller
 public:
   // Temporary until graphics api is complete
   virtual Integration::GlAbstraction&              GetGlAbstraction()              = 0;
-  virtual Integration::GlSyncAbstraction&          GetGlSyncAbstraction()          = 0;
   virtual Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() = 0;
 
   /**
@@ -274,6 +274,16 @@ public:
    */
   virtual UniquePtr<RenderTarget> CreateRenderTarget(const RenderTargetCreateInfo& renderTargetCreateInfo, UniquePtr<RenderTarget>&& oldRenderTarget) = 0;
 
+  /**
+   * Create a synchronisation object.
+   *
+   * @return A pointer to an opaque sync object
+   * @param[in] syncObjectCreateInfo The valid SyncObjectCreateInfo structure
+   * @param[in] oldSyncObject The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+   */
+  virtual UniquePtr<SyncObject> CreateSyncObject(const SyncObjectCreateInfo& syncObjectCreateInfo,
+                                                 UniquePtr<SyncObject>&&     oldSyncObject) = 0;
+
   /**
    * @brief Maps memory associated with Buffer object
    *
index 8f8a08cfef5ae95dae6d22074b67f9c6d2231ef2..73ee17e69f5470b006d095d27632ce34176228c2 100644 (file)
@@ -43,4 +43,4 @@ protected:
 } // Namespace Graphics
 } // Namespace Dali
 
-#endif
\ No newline at end of file
+#endif
diff --git a/dali/graphics-api/graphics-sync-object-create-info.h b/dali/graphics-api/graphics-sync-object-create-info.h
new file mode 100644 (file)
index 0000000..fa6180a
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef DALI_GRAPHICS_SYNC_OBJECT_CREATE_INFO_H
+#define DALI_GRAPHICS_SYNC_OBJECT_CREATE_INFO_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 <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-sync-object.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief Interface class for SyncObjectCreateInfo types in the graphics API.
+ */
+struct SyncObjectCreateInfo
+{
+  /**
+   * @brief Sets pointer to the extension
+   *
+   * The pointer to the extension must be set either to nullptr
+   * or to the valid structure. The structures may create
+   * a chain. The last structure in a chain must point at
+   * nullptr.
+   *
+   * @param[in] value pointer to the valid extension structure
+   * @return reference to this structure
+   */
+  auto& SetNextExtension(ExtensionCreateInfo* value)
+  {
+    nextExtension = value;
+    return *this;
+  }
+
+  GraphicsStructureType type{GraphicsStructureType::SYNC_OBJECT_CREATE_INFO_STRUCT};
+  ExtensionCreateInfo*  nextExtension{nullptr};
+
+  const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_SYNC_OBJECT_CREATE_INFO
diff --git a/dali/graphics-api/graphics-sync-object.h b/dali/graphics-api/graphics-sync-object.h
new file mode 100644 (file)
index 0000000..b0e8f92
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef DALI_GRAPHICS_API_GRAPHICS_SYNC_OBJECT_H
+#define DALI_GRAPHICS_API_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.
+ */
+
+namespace Dali::Graphics
+{
+class SyncObject
+{
+public:
+  SyncObject()          = default;
+  virtual ~SyncObject() = default;
+
+  // Definitely not copyable:
+  SyncObject(const SyncObject&) = delete;
+  SyncObject& operator=(const SyncObject&) = delete;
+
+  /**
+   * Determine if the synchronisation object has been signalled.
+   *
+   * @return false if the sync object has not been signalled, true if it has been signalled (and
+   * can now be destroyed)
+   */
+  virtual bool IsSynced() = 0;
+
+protected:
+  SyncObject(SyncObject&&) = default;
+  SyncObject& operator=(SyncObject&&) = default;
+};
+
+} // namespace Dali::Graphics
+
+#endif //DALI_GRAPHICS_API_GRAPHICS_SYNC_OBJECT_H
index 698a7be991a9b5fe7db5f4e8bd51ee98e1090995..d6b207213c13cedc1d93009ccea513fb54c67724 100644 (file)
@@ -1300,7 +1300,8 @@ enum class GraphicsStructureType : uint32_t
   SAMPLER_CREATE_INFO_STRUCT,
   SHADER_CREATE_INFO_STRUCT,
   TEXTURE_CREATE_INFO_STRUCT,
-  RENDER_TARGET_CREATE_INFO_STRUCT
+  RENDER_TARGET_CREATE_INFO_STRUCT,
+  SYNC_OBJECT_CREATE_INFO_STRUCT
 };
 
 /**
index c8129310ced3777171df89acd39ed9bf47b75873..3de0f9892a71f44aacafa53dff9292e61cba428f 100644 (file)
@@ -39,8 +39,8 @@ SET( platform_abstraction_header_files
    ${platform_abstraction_src_dir}/resource-types.h
    ${platform_abstraction_src_dir}/gl-abstraction.h
    ${platform_abstraction_src_dir}/gl-defines.h
-   ${platform_abstraction_src_dir}/gl-sync-abstraction.h
    ${platform_abstraction_src_dir}/gl-context-helper-abstraction.h
+   ${platform_abstraction_src_dir}/graphics-sync-abstraction.h
    ${platform_abstraction_src_dir}/render-controller.h
    ${platform_abstraction_src_dir}/platform-abstraction.h
    ${platform_abstraction_src_dir}/processor-interface.h
diff --git a/dali/integration-api/gl-sync-abstraction.h b/dali/integration-api/gl-sync-abstraction.h
deleted file mode 100644 (file)
index cbe440e..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef DALI_INTEGRATION_GL_SYNC_ABSTRACTION_H
-#define DALI_INTEGRATION_GL_SYNC_ABSTRACTION_H
-
-/*
- * Copyright (c) 2020 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/public-api/common/dali-common.h>
-
-namespace Dali
-{
-namespace Integration
-{
-/**
- * This abstraction defines an API for syncing CPU with GPU.
- * A typical use case is to determine when GL draw calls have finished drawing
- * to a framebuffer.
- */
-class GlSyncAbstraction
-{
-protected:
-  /**
-   * Virtual protected destructor, no deletion through this interface
-   */
-  virtual ~GlSyncAbstraction() = default;
-
-public:
-  class SyncObject
-  {
-  protected:
-    /**
-     * Virtual protected destructor, no deletion through this interface. This prevents
-     * Core from deleting SyncObjects - only Adaptor implementation is able to delete
-     * them.
-     */
-    virtual ~SyncObject() = default;
-
-  public:
-    /**
-     * Determine if the synchronisation object has been signalled.
-     * @return false if the sync object has not been signalled, true if it has been signalled (and
-     * can now be destroyed)
-     */
-    virtual bool IsSynced() = 0;
-  };
-
-  /**
-   * Create a synchronisation object based on the resource id, typically that of
-   * a framebuffer texture. It can then be polled using the same resource id.
-   * @return A pointer to an opaque sync object
-   */
-  virtual SyncObject* CreateSyncObject() = 0;
-
-  /**
-   * Destroy the synchronisation object.
-   * @param[in] syncObject The sync object to destroy
-   */
-  virtual void DestroySyncObject(SyncObject* syncObject) = 0;
-};
-
-} // namespace Integration
-} // namespace Dali
-
-#endif // DALI_INTEGRATION_GL_SYNC_ABSTRACTION_H
diff --git a/dali/integration-api/graphics-sync-abstraction.h b/dali/integration-api/graphics-sync-abstraction.h
new file mode 100644 (file)
index 0000000..38bee54
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef DALI_INTEGRATION_GRAPHICS_SYNC_ABSTRACTION_H
+#define DALI_INTEGRATION_GRAPHICS_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.
+ *
+ */
+
+#include <dali/public-api/common/dali-common.h>
+
+namespace Dali
+{
+namespace Integration
+{
+/**
+ * This abstraction defines an API for syncing CPU with GPU.
+ * A typical use case is to determine when GL draw calls have finished drawing
+ * to a framebuffer.
+ */
+class GraphicsSyncAbstraction
+{
+protected:
+  /**
+   * Virtual protected destructor, no deletion through this interface
+   */
+  virtual ~GraphicsSyncAbstraction() = default;
+
+public:
+  class SyncObject
+  {
+  protected:
+    /**
+     * Virtual protected destructor, no deletion through this interface. This prevents
+     * Core from deleting SyncObjects - only Adaptor implementation is able to delete
+     * them.
+     */
+    virtual ~SyncObject() = default;
+
+  public:
+    /**
+     * Determine if the synchronisation object has been signalled.
+     * @return false if the sync object has not been signalled, true if it has been signalled (and
+     * can now be destroyed)
+     */
+    virtual bool IsSynced() = 0;
+  };
+
+  /**
+   * Create a synchronisation object based on the resource id, typically that of
+   * a framebuffer texture. It can then be polled using the same resource id.
+   * @return A pointer to an opaque sync object
+   */
+  virtual SyncObject* CreateSyncObject() = 0;
+
+  /**
+   * Destroy the synchronisation object.
+   * @param[in] syncObject The sync object to destroy
+   */
+  virtual void DestroySyncObject(SyncObject* syncObject) = 0;
+};
+
+} // namespace Integration
+} // namespace Dali
+
+#endif // DALI_INTEGRATION_GRAPHICS_SYNC_ABSTRACTION_H
index 27e38f8044fcbbfdc7c151cc2726b4fc65d321bd..3b50a24c67dcc1c3ee18016aabd84b517951e4b6 100644 (file)
@@ -24,7 +24,6 @@
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/events/event.h>
 #include <dali/integration-api/gl-context-helper-abstraction.h>
-#include <dali/integration-api/gl-sync-abstraction.h>
 #include <dali/integration-api/platform-abstraction.h>
 #include <dali/integration-api/processor-interface.h>
 #include <dali/integration-api/render-controller.h>
@@ -72,7 +71,6 @@ namespace Internal
 using Integration::Event;
 using Integration::GlAbstraction;
 using Integration::GlContextHelperAbstraction;
-using Integration::GlSyncAbstraction;
 using Integration::PlatformAbstraction;
 using Integration::RenderController;
 using Integration::RenderStatus;
index db74f373ce6cee39bab87be6756f23ed7c132812..75dba9e50e1e280629ab2b31f2d95a41f3eec2c5 100644 (file)
@@ -948,18 +948,16 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
       }
     }
 
+    Graphics::SyncObject* syncObject{nullptr};
+    // If the render instruction has an associated render tracker (owned separately)
+    // and framebuffer, create a one shot sync object, and use it to determine when
+    // the render pass has finished executing on GPU.
     if(instruction.mRenderTracker && instruction.mFrameBuffer)
     {
-      // This will create a sync object every frame this render tracker
-      // is alive (though it should be now be created only for
-      // render-once render tasks)
-      // @todo Add syncing to Graphics API
-      instruction.mRenderTracker->CreateSyncObject(mImpl->graphicsController.GetGlSyncAbstraction());
-      instruction.mRenderTracker = nullptr; // Only create once.
+      syncObject                 = instruction.mRenderTracker->CreateSyncObject(mImpl->graphicsController);
+      instruction.mRenderTracker = nullptr;
     }
-
-    // End render pass
-    mainCommandBuffer->EndRenderPass();
+    mainCommandBuffer->EndRenderPass(syncObject);
   }
   mImpl->renderAlgorithms.SubmitCommandBuffer();
 
index 2af477bc4b4831412df2a292bdb058f5c1fd2d7a..4af1b8b885716ef22c423808eac9c7d7abb7c7fb 100644 (file)
@@ -31,7 +31,6 @@ namespace Dali
 namespace Integration
 {
 class GlAbstraction;
-class GlSyncAbstraction;
 class GlContextHelperAbstraction;
 class RenderStatus;
 class Scene;
index d7278ec703119365c7bfc9540b898efaf6c3b01e..edd884dca261bd62b565c514fcd10d6d3a5426d3 100644 (file)
@@ -19,7 +19,7 @@
 #include <dali/internal/render/common/render-tracker.h>
 
 // INTERNAL INCLUDES
-#include <dali/integration-api/gl-sync-abstraction.h>
+#include <dali/graphics-api/graphics-sync-object-create-info.h>
 #include <dali/internal/render/common/render-tracker-debug.h>
 
 // EXTERNAL INCLUDES
@@ -31,7 +31,7 @@ namespace Internal
 namespace Render
 {
 RenderTracker::RenderTracker()
-: mGlSyncAbstraction(nullptr),
+: mGraphicsController(nullptr),
   mSyncObject(nullptr),
   mSyncTrigger(0)
 {
@@ -41,26 +41,18 @@ RenderTracker::RenderTracker()
 RenderTracker::~RenderTracker()
 {
   TRACKER_LOG(Debug::Verbose);
-  if(mSyncObject)
-  {
-    mGlSyncAbstraction->DestroySyncObject(mSyncObject);
-    mSyncObject = nullptr;
-  }
+  mSyncObject.reset(nullptr); // Will destroy sync object immediately
 }
 
-void RenderTracker::CreateSyncObject(Integration::GlSyncAbstraction& glSyncAbstraction)
+Graphics::SyncObject* RenderTracker::CreateSyncObject(Graphics::Controller& graphicsController)
 {
-  mGlSyncAbstraction = &glSyncAbstraction;
+  mGraphicsController = &graphicsController;
+
   TRACKER_LOG(Debug::General);
 
-  // Destroy any previous sync object
-  if(mSyncObject)
-  {
-    mGlSyncAbstraction->DestroySyncObject(mSyncObject);
-    mSyncObject = nullptr;
-  }
   ResetSyncFlag();
-  mSyncObject = mGlSyncAbstraction->CreateSyncObject();
+  mSyncObject = mGraphicsController->CreateSyncObject(Graphics::SyncObjectCreateInfo{}, std::move(mSyncObject));
+  return mSyncObject.get();
 }
 
 void RenderTracker::PollSyncObject()
@@ -68,8 +60,7 @@ void RenderTracker::PollSyncObject()
   if(mSyncObject && mSyncObject->IsSynced())
   {
     SetSyncFlag();
-    mGlSyncAbstraction->DestroySyncObject(mSyncObject);
-    mSyncObject = nullptr;
+    mSyncObject.reset();
 
     TRACKER_LOG_FMT(Debug::General, " Synced\n");
     return;
index 66f0d50ea5880df5c6ba17195728109b77b7ba24..818b56ac622f4ec9f6f293a24004e2056a294c30 100644 (file)
@@ -18,7 +18,7 @@
  *
  */
 
-#include <dali/integration-api/gl-sync-abstraction.h>
+#include <dali/graphics-api/graphics-controller.h>
 #include <dali/internal/common/message.h>
 
 namespace Dali
@@ -46,8 +46,10 @@ public:
 
   /**
    * Creates a sync object for this tracker. Will delete any existing sync object.
+   *
+   * @param[in] graphicsController The graphics subsystem
    */
-  void CreateSyncObject(Integration::GlSyncAbstraction& glSyncAbstraction);
+  Graphics::SyncObject* CreateSyncObject(Graphics::Controller& graphicsController);
 
   /**
    * Check the GL Sync objects. This is called from Render Thread.
@@ -73,9 +75,9 @@ public:
   void SetSyncFlag();
 
 private:
-  Integration::GlSyncAbstraction*             mGlSyncAbstraction; // The sync abstraction
-  Integration::GlSyncAbstraction::SyncObject* mSyncObject;        // Associated sync object
-  volatile int                                mSyncTrigger;       // Trigger that update thread can read
+  Graphics::Controller*                     mGraphicsController; ///<  The graphics subsystem
+  Graphics::UniquePtr<Graphics::SyncObject> mSyncObject;         ///< Associated sync object
+  volatile int                              mSyncTrigger;        ///< Trigger that update thread can read
 };
 
 } // namespace Render
index 3b2ad2bc797124f8cc00575583f44345688728e9..8a8b2b3aad00adb4b71ad29cbf3e918852f6dffc 100644 (file)
@@ -52,7 +52,6 @@ class FrameCallbackInterface;
 
 namespace Integration
 {
-class GlSyncAbstraction;
 class RenderController;
 
 } // namespace Integration