#include <mesh-builder.h>
#include <stdlib.h>
+#include <dali/public-api/common/vector-wrapper.h>
+
#include <algorithm>
#include <iostream>
+#include <utility>
using std::max;
using namespace Dali;
// not mathing properties (VECTOR3, FLOAT)
animation.AnimateBy(Property(actor, Actor::Property::POSITION), Property::Value(10.f));
},
- "Property and target types don't match");
+ "Target types could not be convert to Property type");
DALI_TEST_ASSERTION(
{
// not mathing properties (VECTOR3.A, VECTOR2)
animation.AnimateBy(Property(actor, Actor::Property::COLOR_ALPHA), Property::Value(Property::VECTOR2));
},
- "Property and target types don't match");
+ "Target types could not be convert to Property type");
DALI_TEST_ASSERTION(
{
},
"Target value is not animatable");
- DALI_TEST_ASSERTION(
- {
- // not mathing properties (FLOAT, INT)
- animation.AnimateTo(Property(actor, Actor::Property::SCALE_Y), Property::Value(10));
- },
- "Property and target types don't match");
-
DALI_TEST_ASSERTION(
{
// not mathing properties (VECTOR3, VECTOR2)
animation.AnimateTo(Property(actor, Actor::Property::COLOR), Property::Value(Property::VECTOR2));
},
- "Property and target types don't match");
+ "Target types could not be convert to Property type");
DALI_TEST_ASSERTION(
{
keyframes.Add(0.5f, Property::Value(Vector4(1, 2, 3, 4)));
animation.AnimateBetween(Property(actor, Actor::Property::MAXIMUM_SIZE), keyframes);
},
- "Property and target types don't match");
+ "Target types could not be convert to Property type");
DALI_TEST_ASSERTION(
{
END_TEST;
}
+int UtcDaliAnimationAnimateConvertPropertyValueParameters(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+
+ // Create the animation
+ Animation animation = Animation::New(1.0f);
+
+ Property::Index indexBoolean = actor.RegisterProperty("animationBoolean", Property::Value(false), Property::ANIMATABLE);
+ Property::Index indexFloat = actor.RegisterProperty("animationFloat", Property::Value(0.0f), Property::ANIMATABLE);
+ Property::Index indexInteger = actor.RegisterProperty("animationInteger", Property::Value(0), Property::ANIMATABLE);
+
+ // clang-format off
+ const std::vector<std::pair<Property::Index, Property::Value>> indexValueList =
+ {
+ {indexBoolean, actor.GetProperty(indexBoolean)},
+ {indexFloat, actor.GetProperty(indexFloat)},
+ {indexInteger, actor.GetProperty(indexInteger)},
+ };
+
+ // Piar of relative value - {except value as relative value per each type of properties}
+ const std::vector<std::pair<Property::Value, std::vector<Property::Value>>> testExceptValueList =
+ {
+ {
+ Property::Value(true),
+ {
+ Property::Value(true), Property::Value(1.0f), Property::Value(1),
+ }
+ },
+ {
+ Property::Value(2.0f),
+ {
+ Property::Value(true), Property::Value(2.0f), Property::Value(2),
+ }
+ },
+ {
+ Property::Value(3),
+ {
+ Property::Value(true), Property::Value(3.0f), Property::Value(3),
+ }
+ },
+ };
+ // clang-format on
+
+ // Let we test both AnimateBy and AnimateTo and AnimateBetween as one UTC.
+ for(auto animateType = 0; animateType < 3; ++animateType)
+ {
+ tet_printf("Animation type test : %s\n", std::vector<std::string>({"AnimateBy", "AnimateTo", "AnimateBetween"})[animateType].c_str());
+ for(const auto& valueExceptPair : testExceptValueList)
+ {
+ {
+ std::ostringstream oss;
+ oss << valueExceptPair.first;
+ tet_printf("Animate required value : %s\n", oss.str().c_str());
+ }
+ for(const auto& indexValuePair : indexValueList)
+ {
+ if(animateType == 0u)
+ {
+ animation.AnimateBy(Property(actor, indexValuePair.first), valueExceptPair.first);
+ }
+ else if(animateType == 1u)
+ {
+ animation.AnimateTo(Property(actor, indexValuePair.first), valueExceptPair.first);
+ }
+ else if(animateType == 2u)
+ {
+ Dali::KeyFrames keyFrames = Dali::KeyFrames::New();
+
+ // Convert original value type as excepted type.
+ auto originalValue = indexValuePair.second;
+ originalValue.ConvertType(valueExceptPair.first.GetType());
+
+ keyFrames.Add(0.0f, originalValue);
+ keyFrames.Add(1.0f, valueExceptPair.first);
+ animation.AnimateBetween(Property(actor, indexValuePair.first), keyFrames);
+ }
+ }
+ animation.Play();
+
+ const auto& exceptValueList = valueExceptPair.second;
+
+ // Test except value list size is same as index value list size. (All property should have except value)
+ DALI_TEST_EQUALS(exceptValueList.size(), indexValueList.size(), TEST_LOCATION);
+
+ // Check cached event thread values are expect.
+ for(auto i = 0u; i < indexValueList.size(); ++i)
+ {
+ DALI_TEST_EQUALS(actor.GetProperty(indexValueList[i].first), exceptValueList[i], TEST_LOCATION);
+ }
+
+ // Check current vaules are not animated yet.
+ for(auto i = 0u; i < indexValueList.size(); ++i)
+ {
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(indexValueList[i].first), indexValueList[i].second, TEST_LOCATION);
+ }
+
+ application.SendNotification();
+ application.Render(500);
+ application.SendNotification();
+ application.Render(500 + 10); ///< Note, we don't allow 1 frame animation finished. To fair test, render 2 frames.
+
+ // Check current vaules are except.
+ for(auto i = 0u; i < indexValueList.size(); ++i)
+ {
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(indexValueList[i].first), exceptValueList[i], TEST_LOCATION);
+ }
+
+ animation.Clear();
+ // Reset to base value, for fair test.
+ for(const auto& indexValuePair : indexValueList)
+ {
+ actor.SetProperty(indexValuePair.first, indexValuePair.second);
+ }
+ application.SendNotification();
+ application.Render();
+ }
+ }
+
+ END_TEST;
+}
+
namespace // Purposefully left this in the middle as the values in this namespace are only used for the subsequent two test cases
{
enum TestFunction
/*
- * 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.
#include <dali/public-api/dali-core.h>
#include <stdlib.h>
+#include <dali/public-api/common/vector-wrapper.h>
+
+#include <algorithm>
#include <iomanip>
#include <iostream>
+#include <utility>
using namespace Dali;
Property::Value value(v);
DALI_TEST_EQUALS(value.GetType(), Property::RECTANGLE, TEST_LOCATION);
- DALI_TEST_CHECK(value.Get<Rect<int> >() == v);
+ DALI_TEST_CHECK(value.Get<Rect<int>>() == v);
END_TEST;
}
Property::Value value(Property::RECTANGLE);
DALI_TEST_CHECK(value.GetType() == Property::RECTANGLE);
- DALI_TEST_CHECK(value.Get<Rect<int> >() == Rect<int>(0, 0, 0, 0));
+ DALI_TEST_CHECK(value.Get<Rect<int>>() == Rect<int>(0, 0, 0, 0));
END_TEST;
}
int UtcDaliPropertyValueCopyConstructorRectP(void)
{
- CheckCopyCtorP<Rect<int> > check(Rect<int>(1.0, 1.0, 1.0, 1.0));
+ CheckCopyCtorP<Rect<int>> check(Rect<int>(1.0, 1.0, 1.0, 1.0));
END_TEST;
}
DALI_TEST_EQUALS(valueFloat, 1.0f, TEST_LOCATION);
// Self std::move assignment make compile warning over gcc-13. Let we ignore the warning.
-#if (__GNUC__ >= 13)
+#if(__GNUC__ >= 13)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wself-move"
#endif
value2 = std::move(value2);
DALI_TEST_EQUALS(true, value2.Get(valueFloat), TEST_LOCATION);
DALI_TEST_EQUALS(valueFloat, 1.0f, TEST_LOCATION);
-#if (__GNUC__ >= 13)
+#if(__GNUC__ >= 13)
#pragma GCC diagnostic pop
#endif
{
Property::Value value(Rect<int>(1, 2, 3, 4));
Rect<int> result(4, 3, 2, 1);
- DALI_TEST_EQUALS(Rect<int>(1, 2, 3, 4), value.Get<Rect<int> >(), TEST_LOCATION);
+ DALI_TEST_EQUALS(Rect<int>(1, 2, 3, 4), value.Get<Rect<int>>(), TEST_LOCATION);
DALI_TEST_EQUALS(true, value.Get(result), TEST_LOCATION);
DALI_TEST_EQUALS(Rect<int>(1, 2, 3, 4), result, TEST_LOCATION);
END_TEST;
{
Property::Value value;
Rect<int> result(4, 3, 2, 1);
- DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), value.Get<Rect<int> >(), TEST_LOCATION);
+ DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), value.Get<Rect<int>>(), TEST_LOCATION);
DALI_TEST_EQUALS(false, value.Get(result), TEST_LOCATION);
DALI_TEST_EQUALS(Rect<int>(4, 3, 2, 1), result, TEST_LOCATION);
Property::Value value2("");
END_TEST;
}
+int UtcDaliPropertyValueConvertScalarType(void)
+{
+ tet_infoline("Check Property::Value type conversion.");
+
+ // Piar of input value - {except value as relative value per each type of properties}
+ // clang-format off
+ const std::vector<Property::Type> testConvertTypeList =
+ {
+ Property::BOOLEAN, Property::FLOAT, Property::INTEGER,
+ };
+ const std::vector<std::pair<Property::Value, std::vector<Property::Value>>> testExceptValueList =
+ {
+ {
+ Property::Value(true),
+ {
+ Property::Value(true), Property::Value(1.0f), Property::Value(1),
+ }
+ },
+ {
+ Property::Value(2.0f),
+ {
+ Property::Value(true), Property::Value(2.0f), Property::Value(2),
+ }
+ },
+ {
+ Property::Value(3),
+ {
+ Property::Value(true), Property::Value(3.0f), Property::Value(3),
+ }
+ },
+ };
+ // clang-format on
+
+ for(auto& valueExceptPair : testExceptValueList)
+ {
+ const auto& exceptValueList = valueExceptPair.second;
+
+ // Test except value list size is same as conversion type list size. (All property should have except value)
+ DALI_TEST_EQUALS(exceptValueList.size(), testConvertTypeList.size(), TEST_LOCATION);
+
+ // Check cached event thread values are expect.
+ for(auto i = 0u; i < testConvertTypeList.size(); ++i)
+ {
+ // Check expect type is valid.
+ const Property::Type convertType = testConvertTypeList[i];
+ DALI_TEST_EQUALS(convertType, exceptValueList[i].GetType(), TEST_LOCATION);
+
+ Property::Value convertedValue = valueExceptPair.first;
+
+ tet_printf("Test convert from %d to %d\n", static_cast<int>(convertedValue.GetType()), static_cast<int>(convertType));
+
+ DALI_TEST_CHECK(convertedValue.ConvertType(convertType));
+ DALI_TEST_EQUALS(convertedValue, exceptValueList[i], TEST_LOCATION);
+ }
+ }
+ END_TEST;
+}
+
+int UtcDaliPropertyValueConvertFailed(void)
+{
+ tet_infoline("Check Property::Value type conversion failed.");
+
+ float a[] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f};
+ Property::Array array;
+ Property::Map map;
+
+ // clang-format off
+ const std::vector<Property::Value> scalarValueList =
+ {
+ Property::Value(false), Property::Value(1.0f), Property::Value(2)
+ };
+ const std::vector<Property::Value> conversionInvalidValueList =
+ {
+ Property::Value(),
+ Property::Value(Vector2()), Property::Value(Vector3()), Property::Value(Vector4()),
+
+ Property::Value(Matrix(a)),
+ Property::Value(Matrix3(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f)),
+
+ Property::Value(Rect<int32_t>(2, 3, 4, 5)),
+ Property::Value(AngleAxis(Radian(20.0f), Vector3(0.0f, 1.0f, 0.0f))),
+ Property::Value(std::string("Hell, o, World!")),
+ Property::Value(Extents(4, 8, 5, 2)),
+
+ Property::Value(array),
+ Property::Value(map),
+ };
+ // clang-format on
+
+ for(int i = Property::Type::NONE; i <= Property::Type::EXTENTS; ++i)
+ {
+ Property::Type type(static_cast<Property::Type>(i));
+
+ // Test convert for scalar value type
+ for(auto& value : scalarValueList)
+ {
+ // Copy value
+ Property::Value convertedValue = value;
+ bool expectConvertResult = (type == Property::BOOLEAN || type == Property::FLOAT || type == Property::INTEGER);
+
+ DALI_TEST_EQUALS(convertedValue.ConvertType(type), expectConvertResult, TEST_LOCATION);
+ }
+
+ // Test convert invalid for conversion invalid types
+ for(auto& value : conversionInvalidValueList)
+ {
+ // Copy value
+ Property::Value convertedValue = value;
+ bool expectConvertResult = (type == convertedValue.GetType());
+
+ DALI_TEST_EQUALS(convertedValue.ConvertType(type), expectConvertResult, TEST_LOCATION);
+ }
+ }
+ END_TEST;
+}
+
int UtcDaliPropertyValueOutputStream(void)
{
TestApplication application;
class Program;
class Shader;
class Texture;
+class RenderTarget;
+class RenderPass;
+class Sampler;
/**
* @brief Structure describes 2D offset
struct InputAssemblyState
{
PrimitiveTopology topology{};
- bool primitiveRestartEnable{true};
+ bool primitiveRestartEnable{false};
auto& SetTopology(PrimitiveTopology value)
{
auto& SetPrimitiveRestartEnable(bool value)
{
- primitiveRestartEnable = true;
+ primitiveRestartEnable = value;
return *this;
}
};
return static_cast<CommandBufferUsageFlags>(flags) | static_cast<CommandBufferUsageFlags>(bit);
}
+enum class ResourceType
+{
+ PROGRAM,
+ BUFFER,
+ SAMPLER,
+ TEXTURE
+};
+
+struct ProgramResourceBindingInfo
+{
+ Graphics::Program* program;
+ uint32_t count;
+};
+
+struct BufferResourceBindingInfo;
+struct TextureResourceBindingInfo;
+struct SamplerResourceBindingInfo;
+
+struct CommandBufferResourceBinding
+{
+ ResourceType type; ///< Type of resource
+
+ union
+ {
+ ProgramResourceBindingInfo* programBinding{nullptr};
+ BufferResourceBindingInfo* bufferBinding;
+ TextureResourceBindingInfo* textureBinding;
+ SamplerResourceBindingInfo* samplerBinding;
+ };
+};
+
struct CommandBufferBeginInfo
{
CommandBufferUsageFlags usage;
- // Don't care about inheritance yet. Can extend as required.
+
+ std::vector<CommandBufferResourceBinding>* resourceBindings{nullptr}; ///< Sets resource binding hints
+ const RenderPass* renderPass{nullptr};
+ const RenderTarget* renderTarget{nullptr};
+ auto& SetUsage(CommandBufferUsageFlags flags)
+ {
+ usage = flags;
+ return *this;
+ }
+ auto& SetRenderPass(const RenderPass& value)
+ {
+ renderPass = &value;
+ return *this;
+ }
+ auto& SetRenderTarget(const RenderTarget& value)
+ {
+ renderTarget = &value;
+ return *this;
+ }
};
/**
template<class P, template<typename> typename U>
DefaultDeleter(const U<P>& deleter)
{
- deleteFunction = [](T* object)
- { U<P>()(static_cast<P*>(object)); };
+ deleteFunction = [](T* object) { U<P>()(static_cast<P*>(object)); };
}
/**
}
/**
- * Helper to validate animation input values
+ * Helper to validate and convert animation input values
*
- * @param propertyType type of the property that is being animated
- * @param destinationType type of the target
- * @param period time period of the animation
+ * @param[in] propertyType type of the property that is being animated
+ * @param[in] period time period of the animation
+ * @param[in, out] convertedValue if the value needs conversion, this will contain the converted value.
*/
-void ValidateParameters(Property::Type propertyType, Property::Type destinationType, const TimePeriod& period)
+void ValidateAndConvertParameters(Property::Type propertyType, const TimePeriod& period, Property::Value& convertedValue)
{
// destination value has to be animatable
DALI_ASSERT_ALWAYS(IsAnimatable(propertyType) && "Property type is not animatable");
- DALI_ASSERT_ALWAYS(IsAnimatable(destinationType) && "Target value is not animatable");
- DALI_ASSERT_ALWAYS(propertyType == destinationType && "Property and target types don't match");
+ DALI_ASSERT_ALWAYS(IsAnimatable(convertedValue.GetType()) && "Target value is not animatable");
DALI_ASSERT_ALWAYS(period.durationSeconds >= 0 && "Duration must be >=0");
+
+ DALI_ASSERT_ALWAYS(convertedValue.ConvertType(propertyType) && "Target types could not be convert to Property type");
}
/**
void Animation::AnimateBy(Property& target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
{
- Object& object = GetImplementation(target.object);
- const Property::Type propertyType = object.GetPropertyType(target.propertyIndex);
- const Property::Type destinationType = relativeValue.GetType();
+ Object& object = GetImplementation(target.object);
+ const Property::Type propertyType = (target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? object.GetPropertyType(target.propertyIndex) : Property::FLOAT;
- // validate animation parameters, if component index is set then use float as checked type
- ValidateParameters((target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
- destinationType,
- period);
+ // validate and convert animation parameters, if component index is set then use float as checked type
+ ValidateAndConvertParameters(propertyType, period, relativeValue);
ExtendDuration(period);
// keep the current count.
auto connectorIndex = mConnectors.Count();
- // using destination type so component animation gets correct type
- switch(destinationType)
+ switch(propertyType)
{
case Property::BOOLEAN:
{
void Animation::AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
{
- Object& object = GetImplementation(target.object);
- const Property::Type propertyType = object.GetPropertyType(target.propertyIndex);
- const Property::Type destinationType = destinationValue.GetType();
+ Object& object = GetImplementation(target.object);
+ const Property::Type propertyType = (target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? object.GetPropertyType(target.propertyIndex) : Property::FLOAT;
- // validate animation parameters, if component index is set then use float as checked type
- ValidateParameters((target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
- destinationType,
- period);
+ // validate and convert animation parameters, if component index is set then use float as checked type
+ ValidateAndConvertParameters(propertyType, period, destinationValue);
ExtendDuration(period);
// keep the current count.
auto connectorIndex = mConnectors.Count();
- // using destination type so component animation gets correct type
- switch(destinationType)
+ switch(propertyType)
{
case Property::BOOLEAN:
{
Object& object = GetImplementation(target.object);
const KeyFrames& keyFramesImpl = GetImplementation(keyFrames);
- const Property::Type propertyType = object.GetPropertyType(target.propertyIndex);
- const Property::Type destinationType = keyFramesImpl.GetType();
+ const Property::Type propertyType = (target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? object.GetPropertyType(target.propertyIndex) : Property::FLOAT;
+
+ auto lastKeyFrameValue = keyFramesImpl.GetLastKeyFrameValue();
+ ValidateAndConvertParameters(propertyType, period, lastKeyFrameValue);
+
+ if(DALI_UNLIKELY(propertyType != keyFramesImpl.GetType()))
+ {
+ // Test for conversion valid, and convert keyframe values to matched property type.
+ Dali::KeyFrames convertedKeyFrames = Dali::KeyFrames::New();
+ auto keyFrameCount = keyFramesImpl.GetKeyFrameCount();
+ for(auto frameIndex = 0u; frameIndex < keyFrameCount; ++frameIndex)
+ {
+ float progress;
+ Property::Value value;
+ keyFramesImpl.GetKeyFrame(frameIndex, progress, value);
+ DALI_ASSERT_ALWAYS(value.ConvertType(propertyType) && "Target types could not be convert to Property type");
- // validate animation parameters, if component index is set then use float as checked type
- ValidateParameters((target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
- destinationType,
- period);
+ convertedKeyFrames.Add(progress, value);
+ }
+
+ // Retry to animation as the converted keyframes.
+ AnimateBetween(target, convertedKeyFrames, alpha, period, interpolation);
+ return;
+ }
ExtendDuration(period);
- AppendConnectorTargetValues({keyFramesImpl.GetLastKeyFrameValue(), period, mConnectors.Count(), BETWEEN});
+ AppendConnectorTargetValues({lastKeyFrameValue, period, mConnectors.Count(), BETWEEN});
- // using destination type so component animation gets correct type
- switch(destinationType)
+ switch(propertyType)
{
case Dali::Property::BOOLEAN:
{
const Rect<int>& rootClippingRect,
int orientation,
const Uint16Pair& sceneSize,
+ Graphics::RenderPass* renderPass,
Graphics::RenderTarget* renderTarget)
{
DALI_PRINT_RENDER_LIST(renderList);
// We are always "inside" a render pass here.
Graphics::CommandBufferBeginInfo info;
- info.usage = 0 | Graphics::CommandBufferUsageFlagBits::ONE_TIME_SUBMIT;
+ info.SetUsage(0 | Graphics::CommandBufferUsageFlagBits::RENDER_PASS_CONTINUE)
+ .SetRenderPass(*renderPass)
+ .SetRenderTarget(*renderTarget);
secondaryCommandBuffer.Begin(info);
secondaryCommandBuffer.SetViewport(ViewportFromClippingBox(sceneSize, mViewportRectangle, orientation));
{
}
-void RenderAlgorithms::ResetCommandBuffer()
+void RenderAlgorithms::ResetCommandBuffer(std::vector<Graphics::CommandBufferResourceBinding>* resourceBindings)
{
// Reset main command buffer
if(!mGraphicsCommandBuffer)
}
Graphics::CommandBufferBeginInfo info;
- info.usage = 0 | Graphics::CommandBufferUsageFlagBits::ONE_TIME_SUBMIT;
+ info.resourceBindings = resourceBindings; // set resource bindings, currently only programs
+ info.usage = 0 | Graphics::CommandBufferUsageFlagBits::ONE_TIME_SUBMIT;
mGraphicsCommandBuffer->Begin(info);
}
const Rect<int>& rootClippingRect,
int orientation,
const Uint16Pair& sceneSize,
+ Graphics::RenderPass* renderPass,
Graphics::RenderTarget* renderTarget)
{
DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_RENDER_INSTRUCTION_PROCESS", [&](std::ostringstream& oss) { oss << "[" << instruction.RenderListCount() << "]"; });
rootClippingRect,
orientation,
sceneSize,
+ renderPass,
renderTarget);
// Execute command buffer
const Rect<int>& rootClippingRect,
int orientation,
const Uint16Pair& sceneSize,
+ Graphics::RenderPass* renderPass,
Graphics::RenderTarget* renderTarget);
/**
* Resets main command buffer (per scene)
+ *
+ * @param[in] bindings list of resource bindings (optional, can be null)
*/
- void ResetCommandBuffer();
+ void ResetCommandBuffer(std::vector<Graphics::CommandBufferResourceBinding>* bindings);
/**
* Submits main command buffer (per scene)
const Rect<int>& rootClippingRect,
int orientation,
const Uint16Pair& sceneSize,
+ Graphics::RenderPass* renderPass,
Graphics::RenderTarget* renderTarget);
// Member variables:
return;
}
- // Reset main algorithms command buffer
- mImpl->renderAlgorithms.ResetCommandBuffer();
-
- auto mainCommandBuffer = mImpl->renderAlgorithms.GetMainCommandBuffer();
-
Internal::Scene& sceneInternal = GetImplementation(scene);
SceneGraph::Scene* sceneObject = sceneInternal.GetSceneObject();
if(!sceneObject)
auto totalSizeCPU = 0u;
auto totalSizeGPU = 0u;
+ std::unordered_map<Graphics::Program*, Graphics::ProgramResourceBindingInfo> programUsageCount;
+
for(uint32_t i = 0; i < instructionCount; ++i)
{
RenderInstruction& instruction = sceneObject->GetRenderInstructions().At(mImpl->renderBufferIndex, i);
{
const auto& memoryRequirements = program->GetUniformBlocksMemoryRequirements();
+ // collect how many programs we use in this frame
+ auto key = &program->GetGraphicsProgram();
+ auto it = programUsageCount.find(key);
+ if(it == programUsageCount.end())
+ {
+ programUsageCount[key] = Graphics::ProgramResourceBindingInfo{.program = key, .count = 1};
+ }
+ else
+ {
+ (*it).second.count++;
+ }
+
totalSizeCPU += memoryRequirements.totalCpuSizeRequired;
totalSizeGPU += memoryRequirements.totalGpuSizeRequired;
}
}
}
+ // Fill resource binding for the command buffer
+ std::vector<Graphics::CommandBufferResourceBinding> commandBufferResourceBindings;
+ if(!programUsageCount.empty())
+ {
+ commandBufferResourceBindings.resize(programUsageCount.size());
+ auto iter = commandBufferResourceBindings.begin();
+ for(auto& item : programUsageCount)
+ {
+ iter->type = Graphics::ResourceType::PROGRAM;
+ iter->programBinding = &item.second;
+ }
+ }
+
+ // Reset main algorithms command buffer
+ mImpl->renderAlgorithms.ResetCommandBuffer(commandBufferResourceBindings.empty() ? nullptr : &commandBufferResourceBindings);
+
+ auto mainCommandBuffer = mImpl->renderAlgorithms.GetMainCommandBuffer();
+
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Render scene (%s), CPU:%d GPU:%d\n", renderToFbo ? "Offscreen" : "Onscreen", totalSizeCPU, totalSizeGPU);
auto& uboManager = mImpl->uniformBufferManager;
clippingRect,
surfaceOrientation,
Uint16Pair(surfaceRect.width, surfaceRect.height),
+ currentRenderPass,
currentRenderTarget);
Graphics::SyncObject* syncObject{nullptr};
{
const uint32_t CORE_MAJOR_VERSION = 2;
const uint32_t CORE_MINOR_VERSION = 3;
-const uint32_t CORE_MICRO_VERSION = 41;
+const uint32_t CORE_MICRO_VERSION = 42;
const char* const CORE_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
/*
- * Copyright (c) 2022 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.
mData.mType.type = typeValue;
}
+ bool ConvertType(const Property::Type targetType)
+ {
+ bool converted = false;
+ const Property::Type inputType = mData.mType.type;
+
+ if(inputType == targetType)
+ {
+ // We don't need conversion for same type.
+ return true;
+ }
+
+ switch(inputType)
+ {
+ // Try to convert only for scalar types
+ case Property::BOOLEAN:
+ {
+ bool value = mData.mBool.member;
+ switch(targetType)
+ {
+ case Property::FLOAT:
+ {
+ SetType(targetType);
+ mData.mFloat.member = static_cast<float>(value);
+ converted = true;
+ break;
+ }
+ case Property::INTEGER:
+ {
+ SetType(targetType);
+ mData.mInt.member = static_cast<int32_t>(value);
+ converted = true;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ break;
+ }
+ case Property::FLOAT:
+ {
+ float value = mData.mFloat.member;
+ switch(targetType)
+ {
+ case Property::BOOLEAN:
+ {
+ SetType(targetType);
+ mData.mBool.member = static_cast<bool>(!Dali::EqualsZero(value));
+ converted = true;
+ break;
+ }
+ case Property::INTEGER:
+ {
+ SetType(targetType);
+ mData.mInt.member = static_cast<int32_t>(value);
+ converted = true;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ break;
+ }
+ case Property::INTEGER:
+ {
+ int32_t value = mData.mInt.member;
+ switch(targetType)
+ {
+ case Property::BOOLEAN:
+ {
+ SetType(targetType);
+ mData.mBool.member = static_cast<bool>(value);
+ converted = true;
+ break;
+ }
+ case Property::FLOAT:
+ {
+ SetType(targetType);
+ mData.mFloat.member = static_cast<float>(value);
+ converted = true;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ return converted;
+ }
+
private:
/**
* This helper function takes a typed(Tp) memory location( member)
return Read().GetType();
}
+bool Property::Value::ConvertType(const Property::Type targetType)
+{
+ return Write().ConvertType(targetType);
+}
+
bool Property::Value::Get(bool& booleanValue) const
{
bool converted = false;
#define DALI_PROPERTY_VALUE_H
/*
- * Copyright (c) 2022 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.
*/
Type GetType() const;
+ /**
+ * @brief Convert value to another type.
+ * @note It will be works only if both input and output are scalar type. - Property::BOOLEAN, Property::FLOAT, Property::INTEGER.
+ *
+ * @SINCE_2_3.41
+ * @param[in] targetType Target type of the conversion.
+ * @return True if convert is successful, false otherwise. If the conversion fails, the original value is not modified.
+ */
+ bool ConvertType(const Property::Type targetType);
+
/**
* @brief Retrieves a specific value.
*
Name: dali2
Summary: DALi 3D Engine
-Version: 2.3.41
+Version: 2.3.42
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT