*/
#include <dali-test-suite-utils.h>
+#include <dali/integration-api/shader-integ.h>
#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/effects/shader-factory.h>
END_TEST;
}
+int UtcDaliShaderWithPrefixTestVersion2(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test same case of UtcDaliShaderWithPrefixTestVersion with integration api");
+
+ std::string vertexShader =
+ "//@version 100\n"
+ "some code\n";
+ std::string fragmentShader =
+ "//@version 101\n"
+ "some code\n";
+
+ // Get prefix from graphics config.
+ auto vertexPrefix = application.GetGlAbstraction().GetVertexShaderPrefix();
+ auto fragmentPrefix = application.GetGlAbstraction().GetFragmentShaderPrefix();
+
+ // And use GenerateTaggedShaderPrefix from integration-api.
+ vertexPrefix = Dali::Integration::GenerateTaggedShaderPrefix(vertexPrefix);
+ fragmentPrefix = Dali::Integration::GenerateTaggedShaderPrefix(fragmentPrefix);
+
+ Dali::Shader shader = Dali::Shader::New(
+ vertexPrefix + vertexShader,
+ fragmentPrefix + fragmentShader);
+
+ DALI_TEST_EQUALS(vertexPrefix.substr(0, 20), "//@legacy-prefix-end", TEST_LOCATION);
+ DALI_TEST_EQUALS(fragmentPrefix.substr(0, 20), "//@legacy-prefix-end", TEST_LOCATION);
+
+ // Test version number in the shader data
+ Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();
+ Dali::Internal::ShaderFactory& shaderFactory = tls.GetShaderFactory();
+ size_t shaderHash;
+ Internal::ShaderDataPtr shaderData = shaderFactory.Load(vertexShader, fragmentShader, {}, {}, "", shaderHash);
+
+ bool dataValid = (shaderData != nullptr);
+ DALI_TEST_EQUALS(dataValid, true, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(shaderData->GetVertexShaderVersion(), 100, TEST_LOCATION);
+ DALI_TEST_EQUALS(shaderData->GetFragmentShaderVersion(), 101, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliInternalShaderSaveAndLoad01(void)
{
TestApplication application;
${platform_abstraction_src_dir}/profiling.cpp
${platform_abstraction_src_dir}/render-task-list-integ.cpp
${platform_abstraction_src_dir}/scene.cpp
+ ${platform_abstraction_src_dir}/shader-integ.cpp
${platform_abstraction_src_dir}/testing.cpp
${platform_abstraction_src_dir}/texture-integ.cpp
${platform_abstraction_src_dir}/trace.cpp
${platform_abstraction_src_dir}/resource-policies.h
${platform_abstraction_src_dir}/resource-types.h
${platform_abstraction_src_dir}/scene.h
+ ${platform_abstraction_src_dir}/shader-integ.h
${platform_abstraction_src_dir}/testing.h
${platform_abstraction_src_dir}/texture-integ.h
${platform_abstraction_src_dir}/trace.h
--- /dev/null
+/*
+ * Copyright (c) 2024 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// FILE HEADER
+#include <dali/integration-api/shader-integ.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/rendering/shader-impl.h>
+
+namespace Dali::Integration
+{
+std::string GenerateTaggedShaderPrefix(const std::string& shaderPrefix)
+{
+ return Dali::Internal::Shader::GenerateTaggedShaderPrefix(shaderPrefix);
+}
+} // namespace Dali::Integration
--- /dev/null
+#ifndef DALI_SHADER_INTEG_H
+#define DALI_SHADER_INTEG_H
+
+/*
+ * Copyright (c) 2024 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string> // std::string
+
+// INTERNAL INCLUDES
+#include <dali/public-api/rendering/shader.h>
+
+namespace Dali::Integration
+{
+/**
+ * @brief Generates tag 'legacy-prefix-end' with end position of
+ * prefix text to make shader code parsing easier.
+ *
+ * @SINCE_2_3.43
+ * @return Generated string with tag.
+ */
+DALI_CORE_API std::string GenerateTaggedShaderPrefix(const std::string& shaderPrefix);
+
+} // namespace Dali::Integration
+
+#endif // DALI_SHADER_INTEG_H
/**
* Generates tag 'legacy-prefix-end' with end position of
* prefix text to make shader code parsing easier.
- * Function is public to be testable
+ * Function is public to be testable and integration api.
*/
static std::string GenerateTaggedShaderPrefix(const std::string& shaderPrefix);
};