From f96bba06d5017b7e63c66b9f28d8f62421490236 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Fri, 2 Feb 2024 17:01:53 +0900 Subject: [PATCH] [Tizen] Add shader class name so we can debug easly. Let we allow to apply / get the name of shader. It will be useful when we want to control default shader + debug it. Change-Id: Ic69201401191449bc78dafa750e6d097e5f72cde Signed-off-by: Eunki, Hong --- automated-tests/src/dali/utc-Dali-Shader.cpp | 63 +++++++++++++++------- dali/graphics-api/graphics-program-create-info.h | 15 +++++- dali/internal/common/shader-data.h | 53 ++++++++++++++---- dali/internal/event/effects/shader-factory.cpp | 6 +-- dali/internal/event/effects/shader-factory.h | 7 +-- dali/internal/event/rendering/shader-impl.cpp | 35 ++++++++---- dali/internal/event/rendering/shader-impl.h | 14 ++--- dali/internal/render/renderers/render-renderer.cpp | 3 +- dali/public-api/rendering/shader.cpp | 7 +-- dali/public-api/rendering/shader.h | 8 +-- 10 files changed, 151 insertions(+), 60 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Shader.cpp b/automated-tests/src/dali/utc-Dali-Shader.cpp index bf37850..cc2f064 100644 --- a/automated-tests/src/dali/utc-Dali-Shader.cpp +++ b/automated-tests/src/dali/utc-Dali-Shader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * 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. @@ -97,6 +97,15 @@ int UtcDaliShaderMethodNew04(void) END_TEST; } +int UtcDaliShaderMethodNew05(void) +{ + TestApplication application; + + Shader shader = Shader::New(VertexSource, FragmentSource, Shader::Hint::NONE, "testShader"); + DALI_TEST_EQUALS((bool)shader, true, TEST_LOCATION); + END_TEST; +} + int UtcDaliShaderAssignmentOperator(void) { TestApplication application; @@ -506,10 +515,11 @@ int UtcDaliShaderPropertyValueConstructorMap(void) std::string hintSet = "MODIFIES_GEOMETRY"; Property::Map map; - map["vertex"] = VertexSource; - map["fragment"] = FragmentSource; + map["vertex"] = VertexSource; + map["fragment"] = FragmentSource; map["renderPassTag"] = 0; - map["hints"] = hintSet; + map["hints"] = hintSet; + map["name"] = "Test"; Shader shader = Shader::New(map); @@ -521,11 +531,13 @@ int UtcDaliShaderPropertyValueConstructorMap(void) std::string f = (*outMap)["fragment"].Get(); std::string h = (*outMap)["hints"].Get(); int32_t r = (*outMap)["renderPassTag"].Get(); + std::string n = (*outMap)["name"].Get(); DALI_TEST_CHECK(v == map["vertex"].Get()); DALI_TEST_CHECK(f == map["fragment"].Get()); DALI_TEST_CHECK(h == map["hints"].Get()); DALI_TEST_CHECK(r == map["renderPassTag"].Get()); + DALI_TEST_CHECK(n == map["name"].Get()); END_TEST; } @@ -538,10 +550,11 @@ int UtcDaliShaderPropertyValueConstructorMap2(void) std::string hintSet = "MODIFIES_GEOMETRY"; Property::Map map; - map["vertex"] = VertexSource; - map["fragment"] = FragmentSource; + map["vertex"] = VertexSource; + map["fragment"] = FragmentSource; map["renderPassTag"] = 0; - map["hints"] = Shader::Hint::Value::MODIFIES_GEOMETRY; + map["hints"] = Shader::Hint::Value::MODIFIES_GEOMETRY; + map["name"] = "Test"; Shader shader = Shader::New(map); @@ -553,12 +566,14 @@ int UtcDaliShaderPropertyValueConstructorMap2(void) std::string f = (*outMap)["fragment"].Get(); std::string h = (*outMap)["hints"].Get(); int32_t r = (*outMap)["renderPassTag"].Get(); + std::string n = (*outMap)["name"].Get(); DALI_TEST_CHECK(v == map["vertex"].Get()); DALI_TEST_CHECK(f == map["fragment"].Get()); // Note : shader.GetProperty return string even we input hints as enum. DALI_TEST_CHECK(h == hintSet); DALI_TEST_CHECK(r == map["renderPassTag"].Get()); + DALI_TEST_CHECK(n == map["name"].Get()); END_TEST; } @@ -571,15 +586,17 @@ int UtcDaliShaderPropertyValueConstructorArray(void) std::string hintSet = "MODIFIES_GEOMETRY"; Property::Map map[2]; - map[0]["vertex"] = VertexSource; - map[0]["fragment"] = FragmentSource; + map[0]["vertex"] = VertexSource; + map[0]["fragment"] = FragmentSource; map[0]["renderPassTag"] = 0; - map[0]["hints"] = hintSet; + map[0]["hints"] = hintSet; + map[0]["name"] = "Test0"; - map[1]["vertex"] = VertexSource2; - map[1]["fragment"] = FragmentSource2; + map[1]["vertex"] = VertexSource2; + map[1]["fragment"] = FragmentSource2; map[1]["renderPassTag"] = 1; - map[1]["hints"] = hintSet; + map[1]["hints"] = hintSet; + map[1]["name"] = "Test1"; Property::Array array; array.PushBack(map[0]); @@ -601,11 +618,13 @@ int UtcDaliShaderPropertyValueConstructorArray(void) std::string f = (*outMap)["fragment"].Get(); std::string h = (*outMap)["hints"].Get(); int32_t r = (*outMap)["renderPassTag"].Get(); + std::string n = (*outMap)["name"].Get(); DALI_TEST_CHECK(v == map[i]["vertex"].Get()); DALI_TEST_CHECK(f == map[i]["fragment"].Get()); DALI_TEST_CHECK(h == map[i]["hints"].Get()); DALI_TEST_CHECK(r == map[i]["renderPassTag"].Get()); + DALI_TEST_CHECK(n == map[i]["name"].Get()); } END_TEST; @@ -621,15 +640,17 @@ int UtcDaliShaderProgramPropertyArray(void) std::string hintSet = "MODIFIES_GEOMETRY"; Property::Map map[2]; - map[0]["vertex"] = VertexSource; - map[0]["fragment"] = FragmentSource; + map[0]["vertex"] = VertexSource; + map[0]["fragment"] = FragmentSource; map[0]["renderPassTag"] = 0; - map[0]["hints"] = hintSet; + map[0]["hints"] = hintSet; + map[0]["name"] = "Test0"; - map[1]["vertex"] = VertexSource2; - map[1]["fragment"] = FragmentSource2; + map[1]["vertex"] = VertexSource2; + map[1]["fragment"] = FragmentSource2; map[1]["renderPassTag"] = 1; - map[1]["hints"] = hintSet; + map[1]["hints"] = hintSet; + map[1]["name"] = "Test1"; Property::Array array; array.PushBack(map[0]); @@ -651,11 +672,13 @@ int UtcDaliShaderProgramPropertyArray(void) std::string f = (*outMap)["fragment"].Get(); std::string h = (*outMap)["hints"].Get(); int32_t r = (*outMap)["renderPassTag"].Get(); + std::string n = (*outMap)["name"].Get(); DALI_TEST_CHECK(v == map[i]["vertex"].Get()); DALI_TEST_CHECK(f == map[i]["fragment"].Get()); DALI_TEST_CHECK(h == map[i]["hints"].Get()); DALI_TEST_CHECK(r == map[i]["renderPassTag"].Get()); + DALI_TEST_CHECK(n == map[i]["name"].Get()); } END_TEST; @@ -677,4 +700,4 @@ int UtcDaliShaderWrongData(void) DALI_TEST_CHECK(arrayCount == 0u); END_TEST; -} +} \ No newline at end of file diff --git a/dali/graphics-api/graphics-program-create-info.h b/dali/graphics-api/graphics-program-create-info.h index 229b336..4c17677 100644 --- a/dali/graphics-api/graphics-program-create-info.h +++ b/dali/graphics-api/graphics-program-create-info.h @@ -2,7 +2,7 @@ #define DALI_GRAPHICS_PROGRAM_CREATE_INFO_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * 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. @@ -94,9 +94,22 @@ struct ProgramCreateInfo return *this; } + /** + * @brief Set the name of program. + * + * @param[in] value set of allocation callbacks + * @return reference to this structure. + */ + auto& SetName(const std::string& value) + { + name = value; + return *this; + } + GraphicsStructureType type{GraphicsStructureType::PROGRAM_CREATE_INFO_STRUCT}; ExtensionCreateInfo* nextExtension{nullptr}; + std::string_view name{}; const std::vector* shaderState{nullptr}; const AllocationCallbacks* allocationCallbacks{nullptr}; }; diff --git a/dali/internal/common/shader-data.h b/dali/internal/common/shader-data.h index c4fb4fb..10e58b4 100644 --- a/dali/internal/common/shader-data.h +++ b/dali/internal/common/shader-data.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SHADER_DATA_H /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * 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. @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include @@ -36,7 +37,8 @@ using ShaderDataPtr = IntrusivePtr; namespace { -inline std::vector StringToVector(const std::string& str) +template +inline std::vector StringToVector(const StdStringType& str) { auto retval = std::vector{}; retval.insert(retval.begin(), str.begin(), str.end()); @@ -59,14 +61,35 @@ public: * @param[in] fragmentSource Source code for fragment program * @param[in] hints Hints for rendering * @param[in] renderPassTag RenderPassTag to match shader data and render task. + * @param[in] name Shader name for debug. */ - ShaderData(std::string vertexSource, std::string fragmentSource, const Dali::Shader::Hint::Value hints, uint32_t renderPassTag) + ShaderData(std::string vertexSource, std::string fragmentSource, const Dali::Shader::Hint::Value hints, uint32_t renderPassTag, std::string_view name) : mShaderHash(-1), mVertexShader(StringToVector(vertexSource)), mFragmentShader(StringToVector(fragmentSource)), mHints(hints), mSourceMode(Graphics::ShaderSourceMode::TEXT), - mRenderPassTag(renderPassTag) + mRenderPassTag(renderPassTag), + mName(name) + { + } + + /** + * Constructor + * @param[in] vertexSource Source code for vertex program + * @param[in] fragmentSource Source code for fragment program + * @param[in] hints Hints for rendering + * @param[in] renderPassTag RenderPassTag to match shader data and render task. + * @param[in] name Shader name for debug. + */ + ShaderData(std::string_view vertexSource, std::string_view fragmentSource, const Dali::Shader::Hint::Value hints, uint32_t renderPassTag, std::string_view name) + : mShaderHash(-1), + mVertexShader(StringToVector(vertexSource)), + mFragmentShader(StringToVector(fragmentSource)), + mHints(hints), + mSourceMode(Graphics::ShaderSourceMode::TEXT), + mRenderPassTag(renderPassTag), + mName(name) { } @@ -76,14 +99,16 @@ public: * @param[in] fragmentSource Source code for fragment program * @param[in] hints Hints for rendering * @param[in] renderPassTag RenderPassTag to match shader data and render task. + * @param[in] name Shader name for debug. */ - ShaderData(std::vector& vertexSource, std::vector& fragmentSource, const Dali::Shader::Hint::Value hints, uint32_t renderPassTag) + ShaderData(std::vector& vertexSource, std::vector& fragmentSource, const Dali::Shader::Hint::Value hints, uint32_t renderPassTag, std::string_view name) : mShaderHash(-1), mVertexShader(vertexSource), mFragmentShader(fragmentSource), mHints(hints), mSourceMode(Graphics::ShaderSourceMode::BINARY), - mRenderPassTag(renderPassTag) + mRenderPassTag(renderPassTag), + mName(name) { } @@ -242,9 +267,18 @@ public: // API return mRenderPassTag; } -private: // Not implemented - ShaderData(const ShaderData& other); ///< no copying of this object - ShaderData& operator=(const ShaderData& rhs); ///< no copying of this object + /** + * Get Name of shader data + * @return Name for this shader data, Default value is empty string. + */ + const std::string& GetName() const + { + return mName; + } + +private: // Not implemented + ShaderData(const ShaderData& other); ///< no copying of this object + ShaderData& operator=(const ShaderData& rhs); ///< no copying of this object private: // Data std::size_t mShaderHash; ///< hash key created with vertex and fragment shader code @@ -254,6 +288,7 @@ private: // Data Dali::Vector mBuffer; ///< buffer containing compiled binary bytecode Graphics::ShaderSourceMode mSourceMode; ///< Source mode of shader data ( text or binary ) uint32_t mRenderPassTag{0u}; ///< Render Pass Tag for this shader + std::string mName{""}; ///< Name for this shader }; } // namespace Internal diff --git a/dali/internal/event/effects/shader-factory.cpp b/dali/internal/event/effects/shader-factory.cpp index bb1be31..b705e0a 100644 --- a/dali/internal/event/effects/shader-factory.cpp +++ b/dali/internal/event/effects/shader-factory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * 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. @@ -71,7 +71,7 @@ ShaderFactory::~ShaderFactory() } } -ShaderDataPtr ShaderFactory::Load(std::string_view vertexSource, std::string_view fragmentSource, const Dali::Shader::Hint::Value hints, uint32_t renderPass, size_t& shaderHash) +ShaderDataPtr ShaderFactory::Load(std::string_view vertexSource, std::string_view fragmentSource, const Dali::Shader::Hint::Value hints, uint32_t renderPassTag, std::string_view name, size_t& shaderHash) { // Work out the filename for the binary that the glsl source will be compiled and linked to: shaderHash = CalculateHash(vertexSource.data(), fragmentSource.data()); @@ -96,7 +96,7 @@ ShaderDataPtr ShaderFactory::Load(std::string_view vertexSource, std::string_vie if(shaderData.Get() == nullptr) { // Allocate the structure that returns the loaded shader: - shaderData = new ShaderData(std::string(vertexSource), std::string(fragmentSource), hints, renderPass); + shaderData = new ShaderData(vertexSource, fragmentSource, hints, renderPassTag, name); shaderData->SetHashValue(shaderHash); shaderData->GetBuffer().Clear(); diff --git a/dali/internal/event/effects/shader-factory.h b/dali/internal/event/effects/shader-factory.h index 744f2f6..2171466 100644 --- a/dali/internal/event/effects/shader-factory.h +++ b/dali/internal/event/effects/shader-factory.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SHADER_FACTORY_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * 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. @@ -59,13 +59,14 @@ public: * * @param [in] vertexSource The vertex shader source code * @param [in] fragmentSource The fragment shader source code - * @param [in] renderPass RenderPass the shaders are executed + * @param [in] renderPassTag RenderPass the shaders are executed + * @param [in] name The name of shaders are executed * @param [out] shaderHash Hash key created from vertex and fragment shader code * @return ShaderData containing the source and hash value, and additionally, * a compiled shader program binary if one could be found, else an * empty binary buffer cleared to size zero. */ - Internal::ShaderDataPtr Load(std::string_view vertexSource, std::string_view fragmentSource, const Dali::Shader::Hint::Value hints, uint32_t renderPass, size_t& shaderHash); + Internal::ShaderDataPtr Load(std::string_view vertexSource, std::string_view fragmentSource, const Dali::Shader::Hint::Value hints, uint32_t renderPassTag, std::string_view name, size_t& shaderHash); /** * @brief Saves shader to memory cache and filesystem. diff --git a/dali/internal/event/rendering/shader-impl.cpp b/dali/internal/event/rendering/shader-impl.cpp index e1f9005..becd736 100644 --- a/dali/internal/event/rendering/shader-impl.cpp +++ b/dali/internal/event/rendering/shader-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * 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. @@ -46,7 +46,8 @@ Dali::Scripting::StringEnum ShaderHintsTable[] = const uint32_t ShaderHintsTableSize = static_cast(sizeof(ShaderHintsTable) / sizeof(ShaderHintsTable[0])); -static constexpr uint32_t DEFAULT_RENDER_PASS_TAG = 0u; +static constexpr uint32_t DEFAULT_RENDER_PASS_TAG = 0u; +static constexpr std::string_view DEFAULT_SHADER_NAME = ""; BaseHandle Create() { @@ -88,10 +89,11 @@ Property::Value HintString(const Dali::Shader::Hint::Value& hints) return Property::Value(s); } -void GetShaderData(const Property::Map& shaderMap, std::string& vertexShader, std::string& fragmentShader, uint32_t& renderPassTag, Dali::Shader::Hint::Value& hints) +void GetShaderData(const Property::Map& shaderMap, std::string& vertexShader, std::string& fragmentShader, uint32_t& renderPassTag, Dali::Shader::Hint::Value& hints, std::string& name) { hints = Dali::Shader::Hint::NONE; renderPassTag = DEFAULT_RENDER_PASS_TAG; + name = DEFAULT_SHADER_NAME; if(Property::Value* value = shaderMap.Find("vertex")) { @@ -108,6 +110,11 @@ void GetShaderData(const Property::Map& shaderMap, std::string& vertexShader, st renderPassTag = static_cast(value->Get()); } + if(Property::Value* value = shaderMap.Find("name")) + { + name = value->Get(); + } + if(Property::Value* value = shaderMap.Find("hints")) { int32_t hintInteger = 0; @@ -130,7 +137,8 @@ void GetShaderData(const Property::Map& shaderMap, std::string& vertexShader, st ShaderPtr Shader::New(std::string_view vertexShader, std::string_view fragmentShader, - Dali::Shader::Hint::Value hints) + Dali::Shader::Hint::Value hints, + std::string_view shaderName) { // create scene object first so it's guaranteed to exist for the event side auto sceneObject = new SceneGraph::Shader(); @@ -143,7 +151,7 @@ ShaderPtr Shader::New(std::string_view vertexShader, AddShaderMessage(updateManager, transferOwnership); services.RegisterObject(shader.Get()); - shader->UpdateShaderData(vertexShader, fragmentShader, DEFAULT_RENDER_PASS_TAG, hints); + shader->UpdateShaderData(vertexShader, fragmentShader, DEFAULT_RENDER_PASS_TAG, hints, shaderName); return shader; } @@ -198,6 +206,7 @@ Property::Value Shader::GetDefaultProperty(Property::Index index) const map["fragment"] = Property::Value(mShaderDataList.front()->GetFragmentShader()); map["renderPassTag"] = Property::Value(static_cast(mShaderDataList.front()->GetRenderPassTag())); map["hints"] = HintString(mShaderDataList.front()->GetHints()); + map["name"] = Property::Value(mShaderDataList.front()->GetName()); value = map; } else @@ -212,6 +221,7 @@ Property::Value Shader::GetDefaultProperty(Property::Index index) const map["fragment"] = Property::Value(shaderData->GetFragmentShader()); map["renderPassTag"] = Property::Value(static_cast(shaderData->GetRenderPassTag())); map["hints"] = HintString(shaderData->GetHints()); + map["name"] = Property::Value(shaderData->GetName()); array.PushBack(map); } } @@ -237,13 +247,14 @@ Shader::Shader(const SceneGraph::Shader* sceneObject) void Shader::UpdateShaderData(std::string_view vertexSource, std::string_view fragmentSource, uint32_t renderPassTag, - Dali::Shader::Hint::Value hints) + Dali::Shader::Hint::Value hints, + std::string_view name) { // Try to load a pre-compiled shader binary for the source pair: ThreadLocalStorage& tls = ThreadLocalStorage::Get(); ShaderFactory& shaderFactory = tls.GetShaderFactory(); size_t shaderHash; - Internal::ShaderDataPtr shaderData = shaderFactory.Load(vertexSource, fragmentSource, hints, renderPassTag, shaderHash); + Internal::ShaderDataPtr shaderData = shaderFactory.Load(vertexSource, fragmentSource, hints, renderPassTag, name, shaderHash); std::vector::iterator shaderDataIterator = std::find_if(mShaderDataList.begin(), mShaderDataList.end(), [&shaderData](const Internal::ShaderDataPtr& shaderDataItem) { return shaderDataItem->GetRenderPassTag() == shaderData->GetRenderPassTag(); }); if(shaderDataIterator != mShaderDataList.end()) @@ -270,9 +281,10 @@ void Shader::SetShaderProperty(const Dali::Property::Value& shaderMap) std::string fragment; uint32_t renderPassTag{DEFAULT_RENDER_PASS_TAG}; Dali::Shader::Hint::Value hints(Dali::Shader::Hint::NONE); - GetShaderData(*map, vertex, fragment, renderPassTag, hints); + std::string name(DEFAULT_SHADER_NAME); + GetShaderData(*map, vertex, fragment, renderPassTag, hints, name); - UpdateShaderData(vertex, fragment, renderPassTag, hints); + UpdateShaderData(vertex, fragment, renderPassTag, hints, name); } } else if(shaderMap.GetType() == Property::ARRAY) @@ -290,9 +302,10 @@ void Shader::SetShaderProperty(const Dali::Property::Value& shaderMap) std::string fragment; uint32_t renderPassTag{DEFAULT_RENDER_PASS_TAG}; Dali::Shader::Hint::Value hints(Dali::Shader::Hint::NONE); - GetShaderData(*map, vertex, fragment, renderPassTag, hints); + std::string name(DEFAULT_SHADER_NAME); + GetShaderData(*map, vertex, fragment, renderPassTag, hints, name); - UpdateShaderData(vertex, fragment, renderPassTag, hints); + UpdateShaderData(vertex, fragment, renderPassTag, hints, name); } } } diff --git a/dali/internal/event/rendering/shader-impl.h b/dali/internal/event/rendering/shader-impl.h index ca32c18..3b1482e 100644 --- a/dali/internal/event/rendering/shader-impl.h +++ b/dali/internal/event/rendering/shader-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SHADER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * 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. @@ -50,7 +50,8 @@ public: */ static ShaderPtr New(std::string_view vertexShader, std::string_view fragmentShader, - Dali::Shader::Hint::Value hints); + Dali::Shader::Hint::Value hints, + std::string_view shaderName); /** * @copydoc Dali::Shader::New() @@ -83,7 +84,7 @@ private: // implementation /** * Constructor * - * @param sceneObject the scene object + * @param[in] sceneObject the scene object */ Shader(const SceneGraph::Shader* sceneObject); @@ -95,8 +96,9 @@ private: // implementation * @param[in] fragmentShader Fragment Shader code for the effect. * @param[in] renderPassTag render pass tag of this shader data * @param[in] hints Hints to define the geometry of the rendered object + * @param[in] name The name of shader data. */ - void UpdateShaderData(std::string_view vertexShader, std::string_view fragmentShader, uint32_t renderPassTag, Dali::Shader::Hint::Value hints); + void UpdateShaderData(std::string_view vertexShader, std::string_view fragmentShader, uint32_t renderPassTag, Dali::Shader::Hint::Value hints, std::string_view name); /** * @brief Sets shader data from shaderMap. @@ -112,8 +114,8 @@ protected: ~Shader() override; private: // unimplemented methods - Shader() = delete; - Shader(const Shader&) = delete; + Shader() = delete; + Shader(const Shader&) = delete; Shader& operator=(const Shader&) = delete; private: diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp index 11a20f9..413cdb9 100644 --- a/dali/internal/render/renderers/render-renderer.cpp +++ b/dali/internal/render/renderers/render-renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * 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. @@ -441,6 +441,7 @@ Program* Renderer::PrepareProgram(const SceneGraph::RenderInstruction& instructi auto createInfo = Graphics::ProgramCreateInfo(); createInfo.SetShaderState(shaderStates); + createInfo.SetName(shaderData->GetName()); auto graphicsProgram = mGraphicsController->CreateProgram(createInfo, nullptr); program->SetGraphicsProgram(std::move(graphicsProgram), *mUniformBufferManager); // generates reflection } diff --git a/dali/public-api/rendering/shader.cpp b/dali/public-api/rendering/shader.cpp index 1b706f2..04ec2cb 100644 --- a/dali/public-api/rendering/shader.cpp +++ b/dali/public-api/rendering/shader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * 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. @@ -25,9 +25,10 @@ namespace Dali { Shader Shader::New(std::string_view vertexShader, std::string_view fragmentShader, - Hint::Value hints) + Hint::Value hints, + std::string_view shaderName) { - Internal::ShaderPtr shader = Internal::Shader::New(vertexShader, fragmentShader, hints); + Internal::ShaderPtr shader = Internal::Shader::New(vertexShader, fragmentShader, hints, shaderName); return Shader(shader.Get()); } diff --git a/dali/public-api/rendering/shader.h b/dali/public-api/rendering/shader.h index b7b6069..416c8dc 100644 --- a/dali/public-api/rendering/shader.h +++ b/dali/public-api/rendering/shader.h @@ -2,7 +2,7 @@ #define DALI_SHADER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * 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. @@ -110,7 +110,7 @@ public: * @brief Name: "program", Type: MAP or ARRAY. * @note The default value is empty. * @note It is Property::Map or Property::Array of the map. - * @note Format: {"renderPassTag":"", "vertex":"", "fragment":"", "hints":""} + * @note Format: {"renderPassTag":"", "vertex":"", "fragment":"", "hints":"", "name":""} * @SINCE_1_1.43 */ PROGRAM = DEFAULT_OBJECT_PROPERTY_START_INDEX, @@ -124,11 +124,13 @@ public: * @param[in] vertexShader Vertex shader code for the effect. * @param[in] fragmentShader Fragment Shader code for the effect. * @param[in] hints Hints to define the geometry of the rendered object + * @param[in] shaderName The name of this shader. (optional) * @return A handle to a shader effect */ static Shader New(std::string_view vertexShader, std::string_view fragmentShader, - Hint::Value hints = Hint::NONE); + Hint::Value hints = Hint::NONE, + std::string_view shaderName = ""); /** * @brief Creates Shader. -- 2.7.4