Until now, we try to ask RenderItem->mDepthIndex at comparitor.
Let we make some other way to compair the depth index for the UI layer case.
Change-Id: Ib2e15b85b2e76cd1953bb03b0cf800b0cc65596d
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
Layer root = application.GetScene().GetLayer(0);
gTestSortFunctionCalled = 0;
+
+ // Set the behavior to LAYER_3D and set the sort function
+ root.SetProperty(Layer::Property::BEHAVIOR, Dali::Layer::LAYER_3D);
root.SetSortFunction(TestSortFunction);
// flush the queue and render once
END_TEST;
}
+int UtcDaliLayerSetSortFunctionLayerUI(void)
+{
+ tet_infoline("Testing Dali::Layer::SetSortFunction()");
+ TestApplication application;
+
+ // create two transparent actors so there is something to sort
+ Actor actor = CreateRenderableActor();
+ Actor actor2 = CreateRenderableActor();
+ actor.SetProperty(Actor::Property::SIZE, Vector2(1, 1));
+ actor.SetProperty(Actor::Property::COLOR, Vector4(1, 1, 1, 0.5f)); // 50% transparent
+ actor2.SetProperty(Actor::Property::SIZE, Vector2(1, 1));
+ actor2.SetProperty(Actor::Property::COLOR, Vector4(1, 1, 1, 0.5f)); // 50% transparent
+
+ // add to scene
+ application.GetScene().Add(actor);
+ application.GetScene().Add(actor2);
+
+ Layer root = application.GetScene().GetLayer(0);
+ gTestSortFunctionCalled = 0;
+
+ // Set the sort function
+ root.SetSortFunction(TestSortFunction);
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // The sort function should not be called as the layer is LAYER_UI
+ // Since LAYER_UI don't use the sort function.
+ DALI_TEST_CHECK(gTestSortFunctionCalled == 0);
+ END_TEST;
+}
+
int UtcDaliLayerRaiseAbove(void)
{
tet_infoline("Testing Dali::Layer::RaiseAbove()");
const auto nodeChangeCounter = nodePtr ? uniformMapNode.GetChangeCounter() : 0;
const auto renderItemMapChangeCounter = uniformMap.GetChangeCounter();
- auto iter = std::find_if(mNodeIndexMap.begin(), mNodeIndexMap.end(), [nodePtr, programPtr](RenderItemLookup& element) { return (element.node == nodePtr && element.program == programPtr); });
+ auto iter = std::find_if(mNodeIndexMap.begin(), mNodeIndexMap.end(), [nodePtr, programPtr](RenderItemLookup& element)
+ { return (element.node == nodePtr && element.program == programPtr); });
std::size_t renderItemMapIndex;
if(iter == mNodeIndexMap.end())
}
}
-void Renderer::SetSortAttributes(SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const
-{
- if(!mRenderCallback)
- {
- sortAttributes.shader = &mRenderDataProvider->GetShader();
- sortAttributes.geometry = mGeometry;
- }
- else
- {
- sortAttributes.shader = nullptr;
- sortAttributes.geometry = nullptr;
- }
-}
-
void Renderer::SetShaderChanged(bool value)
{
mShaderChanged = value;
class SceneController;
class Shader;
class NodeDataProvider;
-class RenderInstruction; //for reflection effect
+class RenderInstruction; // for reflection effect
} // namespace SceneGraph
namespace Render
using RendererKey = MemoryPoolKey<Render::Renderer>;
using UboViewContainer = Dali::OwnerContainer<Render::UniformBufferView*>;
-} //namespace Render
-} //namespace Internal
+} // namespace Render
+} // namespace Internal
// Ensure RendererKey can be used in Dali::Vector
template<>
*
* @param[out] sortAttributes
*/
- void SetSortAttributes(SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const;
+ void SetSortAttributes(SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const
+ {
+ if(!mRenderCallback)
+ {
+ sortAttributes.shader = &mRenderDataProvider->GetShader();
+ sortAttributes.geometry = mGeometry;
+ }
+ else
+ {
+ sortAttributes.shader = nullptr;
+ sortAttributes.geometry = nullptr;
+ }
+ }
/**
* Sets the flag indicating whether shader changed.
const SceneGraph::NodeDataProvider* node{nullptr}; ///< Node key. It can be nullptr if this NodeIndex don't need node uniform
const Program* program{nullptr}; ///< Program key.
- std::size_t index{0}; ///<Index into mUniformIndexMap
- std::size_t nodeChangeCounter{0}; ///<The last known change counter for this node's uniform map
+ std::size_t index{0}; ///< Index into mUniformIndexMap
+ std::size_t nodeChangeCounter{0}; ///< The last known change counter for this node's uniform map
std::size_t renderItemMapChangeCounter{0u}; ///< Change counter of the renderer & shader collected uniform map for this render item (node/renderer pair)
};
std::vector<RenderItemLookup> mNodeIndexMap; ///< usually only 1 element.
{
// @todo Consider replacing all these sortAttributes with a single long int that
// encapsulates the same data (e.g. the middle-order bits of the ptrs).
- if(lhs.renderItem->mDepthIndex == rhs.renderItem->mDepthIndex)
+ if(lhs.depthIndex == rhs.depthIndex)
{
return PartialCompareItems(lhs, rhs);
}
- return lhs.renderItem->mDepthIndex < rhs.renderItem->mDepthIndex;
+ return lhs.depthIndex < rhs.depthIndex;
}
/**
// Don't cull items which have render callback
bool hasRenderCallback = (rendererExist && renderable.mRenderer->GetRenderCallback());
- auto requiredInsideCheck = [&]() {
+ auto requiredInsideCheck = [&]()
+ {
if(node != stopperNode &&
cullingEnabled &&
!hasRenderCallback &&
// List of zValue calculating functions.
const Dali::Layer::SortFunctionType zValueFunctionFromVector3[] = {
- [](const Vector3& position) { return position.z; },
- [](const Vector3& position) { return position.LengthSquared(); },
+ [](const Vector3& position)
+ { return position.z; },
+ [](const Vector3& position)
+ { return position.LengthSquared(); },
layer.GetSortFunction(),
};
// 2 is user defined function.
const int zValueFunctionIndex = layer.UsesDefaultSortFunction() ? ((layer.GetBehavior() == Dali::Layer::LAYER_UI || isOrthographicCamera) ? 0 : 1) : 2;
+ // Here we determine which comparitor (of the 3) to use.
+ // 0 is LAYER_UI
+ // 1 is LAYER_3D
+ // 2 is LAYER_3D + Clipping
+ const int comparitorIndex = layer.GetBehavior() == Dali::Layer::LAYER_3D ? respectClippingOrder ? 2u : 1u : 0u;
+
for(uint32_t index = 0; index < renderableCount; ++index)
{
RenderItemKey itemKey = renderList.GetItemKey(index);
RenderItem& item = *itemKey.Get();
+
if(DALI_LIKELY(item.mRenderer))
{
item.mRenderer->SetSortAttributes(mSortingHelper[index]);
// texture set
mSortingHelper[index].textureSet = item.mTextureSet;
- mSortingHelper[index].zValue = zValueFunctionFromVector3[zValueFunctionIndex](item.mModelViewMatrix.GetTranslation3()) - static_cast<float>(item.mDepthIndex);
+ if(comparitorIndex == 0)
+ {
+ // If we are under LAYER_UI, We don't need to get zValue and renderer sort attributes.
+ // Since all render items well-sorted by draw order normally.
+ mSortingHelper[index].depthIndex = item.mDepthIndex;
+ }
+ else
+ {
+ mSortingHelper[index].zValue = zValueFunctionFromVector3[zValueFunctionIndex](item.mModelViewMatrix.GetTranslation3()) - static_cast<float>(item.mDepthIndex);
+ }
// Keep the renderitem pointer in the helper so we can quickly reorder items after sort.
mSortingHelper[index].renderItem = itemKey;
}
- // Here we determine which comparitor (of the 3) to use.
- // 0 is LAYER_UI
- // 1 is LAYER_3D
- // 2 is LAYER_3D + Clipping
- const unsigned int comparitorIndex = layer.GetBehavior() == Dali::Layer::LAYER_3D ? respectClippingOrder ? 2u : 1u : 0u;
-
std::stable_sort(mSortingHelper.begin(), mSortingHelper.end(), mSortComparitors[comparitorIndex]);
// Reorder / re-populate the RenderItems in the RenderList to correct order based on the sortinghelper.
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_PROCESSOR_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
const Shader* shader; ///< The shader instance
const void* textureSet; ///< The textureSet instance
const Render::Geometry* geometry; ///< The geometry instance
- float zValue; ///< The Z value of the given renderer (either distance from camera, or a custom calculated value)
+ union
+ {
+ float zValue; ///< The Z value of the given renderer (either distance from camera, or a custom calculated value)
+ int32_t depthIndex; ///< The depth index of the given render item. Only be used for LAYER_UI
+ };
};
/**