[Tizen] Apply Precompile shader
authordongsug.song <dongsug.song@samsung.com>
Mon, 6 Nov 2023 10:07:51 +0000 (19:07 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Mon, 6 Nov 2023 10:07:57 +0000 (19:07 +0900)
This reverts commit 372696346c5bf17dec65247d0abeb394be4ef3ba.

Change-Id: I58f4c3d0322b15424f4e91c435ab958b77831f2c

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

index 648ef81..e164e85 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;
@@ -535,6 +537,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);
@@ -553,6 +570,24 @@ void CombinedUpdateRenderController::UpdateRenderThread()
   const bool         renderToFboEnabled  = 0u != renderToFboInterval;
   unsigned int       frameCount          = 0u;
 
+  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;
@@ -717,7 +752,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     if(!uploadOnly || surfaceResized)
     {
       // Go through each window
-      WindowContainer windows;
+      windows.clear();
       mAdaptorInterfaces.GetWindowContainerInterface(windows);
 
       for(auto&& window : windows)
@@ -853,7 +888,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
   // Inform core of context destruction
   mCore.ContextDestroyed();
 
-  WindowContainer windows;
+  windows.clear();
   mAdaptorInterfaces.GetWindowContainerInterface(windows);
 
   // Destroy surfaces