std::vector<uint8_t> data;
auto* shader = static_cast<const Dali::Graphics::GLES::Shader*>(shaderState.shader);
auto& shaderCreateInfo = shader->GetCreateInfo();
- data.resize(shaderCreateInfo.sourceSize + 1);
- std::memcpy(&data[0], shaderCreateInfo.sourceData, shaderCreateInfo.sourceSize);
- data[shaderCreateInfo.sourceSize] = 0;
- return std::string(reinterpret_cast<char*>(&data[0]));
+ auto shaderImpl = shader->GetImplementation();
+ if(shaderImpl->HasPreprocessedCode())
+ {
+ return std::string{shaderImpl->GetPreprocessedCode()};
+ }
+ return {reinterpret_cast<char*>(&data[0]), shaderCreateInfo.sourceSize};
}
-void ParseShaderSamplers(std::string shaderSource, std::vector<Dali::Graphics::UniformInfo>& uniformOpaques, int& samplerPosition, std::vector<int>& samplerPositions)
+void ParseShaderSamplers(const std::string& shaderSource, std::vector<Dali::Graphics::UniformInfo>& uniformOpaques, int& samplerPosition, std::vector<int>& samplerPositions)
{
if(!shaderSource.empty())
{
return mImpl->createInfo;
}
+bool ShaderImpl::HasPreprocessedCode() const
+{
+ return !mImpl->sourcePreprocessed.empty();
+}
+
+std::string_view ShaderImpl::GetPreprocessedCode() const
+{
+ return {reinterpret_cast<char*>(mImpl->sourcePreprocessed.data())};
+}
+
[[nodiscard]] EglGraphicsController& ShaderImpl::GetController() const
{
return mImpl->controller;
*/
void SetPreprocessedCode(void* data, uint32_t size);
+ /**
+ * @brief Returns preprocessed code
+ *
+ * @note Use HasPreprocessedCode() first before using this function.
+ *
+ * @return the string_view to the preprocessed code
+ */
+ [[nodiscard]] std::string_view GetPreprocessedCode() const;
+
+ /**
+ * @brief Checks whether preprocessed code is available
+ *
+ * @return true if there is a preprocessed code
+ */
+ [[nodiscard]] bool HasPreprocessedCode() const;
+
/**
* @brief Returns GLSL version
* @return Returns valid GLSL version or 0 if undefined