Merge changes I784ba99d,Ieaaeab17 into devel/master
authorEunki Hong <eunkiki.hong@samsung.com>
Wed, 14 Feb 2024 06:37:32 +0000 (06:37 +0000)
committerGerrit Code Review <gerrit@review>
Wed, 14 Feb 2024 06:37:32 +0000 (06:37 +0000)
* changes:
  Add precompiled shader names
  Add program name and print it

dali/integration-api/adaptor-framework/shader-precompiler.h
dali/internal/adaptor/common/combined-update-render-controller.cpp
dali/internal/adaptor/common/combined-update-render-controller.h
dali/internal/graphics/gles-impl/gles-graphics-program.cpp

index 6b14439..28d445d 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTEGRATION_SHADER_PRECOMPILER_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * 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.
  */
 
 // INTERNAL HEADER
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/common/vector-wrapper.h>
 #include <dali/devel-api/threading/conditional-wait.h>
 #include <dali/devel-api/threading/mutex.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/base-handle.h>
 
 // EXTERNAL HEDAER
-#include <string_view>
-#include <memory>
-#include <mutex>
 #include <dali/graphics-api/graphics-program.h>
 #include <dali/graphics-api/graphics-types.h>
+#include <memory>
+#include <mutex>
+#include <string_view>
 
 namespace Dali
 {
 struct RawShaderData
 {
-  int shaderCount;
+  int                           shaderCount;
   std::vector<std::string_view> vertexPrefix;
   std::vector<std::string_view> fragmentPrefix;
-  std::string_view vertexShader;
-  std::string_view fragmentShader;
+  std::vector<std::string_view> shaderName;
+  std::string_view              vertexShader;
+  std::string_view              fragmentShader;
 };
 
 /**
@@ -125,14 +126,14 @@ private:
 
 private:
   std::vector<Graphics::UniquePtr<Dali::Graphics::Program>> mProgram;
-  static std::unique_ptr<ShaderPreCompiler> mInstance;
-  static std::once_flag mOnceFlag;
-  std::vector<RawShaderData> mRawShaderList;
-  ConditionalWait mConditionalWait;
-  Dali::Mutex mMutex;
-  bool mPrecompiled;
-  bool mEnabled;
-  bool mNeedsSleep{true};
+  static std::unique_ptr<ShaderPreCompiler>                 mInstance;
+  static std::once_flag                                     mOnceFlag;
+  std::vector<RawShaderData>                                mRawShaderList;
+  ConditionalWait                                           mConditionalWait;
+  Dali::Mutex                                               mMutex;
+  bool                                                      mPrecompiled;
+  bool                                                      mEnabled;
+  bool                                                      mNeedsSleep{true};
 };
 
 } // namespace Dali
index e87d65b..3697bc4 100644 (file)
@@ -612,7 +612,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
         {
           auto vertexShader   = graphics.GetController().GetGraphicsConfig().GetVertexShaderPrefix() + std::string(precompiledShader->vertexPrefix[i].data()) + std::string(precompiledShader->vertexShader.data());
           auto fragmentShader = graphics.GetController().GetGraphicsConfig().GetFragmentShaderPrefix() + std::string(precompiledShader->fragmentPrefix[i].data()) + std::string(precompiledShader->fragmentShader.data());
-          PreCompileShader(std::move(vertexShader), std::move(fragmentShader));
+          PreCompileShader(std::move(vertexShader), std::move(fragmentShader), static_cast<uint32_t>(i) < precompiledShader->shaderName.size() ? std::string(precompiledShader->shaderName[i]) : "");
         }
         DALI_LOG_RELEASE_INFO("ShaderPreCompiler[ENABLE], shader count :%d \n", numberOfPrecompiledShader);
       }
@@ -1049,7 +1049,7 @@ void CombinedUpdateRenderController::SurfaceResized(uint32_t resizedCount)
   }
 }
 
-void CombinedUpdateRenderController::PreCompileShader(std::string vertexShader, std::string fragmentShader)
+void CombinedUpdateRenderController::PreCompileShader(std::string vertexShader, std::string fragmentShader, std::string shaderName)
 {
   GraphicsInterface& graphics = mAdaptorInterfaces.GetGraphicsInterface();
 
@@ -1079,6 +1079,7 @@ void CombinedUpdateRenderController::PreCompileShader(std::string vertexShader,
 
   auto createInfo = Graphics::ProgramCreateInfo();
   createInfo.SetShaderState(shaderStates);
+  createInfo.SetName(shaderName);
 
   auto graphicsProgram = graphics.GetController().CreateProgram(createInfo, nullptr);
   ShaderPreCompiler::Get().AddPreCompiledProgram(std::move(graphicsProgram));
index 35505fe..625e9e4 100644 (file)
@@ -279,8 +279,9 @@ private:
    *
    * @param[in] vertexShader vertexShader need to precompile
    * @param[in] fragmentShader fragmentShader need to precompile
+   * @param[in] shaderName the name of precompile shader (option)
   */
-  void PreCompileShader(std::string vertexShader, std::string fragmentShader);
+  void PreCompileShader(std::string vertexShader, std::string fragmentShader, std::string shaderName = "");
 
   /**
    * Cancel the precompile
index 2141e32..06b742f 100644 (file)
@@ -83,6 +83,10 @@ struct ProgramImpl::Impl
     {
       createInfo.shaderState = new std::vector<ShaderState>(*info.shaderState);
     }
+
+    // Create new reference of std::string_view.
+    name            = std::string(info.name);
+    createInfo.name = name;
   }
 
   ~Impl()
@@ -92,6 +96,7 @@ struct ProgramImpl::Impl
 
   EglGraphicsController& controller;
   ProgramCreateInfo      createInfo;
+  std::string            name;
   uint32_t               glProgram{};
   uint32_t               refCount{0u};
 
@@ -142,6 +147,8 @@ bool ProgramImpl::Create()
 
   auto program = gl->CreateProgram();
 
+  DALI_LOG_INFO(gGraphicsProgramLogFilter, Debug::Verbose, "Program[%s] create program id : %u\n", mImpl->name.c_str(), program);
+
   const auto& info = mImpl->createInfo;
   for(const auto& state : *info.shaderState)
   {
@@ -150,9 +157,13 @@ bool ProgramImpl::Create()
     // Compile shader first (ignored when compiled)
     if(shader->GetImplementation()->Compile())
     {
-      gl->AttachShader(program, shader->GetImplementation()->GetGLShader());
+      auto shaderId = shader->GetImplementation()->GetGLShader();
+      DALI_LOG_INFO(gGraphicsProgramLogFilter, Debug::Verbose, "Program[%s] attach shader : %u\n", mImpl->name.c_str(), shaderId);
+      gl->AttachShader(program, shaderId);
     }
   }
+
+  DALI_LOG_INFO(gGraphicsProgramLogFilter, Debug::Verbose, "Program[%s] call glLinkProgram\n", mImpl->name.c_str());
   gl->LinkProgram(program);
 
   GLint status{0};
@@ -164,7 +175,7 @@ bool ProgramImpl::Create()
     gl->GetProgramInfoLog(program, 4096, &size, output);
 
     // log on error
-    DALI_LOG_ERROR("glLinkProgam failed:\n%s\n", output);
+    DALI_LOG_ERROR("glLinkProgam[%s] failed:\n%s\n", mImpl->name.c_str(), output);
     gl->DeleteProgram(program);
     return false;
   }