Added FILE_CACHE_SUPPORT hint for shader 49/322649/9
authorsunghyun kim <scholb.kim@samsung.com>
Mon, 14 Apr 2025 04:25:00 +0000 (13:25 +0900)
committersunghyun kim <scholb.kim@samsung.com>
Tue, 22 Apr 2025 06:29:11 +0000 (15:29 +0900)
Previously, all custom Shaders supported file caching, which was not the intended behavior.
therefore, we added a flag to distinguish between internally generated code and externally generated code.
if you want to enable File Caching for externally generated shader code, you can do so using this hint.
(however, the validity of the shader must be verified by the app itself.)

Change-Id: I5e0cb0c6f4177da8159c50e2e27a0833b2c6e54f

automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h
dali/graphics-api/graphics-program-create-info.h
dali/internal/event/rendering/shader-impl.cpp
dali/internal/render/renderers/render-renderer.cpp
dali/public-api/rendering/shader.h

index a70c21f40c50941975feeb75cb4aa03dbf9252fc..52b7411b17735907f946af75448daf65f293cdb8 100644 (file)
@@ -2120,6 +2120,7 @@ public:
 
   inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) override
   {
+    *length = bufSize; // commonly it is same. so we provide bufSize for test
     mGetProgramBinaryCalled = true;
   }
 
index 3f98d169311d65d13afd3e59606cdb780e42dd5f..252bfe5156c525938303edfbba69c31546c73ac7 100644 (file)
@@ -106,12 +106,25 @@ struct ProgramCreateInfo
     return *this;
   }
 
+  /**
+   * @brief Sets whether the program is used the funcation of file-caching by DALi.
+   *
+   * @param[in] value true if the program is used internally by DALi. Otherwise false. Default is false.
+   * @return reference to this structure.
+   */
+  auto& SetFileCaching(bool value)
+  {
+    useFileCache = value;
+    return *this;
+  }
+
   GraphicsStructureType type{GraphicsStructureType::PROGRAM_CREATE_INFO_STRUCT};
   ExtensionCreateInfo*  nextExtension{nullptr};
 
   std::string_view                name{};
   const std::vector<ShaderState>* shaderState{nullptr};
   const AllocationCallbacks*      allocationCallbacks{nullptr};
+  bool                            useFileCache{false};
 };
 
 } // namespace Graphics
index a6ff3c6bfa8b437594247f7b47c3fbd3134d63f8..7dadf22638c4d49928de1d0876bf697d8f5aaebd 100644 (file)
@@ -44,7 +44,8 @@ DALI_PROPERTY_TABLE_END(DEFAULT_ACTOR_PROPERTY_START_INDEX, ShaderDefaultPropert
 Dali::Scripting::StringEnum ShaderHintsTable[] =
   {{"NONE", Dali::Shader::Hint::NONE},
    {"OUTPUT_IS_TRANSPARENT", Dali::Shader::Hint::OUTPUT_IS_TRANSPARENT},
-   {"MODIFIES_GEOMETRY", Dali::Shader::Hint::MODIFIES_GEOMETRY}};
+   {"MODIFIES_GEOMETRY", Dali::Shader::Hint::MODIFIES_GEOMETRY},
+   {"FILE_CACHE_SUPPORT", Dali::Shader::Hint::FILE_CACHE_SUPPORT}};
 
 const uint32_t ShaderHintsTableSize = static_cast<uint32_t>(sizeof(ShaderHintsTable) / sizeof(ShaderHintsTable[0]));
 
index 445d10da6f5b9b56bc0f05d525fea3e98cc70bfa..83ebe3ebde183e8138a00b2205b1d4a56eecb0f6 100644 (file)
@@ -492,6 +492,7 @@ Program* Renderer::PrepareProgram(const SceneGraph::RenderInstruction& instructi
     auto createInfo = Graphics::ProgramCreateInfo();
     createInfo.SetShaderState(shaderStates);
     createInfo.SetName(shaderData->GetName());
+    createInfo.SetFileCaching(shaderData->GetHints() & Dali::Shader::Hint::Value::FILE_CACHE_SUPPORT);
     auto graphicsProgram = mGraphicsController->CreateProgram(createInfo, nullptr);
     program->SetGraphicsProgram(std::move(graphicsProgram), *mUniformBufferManager, shader.GetConnectedUniformBlocks()); // generates reflection, defines memory reqs
 
index ae9f34f012e45862cd76a25743f113d70d35c51b..4235b7a86876e367cbbcb6bb1fd0546a8048206f 100644 (file)
@@ -91,6 +91,7 @@ public:
       NONE                  = 0x00, ///< No hints                                                                          @SINCE_1_1.45
       OUTPUT_IS_TRANSPARENT = 0x01, ///< Might generate transparent alpha from opaque inputs                               @SINCE_1_1.45
       MODIFIES_GEOMETRY     = 0x02, ///< Might change position of vertices, this option disables any culling optimizations @SINCE_1_1.45
+      FILE_CACHE_SUPPORT    = 0x04, ///< Cache the shader in a file                                                        @SINCE_2_4.15
     };
   };