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
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;
}
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
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]));
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
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
};
};