Added dali-vk-graphics test module 12/315712/4
authorDavid Steele <david.steele@samsung.com>
Tue, 23 Jul 2024 17:15:45 +0000 (18:15 +0100)
committerDavid Steele <david.steele@samsung.com>
Fri, 16 Aug 2024 11:13:35 +0000 (12:13 +0100)
Added a new test module to build test suite with actual
vulkan backend; but with a stubbed vulkan driver. (TBD)

Change-Id: I8646cc861ae2ac4c010917300eb4cab7b481efe2
Signed-off-by: David Steele <david.steele@samsung.com>
21 files changed:
automated-tests/build.sh
automated-tests/src/common/assert.h [deleted file]
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-egl-application.cpp [moved from automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.cpp with 99% similarity]
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-egl-application.h [moved from automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h with 98% similarity]
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-vk-application.cpp [new file with mode: 0644]
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-vk-application.h [new file with mode: 0644]
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-vk-abstraction.cpp [new file with mode: 0644]
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-vk-abstraction.h [new file with mode: 0644]
automated-tests/src/dali-egl-graphics/CMakeLists.txt
automated-tests/src/dali-egl-graphics/utc-Dali-GraphicsBuffer.cpp
automated-tests/src/dali-egl-graphics/utc-Dali-GraphicsDraw.cpp
automated-tests/src/dali-egl-graphics/utc-Dali-GraphicsFramebuffer.cpp
automated-tests/src/dali-egl-graphics/utc-Dali-GraphicsGeometry.cpp
automated-tests/src/dali-egl-graphics/utc-Dali-GraphicsNativeImage.cpp
automated-tests/src/dali-egl-graphics/utc-Dali-GraphicsProgram.cpp
automated-tests/src/dali-egl-graphics/utc-Dali-GraphicsSampler.cpp
automated-tests/src/dali-egl-graphics/utc-Dali-GraphicsShader.cpp
automated-tests/src/dali-egl-graphics/utc-Dali-GraphicsTexture.cpp
automated-tests/src/dali-vk-graphics/CMakeLists.txt [new file with mode: 0644]
automated-tests/src/dali-vk-graphics/tct-dali-vk-graphics-core.cpp [new file with mode: 0644]
automated-tests/src/dali-vk-graphics/utc-Dali-VkGraphicsBuffer.cpp [new file with mode: 0644]

index 513dcd7..4c99d71 100755 (executable)
@@ -60,11 +60,16 @@ else
   for mod in `ls -1 src/ | grep -v CMakeList `
   do
       build=0
-      # Don't build dali-egl-graphics if we are using Vulkan...
+      # only build dali-egl-graphics if we are not using Vulkan.
       if [ $mod == 'dali-egl-graphics' ] ; then
           if [ $ENABLE_VULKAN == 0 ] ; then
               build=1
           fi
+      # only build dali-vk-graphics if we are using Vulkan.
+      elif [ $mod == 'dali-vk-graphics' ] ; then
+          if [ $ENABLE_VULKAN == 1 ] ; then
+              build=1
+          fi
       elif [ $mod != 'common' ] && [ $mod != 'manual' ]; then
           build=1
       fi
