Add precompiled shader names 06/305606/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 5 Feb 2024 08:54:05 +0000 (17:54 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 7 Feb 2024 11:17:35 +0000 (20:17 +0900)
Let we allow to use precompiled shader also use shader name

Change-Id: I701627ffc53b8450e286c31b8ac8e348e2a81cb0
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/visuals/image-visual-shader-factory.cpp
dali-toolkit/internal/visuals/text-visual-shader-factory.cpp
dali-toolkit/internal/visuals/visual-factory-impl.cpp

index 7b27502..ec4ab2c 100644 (file)
@@ -58,6 +58,14 @@ constexpr std::string_view FragmentPredefines[SHADER_TYPE_COUNT]{
   "#define IS_REQUIRED_UNIFIED_YUV_AND_RGB\n",                                     // VisualFactoryCache::IMAGE_SHADER_YUV_AND_RGB,
   "#define IS_REQUIRED_UNIFIED_YUV_AND_RGB\n#define IS_REQUIRED_ROUNDED_CORNER\n", // VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_YUV_AND_RGB,
 };
+constexpr VisualFactoryCache::ShaderType ShaderTypePredefines[SHADER_TYPE_COUNT]{
+  VisualFactoryCache::ShaderType::IMAGE_SHADER,
+  VisualFactoryCache::ShaderType::IMAGE_SHADER_ROUNDED_CORNER,
+  VisualFactoryCache::ShaderType::IMAGE_SHADER_YUV_TO_RGB,
+  VisualFactoryCache::ShaderType::IMAGE_SHADER_ROUNDED_CORNER_YUV_TO_RGB,
+  VisualFactoryCache::ShaderType::IMAGE_SHADER_YUV_AND_RGB,
+  VisualFactoryCache::ShaderType::IMAGE_SHADER_ROUNDED_CORNER_YUV_AND_RGB,
+};
 } // unnamed namespace
 
 ImageVisualShaderFactory::ImageVisualShaderFactory()
@@ -167,17 +175,20 @@ void ImageVisualShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
 {
   std::vector<std::string_view> vertexPrefix;
   std::vector<std::string_view> fragmentPrefix;
+  std::vector<std::string_view> shaderName;
   shaders.shaderCount = 0;
   int shaderCount     = 0;
   for(uint32_t i = 0; i < SHADER_TYPE_COUNT; ++i)
   {
     vertexPrefix.push_back(VertexPredefines[i]);
     fragmentPrefix.push_back(FragmentPredefines[i]);
+    shaderName.push_back(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
     shaderCount++;
   }
 
   shaders.vertexPrefix   = vertexPrefix;
   shaders.fragmentPrefix = fragmentPrefix;
+  shaders.shaderName     = shaderName;
   shaders.vertexShader   = SHADER_IMAGE_VISUAL_SHADER_VERT;
   shaders.fragmentShader = SHADER_IMAGE_VISUAL_SHADER_FRAG;
   shaders.shaderCount    = shaderCount;
index 8e10a64..365de2f 100644 (file)
@@ -56,13 +56,16 @@ const VisualFactoryCache::ShaderType SHADER_TYPE_TABLE[] =
     VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE_AND_OVERLAY,
 };
 
-static constexpr auto  SHADER_TYPE_COUNT = 1u;
-const std::string_view VertexPredefines[SHADER_TYPE_COUNT]{
+static constexpr auto      SHADER_TYPE_COUNT = 1u;
+constexpr std::string_view VertexPredefines[SHADER_TYPE_COUNT]{
   "", // VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT
 };
-const std::string_view FragmentPredefines[SHADER_TYPE_COUNT]{
+constexpr std::string_view FragmentPredefines[SHADER_TYPE_COUNT]{
   "", // VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT
 };
+constexpr VisualFactoryCache::ShaderType ShaderTypePredefines[SHADER_TYPE_COUNT]{
+  VisualFactoryCache::ShaderType::TEXT_SHADER_SINGLE_COLOR_TEXT,
+};
 
 } // unnamed namespace
 
@@ -165,16 +168,19 @@ void TextVisualShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
 {
   std::vector<std::string_view> vertexPrefix;
   std::vector<std::string_view> fragmentPrefix;
+  std::vector<std::string_view> shaderName;
   int                           shaderCount = 0;
   for(uint32_t i = 0; i < SHADER_TYPE_COUNT; ++i)
   {
     vertexPrefix.push_back(VertexPredefines[i]);
     fragmentPrefix.push_back(FragmentPredefines[i]);
+    shaderName.push_back(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
     shaderCount++;
   }
 
   shaders.vertexPrefix   = vertexPrefix;
   shaders.fragmentPrefix = fragmentPrefix;
+  shaders.shaderName     = shaderName;
   shaders.vertexShader   = SHADER_TEXT_VISUAL_SHADER_VERT;
   shaders.fragmentShader = SHADER_TEXT_VISUAL_SHADER_FRAG;
   shaders.shaderCount    = shaderCount;
index 9bd6d25..91584eb 100644 (file)
@@ -76,15 +76,20 @@ DALI_TYPE_REGISTRATION_BEGIN_CREATE(Toolkit::VisualFactory, Dali::BaseHandle, Cr
 DALI_TYPE_REGISTRATION_END()
 const char* const BROKEN_IMAGE_FILE_NAME = "broken.png"; ///< The file name of the broken image.
 
-static constexpr auto  SHADER_TYPE_COUNT = 2u;
-const std::string_view VertexPredefines[SHADER_TYPE_COUNT]{
+static constexpr auto SHADER_TYPE_COUNT = 2u;
+
+constexpr std::string_view VertexPredefines[SHADER_TYPE_COUNT]{
   "",                                     //VisualFactoryCache::COLOR_SHADER
   "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER
 };
-const std::string_view FragmentPredefines[SHADER_TYPE_COUNT]{
+constexpr std::string_view FragmentPredefines[SHADER_TYPE_COUNT]{
   "",                                     //VisualFactoryCache::COLOR_SHADER
   "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER
 };
+constexpr VisualFactoryCache::ShaderType ShaderTypePredefines[SHADER_TYPE_COUNT]{
+  VisualFactoryCache::ShaderType::COLOR_SHADER,
+  VisualFactoryCache::ShaderType::COLOR_SHADER_ROUNDED_CORNER,
+};
 
 } // namespace
 
@@ -464,17 +469,20 @@ void VisualFactory::GetPreCompiledShader(RawShaderData& shaders)
 {
   std::vector<std::string_view> vertexPrefix;
   std::vector<std::string_view> fragmentPrefix;
+  std::vector<std::string_view> shaderName;
   int                           shaderCount = 0;
   shaders.shaderCount                       = 0;
   for(uint32_t i = 0u; i < SHADER_TYPE_COUNT; ++i)
   {
     vertexPrefix.push_back(VertexPredefines[i]);
     fragmentPrefix.push_back(FragmentPredefines[i]);
+    shaderName.push_back(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
     shaderCount++;
   }
 
   shaders.vertexPrefix   = vertexPrefix;
   shaders.fragmentPrefix = fragmentPrefix;
+  shaders.shaderName     = shaderName;
   shaders.vertexShader   = SHADER_COLOR_VISUAL_SHADER_VERT;
   shaders.fragmentShader = SHADER_COLOR_VISUAL_SHADER_FRAG;
   shaders.shaderCount    = shaderCount;