From 6dc173a1cd8e7345a8079ad341e4a4a6a91d7540 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Thu, 30 Nov 2023 11:43:32 +0900 Subject: [PATCH] [Tizen] Revert "[Tizen] Change precompile shader list for performance" This reverts commit d1ef77038f504e37ffd5d21dd06a867101aea3c3. Change-Id: I38ea3206a7763a3b6e67453d7def948f0d6015d2 --- .../visuals/image-visual-shader-factory.cpp | 48 ++++++++++++++------ .../visuals/text-visual-shader-factory.cpp | 29 +----------- .../internal/visuals/text-visual-shader-factory.h | 8 +--- .../internal/visuals/visual-factory-impl.cpp | 53 ++-------------------- .../internal/visuals/visual-factory-impl.h | 6 --- 5 files changed, 39 insertions(+), 105 deletions(-) diff --git a/dali-toolkit/internal/visuals/image-visual-shader-factory.cpp b/dali-toolkit/internal/visuals/image-visual-shader-factory.cpp index 2bda754..9af065d 100644 --- a/dali-toolkit/internal/visuals/image-visual-shader-factory.cpp +++ b/dali-toolkit/internal/visuals/image-visual-shader-factory.cpp @@ -39,23 +39,43 @@ const int NATIVE_SHADER_TYPE_OFFSET = VisualFactoryCache::ShaderType::NATIVE_IMA } // unnamed namespace -static constexpr auto SHADER_TYPE_COUNT = 6u; +static constexpr auto SHADER_TYPE_COUNT = 16u; const std::string_view VertexPredefines[SHADER_TYPE_COUNT]{ - "", // VisualFactoryCache::IMAGE_SHADER, - "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER, - "", //VisualFactoryCache::IMAGE_SHADER_YUV_TO_RGB, - "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_YUV_TO_RGB, - "", //VisualFactoryCache::IMAGE_SHADER_YUV_AND_RGB, - "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_YUV_AND_RGB, + "", // VisualFactoryCache::IMAGE_SHADER, + "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER, + "#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_BORDERLINE, + "#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE, + "#define IS_REQUIRED_ALPHA_MASKING\n", // VisualFactoryCache::IMAGE_SHADER_MASKING, + "#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_ALPHA_MASKING\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_MASKING, + "#define IS_REQUIRED_BORDERLINE\n#define IS_REQUIRED_ALPHA_MASKING\n", //VisualFactoryCache::IMAGE_SHADER_BORDERLINE_MASKING, + "#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_BORDERLINE\n#define IS_REQUIRED_ALPHA_MASKING\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE_MASKING, + "", //VisualFactoryCache::IMAGE_SHADER_YUV_TO_RGB, + "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_YUV_TO_RGB, + "#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_BORDERLINE_YUV_TO_RGB, + "#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE_YUV_TO_RGB}; + "", //VisualFactoryCache::IMAGE_SHADER_YUV_AND_RGB, + "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_YUV_AND_RGB, + "#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_BORDERLINE_YUV_AND_RGB, + "#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_BORDERLINE\n" //VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE_YUV_AND_RGB}; }; const std::string_view FragmentPredefines[SHADER_TYPE_COUNT]{ - "", // VisualFactoryCache::IMAGE_SHADER, - "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER, - "#define IS_REQUIRED_YUV_TO_RGB\n", //VisualFactoryCache::IMAGE_SHADER_YUV_TO_RGB, - "#define IS_REQUIRED_YUV_TO_RGB\n#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_YUV_TO_RGB, - "#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, + "", // VisualFactoryCache::IMAGE_SHADER, + "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER, + "#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_BORDERLINE, + "#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE, + "#define IS_REQUIRED_ALPHA_MASKING\n", // VisualFactoryCache::IMAGE_SHADER_MASKING, + "#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_ALPHA_MASKING\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_MASKING, + "#define IS_REQUIRED_BORDERLINE\n#define IS_REQUIRED_ALPHA_MASKING\n", //VisualFactoryCache::IMAGE_SHADER_BORDERLINE_MASKING, + "#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_BORDERLINE\n#define IS_REQUIRED_ALPHA_MASKING\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE_MASKING, + "#define IS_REQUIRED_YUV_TO_RGB\n", //VisualFactoryCache::IMAGE_SHADER_YUV_TO_RGB, + "#define IS_REQUIRED_YUV_TO_RGB\n#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_YUV_TO_RGB, + "#define IS_REQUIRED_YUV_TO_RGB\n#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_BORDERLINE_YUV_TO_RGB, + "#define IS_REQUIRED_YUV_TO_RGB\n#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE_YUV_TO_RGB}; + "#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, + "#define IS_REQUIRED_UNIFIED_YUV_AND_RGB\n#define IS_REQUIRED_BORDERLINE\n", //VisualFactoryCache::IMAGE_SHADER_BORDERLINE_YUV_AND_RGB, + "#define IS_REQUIRED_UNIFIED_YUV_AND_RGB\n#define IS_REQUIRED_ROUNDED_CORNER\n#define IS_REQUIRED_BORDERLINE\n" //VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE_YUV_AND_RGB}; }; ImageVisualShaderFactory::ImageVisualShaderFactory() @@ -164,7 +184,7 @@ void ImageVisualShaderFactory::GetPrecompiledShader(RawShaderData& shaders) shaders.fragmentPrefix = fragmentPrefix; shaders.vertexShader = SHADER_IMAGE_VISUAL_SHADER_VERT; shaders.fragmentShader = SHADER_IMAGE_VISUAL_SHADER_FRAG; - shaders.shaderCount = shaderCount; + shaders.shaderCount += shaderCount; } } // namespace Internal diff --git a/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp b/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp index c893a89..5f9b04b 100644 --- a/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp +++ b/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -56,14 +56,6 @@ 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]{ - "", // VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT -}; -const std::string_view FragmentPredefines[SHADER_TYPE_COUNT]{ - "", // VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT -}; - } // unnamed namespace namespace TextVisualShaderFeature @@ -162,25 +154,6 @@ Shader TextVisualShaderFactory::GetShader(VisualFactoryCache& factoryCache, cons return shader; } -void TextVisualShaderFactory::GetPrecompiledShader(RawShaderData& shaders) -{ - std::vector vertexPrefix; - std::vector fragmentPrefix; - int shaderCount = 0; - for(int i = 0; i < SHADER_TYPE_COUNT; ++i) - { - vertexPrefix.push_back(VertexPredefines[i]); - fragmentPrefix.push_back(FragmentPredefines[i]); - shaderCount++; - } - - shaders.vertexPrefix = vertexPrefix; - shaders.fragmentPrefix = fragmentPrefix; - shaders.vertexShader = SHADER_TEXT_VISUAL_SHADER_VERT; - shaders.fragmentShader = SHADER_TEXT_VISUAL_SHADER_FRAG; - shaders.shaderCount = shaderCount; -} - } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/visuals/text-visual-shader-factory.h b/dali-toolkit/internal/visuals/text-visual-shader-factory.h index dcb60d3..4a9969b 100644 --- a/dali-toolkit/internal/visuals/text-visual-shader-factory.h +++ b/dali-toolkit/internal/visuals/text-visual-shader-factory.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_VISUAL_SHADER_FACTORY_H /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -149,12 +149,6 @@ public: */ Shader GetShader(VisualFactoryCache& factoryCache, const TextVisualShaderFeature::FeatureBuilder& featureBuilder); - /** - * @brief Get the default shader source. - * @param[in] shaders shaderList for precompile - */ - void GetPrecompiledShader(RawShaderData& shaders); - protected: /** * Undefined copy constructor. diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index 77c7b8c..07e1ec9 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-impl.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -76,16 +75,6 @@ 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]{ - "", //VisualFactoryCache::COLOR_SHADER - "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER -}; -const std::string_view FragmentPredefines[SHADER_TYPE_COUNT]{ - "", //VisualFactoryCache::COLOR_SHADER - "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER -}; - } // namespace VisualFactory::VisualFactory(bool debugEnabled) @@ -412,26 +401,10 @@ void VisualFactory::UsePreCompiledShader() } mPrecompiledShaderRequested = true; + RawShaderData rawShaderData; Integration::ShaderPrecompiler::Get().Enable(); - - // Get image shader - std::vector rawShaderList; - RawShaderData imageShaderData; - GetImageVisualShaderFactory().GetPrecompiledShader(imageShaderData); - rawShaderList.push_back(imageShaderData); - - // Get text shader - RawShaderData textShaderData; - GetTextVisualShaderFactory().GetPrecompiledShader(textShaderData); - rawShaderList.push_back(textShaderData); - - // Get color shader - RawShaderData colorShaderData; - GetPrecompiledShader(colorShaderData); - rawShaderList.push_back(colorShaderData); - - // Save all shader - Integration::ShaderPrecompiler::Get().SavePrecomipleShaderList(rawShaderList); + GetImageVisualShaderFactory().GetPrecompiledShader(rawShaderData); + Integration::ShaderPrecompiler::Get().SavePrecomipleShaderList(rawShaderData); } Internal::TextureManager& VisualFactory::GetTextureManager() @@ -459,26 +432,6 @@ void VisualFactory::SetBrokenImageUrl(Toolkit::StyleManager& styleManager) mFactoryCache->SetBrokenImageUrl(brokenImageUrl, customBrokenImageUrlList); } -void VisualFactory::GetPrecompiledShader(RawShaderData& shaders) -{ - std::vector vertexPrefix; - std::vector fragmentPrefix; - int shaderCount = 0; - shaders.shaderCount = 0; - for(int i = 0; i < SHADER_TYPE_COUNT; ++i) - { - vertexPrefix.push_back(VertexPredefines[i]); - fragmentPrefix.push_back(FragmentPredefines[i]); - shaderCount++; - } - - shaders.vertexPrefix = vertexPrefix; - shaders.fragmentPrefix = fragmentPrefix; - shaders.vertexShader = SHADER_COLOR_VISUAL_SHADER_VERT; - shaders.fragmentShader = SHADER_COLOR_VISUAL_SHADER_FRAG; - shaders.shaderCount = shaderCount; -} - Internal::VisualFactoryCache& VisualFactory::GetFactoryCache() { if(!mFactoryCache) diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.h b/dali-toolkit/internal/visuals/visual-factory-impl.h index e628178..04dce97 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.h +++ b/dali-toolkit/internal/visuals/visual-factory-impl.h @@ -115,12 +115,6 @@ private: void SetBrokenImageUrl(Toolkit::StyleManager& styleManager); /** - * @brief Get the default shader source. - * @param[in] shaders shaderList for precompile - */ - void GetPrecompiledShader(RawShaderData& shaders); - - /** * Get the factory cache, creating it if necessary. */ Internal::VisualFactoryCache& GetFactoryCache(); -- 2.7.4