[Tizen] Apply Precompile shader
authorEverLEEst(SangHyeon Lee) <sh10233.lee@samsung.com>
Wed, 22 Nov 2023 05:34:36 +0000 (14:34 +0900)
committerEverLEEst(SangHyeon Lee) <sh10233.lee@samsung.com>
Wed, 22 Nov 2023 05:34:36 +0000 (14:34 +0900)
This reverts commit 1798ef1335e81fb050ce5a6221683d738d7c70fe.

dali/internal/adaptor/common/combined-update-render-controller.cpp

index 3a8ad2c..969ee5e 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/integration-api/platform-abstraction.h>
+#include <dali/integration-api/shader-precompiler.h>
 #include <errno.h>
 #include <unistd.h>
 #include "dali/public-api/common/dali-common.h"
@@ -44,6 +45,7 @@ namespace Adaptor
 {
 namespace
 {
+
 const unsigned int CREATED_THREAD_COUNT = 1u;
 
 const int CONTINUOUS = -1;
@@ -537,6 +539,21 @@ void CombinedUpdateRenderController::UpdateRenderThread()
 
   NotifyThreadInitialised();
 
+  // Initialize and create graphics resource for the shared context.
+  WindowContainer windows;
+  mAdaptorInterfaces.GetWindowContainerInterface(windows);
+
+  for(auto&& window : windows)
+  {
+    Dali::Integration::Scene      scene         = window->GetScene();
+    Dali::RenderSurfaceInterface* windowSurface = window->GetSurface();
+
+    if(scene && windowSurface)
+    {
+      windowSurface->InitializeGraphics();
+    }
+  }
+
   // Update time
   uint64_t lastFrameTime;
   TimeService::GetNanoseconds(lastFrameTime);
@@ -557,6 +574,24 @@ void CombinedUpdateRenderController::UpdateRenderThread()
 
   TRACE_UPDATE_RENDER_END("DALI_RENDER_THREAD_INIT");
 
+  if(Integration::ShaderPrecompiler::Get().IsEnable())
+  {
+    RawShaderData precompiledShader;
+    Integration::ShaderPrecompiler::Get().GetPrecompileShaderList(precompiledShader);
+    auto numberOfPrecomipledShader = precompiledShader.shaderCount;
+    for(int i= 0; i<numberOfPrecomipledShader; ++i)
+    {
+      auto vertexShader   = std::string(graphics.GetController().GetGlAbstraction().GetVertexShaderPrefix() + precompiledShader.vertexPrefix[i].data() + precompiledShader.vertexShader.data());
+      auto fragmentShader = std::string(graphics.GetController().GetGlAbstraction().GetFragmentShaderPrefix() + precompiledShader.fragmentPrefix[i].data() + precompiledShader.fragmentShader.data());
+      mCore.PreCompileShader(vertexShader.data(), fragmentShader.data());
+    }
+    DALI_LOG_RELEASE_INFO("ShaderPrecompiler[ENABLE], shader :%d \n",numberOfPrecomipledShader);
+  }
+  else
+  {
+    DALI_LOG_RELEASE_INFO("ShaderPrecompiler[DISABLE] \n");
+  }
+
   while(UpdateRenderReady(useElapsedTime, updateRequired, timeToSleepUntil))
   {
     LOG_UPDATE_RENDER_TRACE;
@@ -722,7 +757,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     if(!uploadOnly || surfaceResized)
     {
       // Go through each window
-      WindowContainer windows;
+      windows.clear();
       mAdaptorInterfaces.GetWindowContainerInterface(windows);
 
       for(auto&& window : windows)
@@ -859,7 +894,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
   // Inform core of context destruction
   mCore.ContextDestroyed();
 
-  WindowContainer windows;
+  windows.clear();
   mAdaptorInterfaces.GetWindowContainerInterface(windows);
 
   // Destroy surfaces