diff --git a/automated-tests/src/common/assert.h b/automated-tests/src/common/assert.h
deleted file mode 100644 (file)
index 677795a..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-#ifndef _ASSERT_H_
-#define _ASSERT_H_
-#include <stdio.h>
-#include <stdlib.h>
-
-#define assert(exp)                               \
-  if(!(exp))                                      \
-  {                                               \
-    fprintf(stderr,                               \
-            "Assert fail in %s:%d\n",             \
-            __FILE__,                             \
-            __LINE__);                            \
-    fprintf(stderr,                               \
-            "Following expression is not true:\n" \
-            "%s\n",                               \
-            #exp);                                \
-    return 1;                                     \
-  }
-
-#define assert_eq(var, ref)                             \
-  if(var != ref)                                        \
-  {                                                     \
-    fprintf(stderr,                                     \
-            "Assert fail in %s:%d\n",                   \
-            __FILE__,                                   \
-            __LINE__);                                  \
-    fprintf(stderr,                                     \
-            "Values \"%s\" and \"%s\" are not equal:\n" \
-            "%s == %d, %s == %d\n",                     \
-            #var,                                       \
-            #ref,                                       \
-            #var,                                       \
-            (int)var,                                   \
-            #ref,                                       \
-            (int)ref);                                  \
-    return 1;                                           \
-  }
-
-#define assert_neq(var, ref)                        \
-  if(var == ref)                                    \
-  {                                                 \
-    fprintf(stderr,                                 \
-            "Assert fail in %s:%d\n",               \
-            __FILE__,                               \
-            __LINE__);                              \
-    fprintf(stderr,                                 \
-            "Values \"%s\" and \"%s\" are equal:\n" \
-            "%s == %s == %d\n",                     \
-            #var,                                   \
-            #ref,                                   \
-            #var,                                   \
-            #ref,                                   \
-            (int)ref);                              \
-    return 1;                                       \
-  }
-
-#define assert_gt(var, ref)                              \
-  if(var <= ref)                                         \
-  {                                                      \
-    fprintf(stderr,                                      \
-            "Assert fail in %s:%d\n",                    \
-            __FILE__,                                    \
-            __LINE__);                                   \
-    fprintf(stderr,                                      \
-            "Value \"%s\" is not greater than \"%s\":\n" \
-            "%s == %d, %s == %d\n",                      \
-            #var,                                        \
-            #ref,                                        \
-            #var,                                        \
-            var,                                         \
-            #ref,                                        \
-            ref);                                        \
-    return 1;                                            \
-  }
-
-#define assert_geq(var, ref)                                    \
-  if(var < ref)                                                 \
-  {                                                             \
-    fprintf(stderr,                                             \
-            "Assert fail in %s:%d\n",                           \
-            __FILE__,                                           \
-            __LINE__);                                          \
-    fprintf(stderr,                                             \
-            "Value \"%s\" is not greater or equal to \"%s\":\n" \
-            "%s == %d, %s == %d\n",                             \
-            #var,                                               \
-            #ref,                                               \
-            #var,                                               \
-            var,                                                \
-            #ref,                                               \
-            ref);                                               \
-    return 1;                                                   \
-  }
-
-#define assert_lt(var, ref)                            \
-  if(var >= ref)                                       \
-  {                                                    \
-    fprintf(stderr,                                    \
-            "Assert fail in %s:%d\n",                  \
-            __FILE__,                                  \
-            __LINE__);                                 \
-    fprintf(stderr,                                    \
-            "Value \"%s\" is not lower than \"%s\":\n" \
-            "%s == %d, %s == %d\n",                    \
-            #var,                                      \
-            #ref,                                      \
-            #var,                                      \
-            var,                                       \
-            #ref,                                      \
-            ref);                                      \
-    return 1;                                          \
-  }
-
-#define assert_leq(var, ref)                                  \
-  if(var > ref)                                               \
-  {                                                           \
-    fprintf(stderr,                                           \
-            "Assert fail in %s:%d\n",                         \
-            __FILE__,                                         \
-            __LINE__);                                        \
-    fprintf(stderr,                                           \
-            "Value \"%s\" is not lower or equal to \"%s\":\n" \
-            "%s == %d, %s == %d\n",                           \
-            #var,                                             \
-            #ref,                                             \
-            #var,                                             \
-            var,                                              \
-            #ref,                                             \
-            ref);                                             \
-    return 1;                                                 \
-  }
-
-#endif //  _ASSERT_H_
@@ -1,5 +1,4 @@
-#ifndef DALI_TEST_GRAPHICS_APPLICATION_H
-#define DALI_TEST_GRAPHICS_APPLICATION_H
+#pragma once
 
 /*
  * Copyright (c) 2024 Samsung Electronics Co., Ltd.
@@ -393,5 +392,3 @@ protected:
 };
 
 } // namespace Dali
-
-#endif // DALI_TEST_GRAPHICS_APPLICATION_H
diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-vk-application.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-vk-application.cpp
new file mode 100644 (file)
index 0000000..224986b
--- /dev/null
@@ -0,0 +1,299 @@
+/*
+ * Copyright (c) 2024 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-vk-application.h"
+
+namespace Dali
+{
+bool TestGraphicsApplication::mLoggingEnabled = true;
+
+TestGraphicsApplication::TestGraphicsApplication(uint32_t surfaceWidth,
+                                                 uint32_t surfaceHeight,
+                                                 uint32_t horizontalDpi,
+                                                 uint32_t verticalDpi,
+                                                 bool     initialize,
+                                                 bool     enablePartialUpdate)
+: mGraphics(GetGraphicsCreateInfo(surfaceWidth, surfaceHeight),
+            Integration::DepthBufferAvailable::FALSE,
+            Integration::StencilBufferAvailable::FALSE,
+            Integration::PartialUpdateAvailable::FALSE),
+  mCore(NULL),
+  mSurfaceWidth(surfaceWidth),
+  mSurfaceHeight(surfaceHeight),
+  mFrame(0u),
+  mDpi{horizontalDpi, verticalDpi},
+  mLastVSyncTime(0u),
+  mPartialUpdateEnabled(enablePartialUpdate)
+{
+  if(initialize)
+  {
+    Initialize();
+  }
+}
+
+const Graphics::GraphicsCreateInfo& TestGraphicsApplication::GetGraphicsCreateInfo(uint32_t width, uint32_t height)
+{
+  static Graphics::GraphicsCreateInfo info{
+    480, 800, Graphics::DepthStencilMode::NONE, Graphics::SwapchainBufferingMode::OPTIMAL, ColorDepth::COLOR_DEPTH_24, 0};
+  info.surfaceWidth  = width;
+  info.surfaceHeight = height;
+  return info;
+}
+
+void TestGraphicsApplication::Initialize()
+{
+  CreateCore();
+  CreateScene();
+  InitializeCore();
+}
+
+void TestGraphicsApplication::CreateCore()
+{
+  Dali::Integration::Log::LogFunction logFunction(&TestGraphicsApplication::LogMessage);
+  Dali::Integration::Log::InstallLogFunction(logFunction);
+
+  Dali::Integration::Trace::LogContextFunction logContextFunction(&TestGraphicsApplication::LogContext);
+  Dali::Integration::Trace::InstallLogContextFunction(logContextFunction);
+
+  // We always need the first update!
+  mStatus.keepUpdating = Integration::KeepUpdating::STAGE_KEEP_RENDERING;
+  mDisplayConnection   = DisplayConnection::New();
+  mGraphics.Initialize(*mDisplayConnection);
+
+  Integration::CorePolicyFlags corePolicyFlags = Integration::CorePolicyFlags::DEPTH_BUFFER_AVAILABLE | Integration::CorePolicyFlags::STENCIL_BUFFER_AVAILABLE;
+  if(mPartialUpdateEnabled)
+  {
+    corePolicyFlags |= Integration::CorePolicyFlags::PARTIAL_UPDATE_AVAILABLE;
+  }
+
+  mCore = Dali::Integration::Core::New(mRenderController,
+                                       mPlatformAbstraction,
+                                       mGraphics.GetController(),
+                                       corePolicyFlags);
+
+  mCore->ContextCreated();
+
+  Dali::Integration::Trace::LogContext(true, "Test");
+}
+
+void TestGraphicsApplication::CreateScene()
+{
+  mScene = Dali::Integration::Scene::New(Size(static_cast<float>(mSurfaceWidth), static_cast<float>(mSurfaceHeight)));
+  mScene.SetDpi(Vector2(static_cast<float>(mDpi.x), static_cast<float>(mDpi.y)));
+
+  Graphics::RenderTargetCreateInfo createInfo{};
+  createInfo.SetSurface({nullptr})
+    .SetExtent({mSurfaceWidth, mSurfaceHeight})
+    .SetPreTransform(0 | Graphics::RenderTargetTransformFlagBits::TRANSFORM_IDENTITY_BIT);
+  //mRenderTarget = mGraphicsController.CreateRenderTarget(createInfo, nullptr);
+  mScene.SetSurfaceRenderTarget(createInfo);
+}
+
+void TestGraphicsApplication::InitializeCore()
+{
+  mCore->SceneCreated();
+  mCore->Initialize();
+}
+
+TestGraphicsApplication::~TestGraphicsApplication()
+{
+  mGraphics.GetController().Shutdown();
+  Dali::Integration::Log::UninstallLogFunction();
+  delete mCore;
+}
+
+void TestGraphicsApplication::LogContext(bool start, const char* tag, const char* message)
+{
+  if(start)
+  {
+    fprintf(stderr, "INFO: Trace Start: %s %s\n", tag, message ? message : "");
+  }
+  else
+  {
+    fprintf(stderr, "INFO: Trace End: %s %s\n", tag, message ? message : "");
+  }
+}
+
+void TestGraphicsApplication::LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message)
+{
+  if(mLoggingEnabled)
+  {
+    switch(level)
+    {
+      case Dali::Integration::Log::DEBUG:
+        fprintf(stderr, "DEBUG: %s", message.c_str());
+        break;
+      case Dali::Integration::Log::INFO:
+        fprintf(stderr, "INFO: %s", message.c_str());
+        break;
+      case Dali::Integration::Log::WARNING:
+        fprintf(stderr, "WARN: %s", message.c_str());
+        break;
+      case Dali::Integration::Log::ERROR:
+        fprintf(stderr, "ERROR: %s", message.c_str());
+        break;
+      default:
+        fprintf(stderr, "DEFAULT: %s", message.c_str());
+        break;
+    }
+  }
+}
+
+Dali::Integration::Core& TestGraphicsApplication::GetCore()
+{
+  return *mCore;
+}
+
+TestPlatformAbstraction& TestGraphicsApplication::GetPlatform()
+{
+  return mPlatformAbstraction;
+}
+
+TestRenderController& TestGraphicsApplication::GetRenderController()
+{
+  return mRenderController;
+}
+
+Graphics::Controller& TestGraphicsApplication::GetGraphicsController()
+{
+  return mGraphics.GetController();
+}
+
+void TestGraphicsApplication::ProcessEvent(const Integration::Event& event)
+{
+  mCore->QueueEvent(event);
+  mCore->ProcessEvents();
+}
+
+void TestGraphicsApplication::SendNotification()
+{
+  mCore->ProcessEvents();
+}
+
+void TestGraphicsApplication::DoUpdate(uint32_t intervalMilliseconds, const char* location)
+{
+  if(GetUpdateStatus() == 0 &&
+     mRenderStatus.NeedsUpdate() == false &&
+     !GetRenderController().WasCalled(TestRenderController::RequestUpdateFunc))
+  {
+    fprintf(stderr, "WARNING - Update not required :%s\n", location == NULL ? "NULL" : location);
+  }
+
+  uint32_t nextVSyncTime  = mLastVSyncTime + intervalMilliseconds;
+  float    elapsedSeconds = static_cast<float>(intervalMilliseconds) * 0.001f;
+
+  mCore->Update(elapsedSeconds, mLastVSyncTime, nextVSyncTime, mStatus, false, false, false);
+
+  GetRenderController().Initialize();
+
+  mLastVSyncTime = nextVSyncTime;
+}
+
+bool TestGraphicsApplication::Render(uint32_t intervalMilliseconds, const char* location)
+{
+  DoUpdate(intervalMilliseconds, location);
+
+  // Reset the status
+  mRenderStatus.SetNeedsUpdate(false);
+  mRenderStatus.SetNeedsPostRender(false);
+
+  mCore->PreRender(mRenderStatus, false /*do not force clear*/);
+  mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/);
+  mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/);
+  mCore->PostRender();
+
+  mFrame++;
+
+  return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
+}
+
+bool TestGraphicsApplication::PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects)
+{
+  DoUpdate(intervalMilliseconds, location);
+
+  mCore->PreRender(mRenderStatus, false /*do not force clear*/);
+  mCore->PreRender(mScene, damagedRects);
+
+  return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
+}
+
+bool TestGraphicsApplication::RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect)
+{
+  mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/, clippingRect);
+  mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/, clippingRect);
+  mCore->PostRender();
+
+  mFrame++;
+
+  return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
+}
+
+uint32_t TestGraphicsApplication::GetUpdateStatus()
+{
+  return mStatus.KeepUpdating();
+}
+
+bool TestGraphicsApplication::UpdateOnly(uint32_t intervalMilliseconds)
+{
+  DoUpdate(intervalMilliseconds);
+  return mStatus.KeepUpdating();
+}
+
+bool TestGraphicsApplication::GetRenderNeedsUpdate()
+{
+  return mRenderStatus.NeedsUpdate();
+}
+
+bool TestGraphicsApplication::GetRenderNeedsPostRender()
+{
+  return mRenderStatus.NeedsPostRender();
+}
+
+bool TestGraphicsApplication::RenderOnly()
+{
+  // Update Time values
+  mCore->PreRender(mRenderStatus, false /*do not force clear*/);
+  mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/);
+  mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/);
+  mCore->PostRender();
+
+  mFrame++;
+
+  return mRenderStatus.NeedsUpdate();
+}
+
+void TestGraphicsApplication::ResetContext()
+{
+  mCore->ContextDestroyed();
+  // re-create vulkan graphics?
+  mCore->ContextCreated();
+}
+
+uint32_t TestGraphicsApplication::Wait(uint32_t durationToWait)
+{
+  int time = 0;
+
+  for(uint32_t i = 0; i <= (durationToWait / RENDER_FRAME_INTERVAL); i++)
+  {
+    SendNotification();
+    Render(RENDER_FRAME_INTERVAL);
+    time += RENDER_FRAME_INTERVAL;
+  }
+  return time;
+}
+
+} // namespace Dali
diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-vk-application.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-vk-application.h
new file mode 100644 (file)
index 0000000..e3d3095
--- /dev/null
@@ -0,0 +1,131 @@
+#pragma once
+
+/*
+ * Copyright (c) 2024 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/resource-policies.h>
+#include <dali/integration-api/scene.h>
+#include <dali/integration-api/trace.h>
+
+#include <dali/internal/graphics/vulkan/vulkan-graphics-impl.h>
+#include <dali/public-api/common/dali-common.h>
+
+#include <test-platform-abstraction.h>
+#include <test-render-controller.h>
+#include <test-vk-abstraction.h>
+
+namespace Dali
+{
+namespace Internal::Adaptor
+{
+class ConfigurationManager;
+}
+
+class DALI_CORE_API TestGraphicsApplication : public ConnectionTracker
+{
+public:
+  // Default values derived from H2 device.
+  static const uint32_t DEFAULT_SURFACE_WIDTH  = 480;
+  static const uint32_t DEFAULT_SURFACE_HEIGHT = 800;
+
+  static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
+  static constexpr uint32_t DEFAULT_VERTICAL_DPI   = 217;
+
+  static const uint32_t DEFAULT_RENDER_INTERVAL = 1;
+
+  static const uint32_t RENDER_FRAME_INTERVAL = 16;
+
+  TestGraphicsApplication(uint32_t surfaceWidth        = DEFAULT_SURFACE_WIDTH,
+                          uint32_t surfaceHeight       = DEFAULT_SURFACE_HEIGHT,
+                          uint32_t horizontalDpi       = DEFAULT_HORIZONTAL_DPI,
+                          uint32_t verticalDpi         = DEFAULT_VERTICAL_DPI,
+                          bool     initialize          = true,
+                          bool     enablePartialUpdate = false);
+
+  void Initialize();
+  void CreateCore();
+  void CreateScene();
+  void InitializeCore();
+  ~TestGraphicsApplication() override;
+  static void              LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
+  static void              LogContext(bool start, const char* tag, const char* message);
+  Dali::Integration::Core& GetCore();
+  TestPlatformAbstraction& GetPlatform();
+  TestRenderController&    GetRenderController();
+  Graphics::Controller&    GetGraphicsController();
+
+  TestVkAbstraction& GetVkAbstraction();
+
+  void     ProcessEvent(const Integration::Event& event);
+  void     SendNotification();
+  bool     Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL);
+  bool     PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
+  bool     RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
+  uint32_t GetUpdateStatus();
+  bool     UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
+  bool     RenderOnly();
+  void     ResetContext();
+  bool     GetRenderNeedsUpdate();
+  bool     GetRenderNeedsPostRender();
+  uint32_t Wait(uint32_t durationToWait);
+
+  static const Graphics::GraphicsCreateInfo& GetGraphicsCreateInfo(uint32_t w, uint32_t h);
+
+  static void EnableLogging(bool enabled)
+  {
+    mLoggingEnabled = enabled;
+  }
+
+  Integration::Scene GetScene() const
+  {
+    return mScene;
+  }
+
+private:
+  void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL);
+
+protected:
+  TestPlatformAbstraction                     mPlatformAbstraction;
+  TestRenderController                        mRenderController;
+  TestVkAbstraction                           mVkAbstraction;
+  Graphics::VulkanGraphics                    mGraphics; // Use real vulkan graphics
+  Graphics::UniquePtr<Graphics::RenderTarget> mRenderTarget{nullptr};
+  Dali::DisplayConnection*                    mDisplayConnection{nullptr};
+
+  Integration::UpdateStatus mStatus;
+  Integration::RenderStatus mRenderStatus;
+
+  Integration::Core*       mCore;
+  Dali::Integration::Scene mScene;
+
+  uint32_t mSurfaceWidth;
+  uint32_t mSurfaceHeight;
+  uint32_t mFrame;
+
+  struct
+  {
+    uint32_t x;
+    uint32_t y;
+  } mDpi;
+  uint32_t    mLastVSyncTime;
+  bool        mPartialUpdateEnabled;
+  static bool mLoggingEnabled;
+};
+
+} // namespace Dali
diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-vk-abstraction.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-vk-abstraction.cpp
new file mode 100644 (file)
index 0000000..ba16d7b
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2024 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-vk-abstraction.h"
diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-vk-abstraction.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-vk-abstraction.h
new file mode 100644 (file)
index 0000000..ee95839
--- /dev/null
@@ -0,0 +1,37 @@
+#pragma once
+
+/*
+ * Copyright (c) 2024 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 <cstdint>
+
+#ifndef VULKAN_HPP_NO_EXCEPTIONS
+#define VULKAN_HPP_NO_EXCEPTIONS
+#endif
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+#pragma GCC diagnostic ignored "-Wswitch-enum"
+#include <vulkan/vulkan.hpp>
+#pragma GCC diagnostic pop
+
+class TestVkAbstraction
+{
+public:
+  TestVkAbstraction()
+  {
+  }
+};
index a88b53d..b075af9 100644 (file)
@@ -26,7 +26,7 @@ LIST(APPEND TC_SOURCES
   ../dali-adaptor/dali-test-suite-utils/mesh-builder.cpp
   ../dali-adaptor/dali-test-suite-utils/test-harness.cpp
   ../dali-adaptor/dali-test-suite-utils/test-actor-utils.cpp
-  ../dali-adaptor/dali-test-suite-utils/test-graphics-application.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-graphics-egl-application.cpp
   ../dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp
 
   ../dali-adaptor/dali-test-suite-utils/test-graphics-sync-impl.cpp
index 6d363c4..d3efa7e 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
 #include <test-actor-utils.h>
-#include <test-graphics-application.h>
+#include <test-graphics-egl-application.h>
 #include <test-graphics-framebuffer.h>
 
 using namespace Dali;
index 2d6be12..da2343c 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
 #include <test-actor-utils.h>
-#include <test-graphics-application.h>
+#include <test-graphics-egl-application.h>
 #include <test-graphics-framebuffer.h>
 
 using namespace Dali;
index e969f7c..9efc429 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
 #include <test-actor-utils.h>
-#include <test-graphics-application.h>
+#include <test-graphics-egl-application.h>
 #include <test-graphics-framebuffer.h>
 
 using namespace Dali;
index efe9423..073ffdc 100644 (file)
@@ -2,7 +2,8 @@
 
 #include <dali/graphics-api/graphics-controller.h>
 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
-#include <test-graphics-application.h>
+#include <test-graphics-egl-application.h>
+
 //#include <dali/graphics-api/graphics-api-buffer.h>
 
 int UtcDaliGraphicsCreateGeometry(void)
index 227701b..e62a84e 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
 #include <test-actor-utils.h>
-#include <test-graphics-application.h>
+#include <test-graphics-egl-application.h>
 #include <test-native-image.h>
 
 using namespace Dali;
index 5719b61..772fc4c 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
 #include <test-actor-utils.h>
-#include <test-graphics-application.h>
+#include <test-graphics-egl-application.h>
 #include <test-graphics-sampler.h>
 
 using namespace Dali;
index 873b1c3..8d8581f 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
 #include <test-actor-utils.h>
-#include <test-graphics-application.h>
+#include <test-graphics-egl-application.h>
 #include <test-graphics-sampler.h>
 
 using namespace Dali;
index 788bd24..b69239a 100644 (file)
@@ -19,7 +19,7 @@
 #include <dali/dali.h>
 #include <dali/integration-api/testing.h>
 #include <dali/internal/graphics/gles-impl/gles-graphics-shader.h>
-#include <test-graphics-application.h>
+#include <test-graphics-egl-application.h>
 
 int UtcDaliGlesStripLegacyCodeIfNeededTest1(void)
 {
@@ -160,4 +160,4 @@ int UtcDaliGlesLegacyCodeTest(void)
   }
 
   END_TEST;
-}
\ No newline at end of file
+}
index d003ae5..16a3ff5 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
 #include <test-actor-utils.h>
-#include <test-graphics-application.h>
+#include <test-graphics-egl-application.h>
 #include <test-graphics-framebuffer.h>
 
 using namespace Dali;
diff --git a/automated-tests/src/dali-vk-graphics/CMakeLists.txt b/automated-tests/src/dali-vk-graphics/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3d36ab0
--- /dev/null
@@ -0,0 +1,72 @@
+SET(PKG_NAME "dali-vk-graphics")
+
+SET(EXEC_NAME "tct-${PKG_NAME}-core")
+SET(RPM_NAME "core-${PKG_NAME}-tests")
+MESSAGE(STATUS "ENABLE_VULKAN: ${ENABLE_VULKAN}")
+
+SET(CAPI_LIB "dali-vk-graphics")
+
+SET(TC_SOURCES
+    utc-Dali-VkGraphicsBuffer.cpp
+)
+
+SET(TC_SOURCE_LIST ${TC_SOURCES} CACHE STRING "List of test sources")
+
+LIST(APPEND TC_SOURCES
+  ../dali-adaptor/dali-test-suite-utils/dali-test-suite-utils.cpp
+  ../dali-adaptor/dali-test-suite-utils/mesh-builder.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-harness.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-actor-utils.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-graphics-vk-application.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-vk-abstraction.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-graphics-sync-impl.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-graphics-sync-object.cpp
+
+  ../dali-adaptor/dali-test-suite-utils/test-native-image.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-render-controller.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-render-surface.cpp
+  ../dali-adaptor/dali-test-suite-utils/test-trace-call-stack.cpp
+  ../dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
+  tct-dali-vk-graphics-core.cpp
+)
+
+PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
+    dali2-core
+    dali2-adaptor
+    vulkan
+)
+
+ADD_COMPILE_OPTIONS(-Wno-switch -Wno-switch-enum -Wno-error=switch -Wno-error=switch-enum)
+ADD_COMPILE_OPTIONS(-Wno-init-list-lifetime)
+INCLUDE(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG(-Wno-class-memaccess HAVE_NO_CLASS_MEMACCESS)
+IF (HAVE_NO_CLASS_MEMACCESS)
+  ADD_COMPILE_OPTIONS( -Wno-class-memaccess )
+ENDIF()
+
+ADD_COMPILE_OPTIONS( -O0 -ggdb --coverage -Wall -Werror )
+ADD_COMPILE_OPTIONS( ${${CAPI_LIB}_CFLAGS_OTHER} )
+
+ADD_DEFINITIONS(-DTEST_RESOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/../../resources\" )
+
+FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
+    SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
+ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(
+  ../../../
+  ../../../dali/integration-api/adaptor-framework
+  ${${CAPI_LIB}_INCLUDE_DIRS}
+  ../dali-adaptor/dali-test-suite-utils
+)
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+TARGET_LINK_LIBRARIES(${EXEC_NAME}
+  ${${CAPI_LIB}_LIBRARIES}
+  --coverage
+)
+
+INSTALL(PROGRAMS ${EXEC_NAME}
+    DESTINATION ${BIN_DIR}/${EXEC_NAME}
+)
diff --git a/automated-tests/src/dali-vk-graphics/tct-dali-vk-graphics-core.cpp b/automated-tests/src/dali-vk-graphics/tct-dali-vk-graphics-core.cpp
new file mode 100644 (file)
index 0000000..efc867d
--- /dev/null
@@ -0,0 +1,8 @@
+#include <test-harness.h>
+
+#include "tct-dali-vk-graphics-core.h"
+
+int main(int argc, char* const argv[])
+{
+  return TestHarness::RunTests(argc, argv, tc_array);
+}
diff --git a/automated-tests/src/dali-vk-graphics/utc-Dali-VkGraphicsBuffer.cpp b/automated-tests/src/dali-vk-graphics/utc-Dali-VkGraphicsBuffer.cpp
new file mode 100644 (file)
index 0000000..d244b9c
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2024 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-test-suite-utils.h>
+#include <dali/dali.h>
+
+#include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
+#include <test-actor-utils.h>
+#include <test-graphics-framebuffer.h>
+#include <test-graphics-vk-application.h>
+
+using namespace Dali;
+
+namespace
+{
+} // namespace
+
+int UtcDaliBufferReuseTest(void)
+{
+  TestGraphicsApplication app;
+  tet_infoline("UtcDaliBufferReuseTest: Tests whether GLES buffer can be reused (orphaning content)");
+
+  auto& controller = app.GetGraphicsController();
+
+  Graphics::BufferCreateInfo info;
+  info.size            = 1024;
+  info.usage           = 0u | Graphics::BufferUsage::VERTEX_BUFFER;
+  info.propertiesFlags = 0u;
+
+  auto buffer = controller.CreateBuffer(info, nullptr);
+  controller.WaitIdle();
+
+  DALI_TEST_NOT_EQUALS((void*)buffer.get(), (void*)nullptr, 0, TEST_LOCATION);
+
+  // New buffer with different spec, should create new object
+  Graphics::BufferCreateInfo info2;
+  info.size            = 2024;
+  info.usage           = 0u | Graphics::BufferUsage::VERTEX_BUFFER;
+  info.propertiesFlags = 0u;
+
+  auto buffer2 = controller.CreateBuffer(info2, std::move(buffer));
+  controller.WaitIdle();
+
+  DALI_TEST_NOT_EQUALS(buffer.get(), buffer2.get(), 0, TEST_LOCATION);
+
+  auto ptr = buffer2.get(); // store pointer for testing, the uptr will be emptied
+  // Create new buffer using the same spec
+  auto buffer3 = controller.CreateBuffer(info2, std::move(buffer2));
+  controller.WaitIdle();
+
+  DALI_TEST_EQUALS(ptr, buffer3.get(), TEST_LOCATION);
+
+  END_TEST;
+}