d021083df6b3d7974ca3e505188b39eb5c9d5b4e
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / render-instruction-processor.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/update/manager/render-instruction-processor.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/internal/event/actors/layer-impl.h> // for the default sorting function
24 #include <dali/internal/render/common/render-instruction-container.h>
25 #include <dali/internal/render/common/render-instruction.h>
26 #include <dali/internal/render/common/render-item.h>
27 #include <dali/internal/render/common/render-tracker.h>
28 #include <dali/internal/render/renderers/render-renderer.h>
29 #include <dali/internal/render/shaders/render-shader.h>
30 #include <dali/internal/update/manager/sorted-layers.h>
31 #include <dali/internal/update/nodes/scene-graph-layer.h>
32 #include <dali/internal/update/render-tasks/scene-graph-render-task.h>
33 #include <dali/internal/update/rendering/scene-graph-texture-set.h>
34 #include <dali/public-api/actors/layer.h>
35
36 namespace
37 {
38 #if defined(DEBUG_ENABLED)
39 Debug::Filter* gRenderListLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_RENDER_LISTS");
40 #endif
41 } // namespace
42
43 namespace Dali
44 {
45 namespace Internal
46 {
47 namespace SceneGraph
48 {
49 namespace
50 {
51 /**
52  * Function which compares render items by shader/textureSet/geometry
53  * @param[in] lhs Left hand side item
54  * @param[in] rhs Right hand side item
55  * @return True if left item is greater than right
56  */
57 inline bool PartialCompareItems(const RenderInstructionProcessor::SortAttributes& lhs,
58                                 const RenderInstructionProcessor::SortAttributes& rhs)
59 {
60   if(lhs.shader == rhs.shader)
61   {
62     if(lhs.textureSet == rhs.textureSet)
63     {
64       return lhs.geometry < rhs.geometry;
65     }
66     return lhs.textureSet < rhs.textureSet;
67   }
68   return lhs.shader < rhs.shader;
69 }
70
71 /**
72  * Function which sorts render items by depth index then by instance
73  * ptrs of shader/textureSet/geometry.
74  * @param[in] lhs Left hand side item
75  * @param[in] rhs Right hand side item
76  * @return True if left item is greater than right
77  */
78 bool CompareItems(const RenderInstructionProcessor::SortAttributes& lhs, const RenderInstructionProcessor::SortAttributes& rhs)
79 {
80   // @todo Consider replacing all these sortAttributes with a single long int that
81   // encapsulates the same data (e.g. the middle-order bits of the ptrs).
82   if(lhs.renderItem->mDepthIndex == rhs.renderItem->mDepthIndex)
83   {
84     return PartialCompareItems(lhs, rhs);
85   }
86   return lhs.renderItem->mDepthIndex < rhs.renderItem->mDepthIndex;
87 }
88
89 /**
90  * Function which sorts the render items by Z function, then
91  * by instance ptrs of shader / geometry / material.
92  * @param[in] lhs Left hand side item
93  * @param[in] rhs Right hand side item
94  * @return True if left item is greater than right
95  */
96 bool CompareItems3D(const RenderInstructionProcessor::SortAttributes& lhs, const RenderInstructionProcessor::SortAttributes& rhs)
97 {
98   const bool lhsIsOpaque = lhs.renderItem->mIsOpaque;
99   if(lhsIsOpaque == rhs.renderItem->mIsOpaque)
100   {
101     if(lhsIsOpaque)
102     {
103       // If both RenderItems are opaque, sort using shader, then material then geometry.
104       return PartialCompareItems(lhs, rhs);
105     }
106     else
107     {
108       // If both RenderItems are transparent, sort using Z, then shader, then material, then geometry.
109       if(Equals(lhs.zValue, rhs.zValue))
110       {
111         return PartialCompareItems(lhs, rhs);
112       }
113       return lhs.zValue > rhs.zValue;
114     }
115   }
116   else
117   {
118     return lhsIsOpaque;
119   }
120 }
121
122 /**
123  * Function which sorts render items by clipping hierarchy, then Z function and instance ptrs of shader / geometry / material.
124  * @param[in] lhs Left hand side item
125  * @param[in] rhs Right hand side item
126  * @return True if left item is greater than right
127  */
128 bool CompareItems3DWithClipping(const RenderInstructionProcessor::SortAttributes& lhs, const RenderInstructionProcessor::SortAttributes& rhs)
129 {
130   // Items must be sorted in order of clipping first, otherwise incorrect clipping regions could be used.
131   if(lhs.renderItem->mNode->mClippingSortModifier == rhs.renderItem->mNode->mClippingSortModifier)
132   {
133     return CompareItems3D(lhs, rhs);
134   }
135
136   return lhs.renderItem->mNode->mClippingSortModifier < rhs.renderItem->mNode->mClippingSortModifier;
137 }
138
139 /**
140  * Set the update size of the node
141  * @param[in] node The node of the renderer
142  * @param[in] isLayer3d Whether we are processing a 3D layer or not
143  * @param[in,out] nodeWorldMatrix The world matrix of the node
144  * @param[in,out] nodeSize The size of the node
145  * @param[in,out] nodeUpdateSize The update size of the node
146  */
147 inline void SetNodeUpdateSize(Node* node, bool isLayer3d, Matrix& nodeWorldMatrix, Vector3& nodeSize, Vector3& nodeUpdateSize)
148 {
149   node->GetWorldMatrixAndSize(nodeWorldMatrix, nodeSize);
150
151   if(node->GetUpdateSizeHint() == Vector3::ZERO)
152   {
153     // RenderItem::CalculateViewportSpaceAABB cannot cope with z transform
154     // I don't use item.mModelMatrix.GetTransformComponents() for z transform, would be too slow
155     if(!isLayer3d && nodeWorldMatrix.GetZAxis() == Vector3(0.0f, 0.0f, 1.0f))
156     {
157       nodeUpdateSize = nodeSize;
158     }
159   }
160   else
161   {
162     nodeUpdateSize = node->GetUpdateSizeHint();
163   }
164 }
165
166 /**
167  * Add a renderer to the list
168  * @param updateBufferIndex to read the model matrix from
169  * @param renderList to add the item to
170  * @param renderable Node-Renderer pair
171  * @param viewMatrix used to calculate modelview matrix for the item
172  * @param camera The camera used to render
173  * @param isLayer3d Whether we are processing a 3D layer or not
174  * @param viewportSet Whether the viewport is set or not
175  * @param viewport The viewport
176  * @param cull Whether frustum culling is enabled or not
177  */
178 inline void AddRendererToRenderList(BufferIndex         updateBufferIndex,
179                                     RenderList&         renderList,
180                                     Renderable&         renderable,
181                                     const Matrix&       viewMatrix,
182                                     SceneGraph::Camera& camera,
183                                     bool                isLayer3d,
184                                     bool                viewportSet,
185                                     const Viewport&     viewport,
186                                     bool                cull)
187 {
188   bool    inside(true);
189   Node*   node = renderable.mNode;
190   Matrix  nodeWorldMatrix(false);
191   Vector3 nodeSize;
192   Vector3 nodeUpdateSize;
193   bool    nodeUpdateSizeSet(false);
194   Matrix  nodeModelViewMatrix(false);
195   bool    nodeModelViewMatrixSet(false);
196
197   // Don't cull items which have render callback
198   bool hasRenderCallback = (renderable.mRenderer && renderable.mRenderer->GetRenderCallback());
199
200   if(cull && renderable.mRenderer && (hasRenderCallback || (!renderable.mRenderer->GetShader().HintEnabled(Dali::Shader::Hint::MODIFIES_GEOMETRY) && node->GetClippingMode() == ClippingMode::DISABLED)))
201   {
202     const Vector4& boundingSphere = node->GetBoundingSphere();
203     inside                        = (boundingSphere.w > Math::MACHINE_EPSILON_1000) &&
204              (camera.CheckSphereInFrustum(updateBufferIndex, Vector3(boundingSphere), boundingSphere.w));
205
206     if(inside && !isLayer3d && viewportSet)
207     {
208       SetNodeUpdateSize(node, isLayer3d, nodeWorldMatrix, nodeSize, nodeUpdateSize);
209       nodeUpdateSizeSet = true;
210
211       const Vector3& scale = node->GetWorldScale(updateBufferIndex);
212       const Vector3& size  = nodeUpdateSize * scale;
213
214       if(size.LengthSquared() > Math::MACHINE_EPSILON_1000)
215       {
216         Matrix::Multiply(nodeModelViewMatrix, nodeWorldMatrix, viewMatrix);
217         nodeModelViewMatrixSet = true;
218
219         // Assume actors are at z=0, compute AABB in view space & test rect intersection
220         // against z=0 plane boundaries for frustum. (NOT viewport). This should take into account
221         // magnification due to FOV etc.
222         ClippingBox boundingBox = RenderItem::CalculateTransformSpaceAABB(nodeModelViewMatrix, nodeUpdateSize);
223         ClippingBox clippingBox(camera.mLeftClippingPlane, camera.mBottomClippingPlane, camera.mRightClippingPlane - camera.mLeftClippingPlane, fabsf(camera.mBottomClippingPlane - camera.mTopClippingPlane));
224         inside = clippingBox.Intersects(boundingBox);
225       }
226     }
227     /*
228      * Note, the API Camera::CheckAABBInFrustum() can be used to test if a bounding box is (partially/fully) inside the view frustum.
229      */
230   }
231
232   if(inside)
233   {
234     bool skipRender(false);
235     bool isOpaque = true;
236     if(!hasRenderCallback)
237     {
238       Renderer::OpacityType opacityType = renderable.mRenderer ? renderable.mRenderer->GetOpacityType(updateBufferIndex, *node) : Renderer::OPAQUE;
239
240       // We can skip render when node is not clipping and transparent
241       skipRender = (opacityType == Renderer::TRANSPARENT && node->GetClippingMode() == ClippingMode::DISABLED);
242
243       isOpaque = (opacityType == Renderer::OPAQUE);
244     }
245
246     if(!skipRender)
247     {
248       // Get the next free RenderItem.
249       RenderItem& item = renderList.GetNextFreeItem();
250
251       // Get cached values
252       auto& partialRenderingData = node->GetPartialRenderingData();
253
254       auto& partialRenderingCacheInfo = node->GetPartialRenderingData().GetCurrentCacheInfo();
255
256       partialRenderingCacheInfo.node       = node;
257       partialRenderingCacheInfo.isOpaque   = isOpaque;
258       partialRenderingCacheInfo.renderer   = renderable.mRenderer;
259       partialRenderingCacheInfo.color      = node->GetWorldColor(updateBufferIndex);
260       partialRenderingCacheInfo.depthIndex = node->GetDepthIndex();
261
262       if(DALI_LIKELY(renderable.mRenderer))
263       {
264         partialRenderingCacheInfo.textureSet = renderable.mRenderer->GetTextureSet();
265       }
266
267       item.mNode     = node;
268       item.mIsOpaque = isOpaque;
269       item.mColor    = node->GetColor(updateBufferIndex);
270
271       item.mDepthIndex = 0;
272       if(!isLayer3d)
273       {
274         item.mDepthIndex = node->GetDepthIndex();
275       }
276
277       if(DALI_LIKELY(renderable.mRenderer))
278       {
279         item.mRenderer   = &renderable.mRenderer->GetRenderer();
280         item.mTextureSet = renderable.mRenderer->GetTextureSet();
281         item.mDepthIndex += renderable.mRenderer->GetDepthIndex();
282
283         // Ensure collected map is up to date
284         item.mIsUpdated |= renderable.mRenderer->UpdateUniformMap();
285       }
286       else
287       {
288         item.mRenderer = nullptr;
289       }
290
291       item.mIsUpdated |= isLayer3d;
292
293       if(!nodeUpdateSizeSet)
294       {
295         SetNodeUpdateSize(node, isLayer3d, nodeWorldMatrix, nodeSize, nodeUpdateSize);
296       }
297
298       item.mSize        = nodeSize;
299       item.mUpdateSize  = nodeUpdateSize;
300       item.mModelMatrix = nodeWorldMatrix;
301
302       if(!nodeModelViewMatrixSet)
303       {
304         Matrix::Multiply(nodeModelViewMatrix, nodeWorldMatrix, viewMatrix);
305       }
306       item.mModelViewMatrix = nodeModelViewMatrix;
307
308       partialRenderingCacheInfo.matrix      = item.mModelViewMatrix;
309       partialRenderingCacheInfo.size        = item.mSize;
310       partialRenderingCacheInfo.updatedSize = item.mUpdateSize;
311
312       item.mIsUpdated = partialRenderingData.IsUpdated() || item.mIsUpdated;
313
314       partialRenderingData.mRendered = true;
315
316       partialRenderingData.SwapBuffers();
317     }
318     else
319     {
320       // Mark as not rendered
321       auto& partialRenderingData     = node->GetPartialRenderingData();
322       partialRenderingData.mRendered = false;
323     }
324
325     node->SetCulled(updateBufferIndex, false);
326   }
327   else
328   {
329     // Mark as not rendered
330     auto& partialRenderingData     = node->GetPartialRenderingData();
331     partialRenderingData.mRendered = false;
332
333     node->SetCulled(updateBufferIndex, true);
334   }
335 }
336
337 /**
338  * Add all renderers to the list
339  * @param updateBufferIndex to read the model matrix from
340  * @param renderList to add the items to
341  * @param renderers to render
342  * NodeRendererContainer Node-Renderer pairs
343  * @param viewMatrix used to calculate modelview matrix for the items
344  * @param camera The camera used to render
345  * @param isLayer3d Whether we are processing a 3D layer or not
346  * @param cull Whether frustum culling is enabled or not
347  */
348 inline void AddRenderersToRenderList(BufferIndex          updateBufferIndex,
349                                      RenderList&          renderList,
350                                      RenderableContainer& renderers,
351                                      const Matrix&        viewMatrix,
352                                      SceneGraph::Camera&  camera,
353                                      bool                 isLayer3d,
354                                      bool                 viewportSet,
355                                      const Viewport&      viewport,
356                                      bool                 cull)
357 {
358   DALI_LOG_INFO(gRenderListLogFilter, Debug::Verbose, "AddRenderersToRenderList()\n");
359
360   for(auto&& renderer : renderers)
361   {
362     AddRendererToRenderList(updateBufferIndex,
363                             renderList,
364                             renderer,
365                             viewMatrix,
366                             camera,
367                             isLayer3d,
368                             viewportSet,
369                             viewport,
370                             cull);
371   }
372 }
373
374 /**
375  * Try to reuse cached RenderItems from the RenderList
376  * This avoids recalculating the model view matrices in case this part of the scene was static
377  * An example case is a toolbar layer that rarely changes or a popup on top of the rest of the stage
378  * @param layer that is being processed
379  * @param renderList that is cached from frame N-1
380  * @param renderables list of renderables
381  */
382 inline bool TryReuseCachedRenderers(Layer&               layer,
383                                     RenderList&          renderList,
384                                     RenderableContainer& renderables)
385 {
386   bool     retValue        = false;
387   uint32_t renderableCount = static_cast<uint32_t>(renderables.Size());
388   // Check that the cached list originates from this layer and that the counts match
389   if((renderList.GetSourceLayer() == &layer) &&
390      (renderList.GetCachedItemCount() == renderableCount))
391   {
392     // Check that all the same renderers are there. This gives us additional security in avoiding rendering the wrong things.
393     // Render list is sorted so at this stage renderers may be in different order.
394     // Therefore we check a combined sum of all renderer addresses.
395     size_t checkSumNew = 0;
396     size_t checkSumOld = 0;
397     for(uint32_t index = 0; index < renderableCount; ++index)
398     {
399       if(DALI_LIKELY(renderables[index].mRenderer))
400       {
401         const Render::Renderer& renderer = renderables[index].mRenderer->GetRenderer();
402         checkSumNew += reinterpret_cast<std::size_t>(&renderer);
403       }
404       if(DALI_LIKELY(renderList.GetItem(index).mRenderer))
405       {
406         checkSumOld += reinterpret_cast<std::size_t>(&renderList.GetRenderer(index));
407       }
408     }
409     if(checkSumNew == checkSumOld)
410     {
411       // tell list to reuse its existing items
412       renderList.ReuseCachedItems();
413       retValue = true;
414     }
415   }
416
417   return retValue;
418 }
419
420 inline bool SetupRenderList(RenderableContainer& renderables,
421                             Layer&               layer,
422                             RenderInstruction&   instruction,
423                             bool                 tryReuseRenderList,
424                             RenderList**         renderList)
425 {
426   *renderList = &(instruction.GetNextFreeRenderList(renderables.Size()));
427   (*renderList)->SetClipping(layer.IsClipping(), layer.GetClippingBox());
428   (*renderList)->SetSourceLayer(&layer);
429
430   // Try to reuse cached RenderItems from last time around.
431   return (tryReuseRenderList && TryReuseCachedRenderers(layer, **renderList, renderables));
432 }
433
434 } // Anonymous namespace.
435
436 RenderInstructionProcessor::RenderInstructionProcessor()
437 : mSortingHelper()
438 {
439   // Set up a container of comparators for fast run-time selection.
440   mSortComparitors.Reserve(3u);
441
442   mSortComparitors.PushBack(CompareItems);
443   mSortComparitors.PushBack(CompareItems3D);
444   mSortComparitors.PushBack(CompareItems3DWithClipping);
445 }
446
447 RenderInstructionProcessor::~RenderInstructionProcessor() = default;
448
449 inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex, RenderList& renderList, Layer& layer, bool respectClippingOrder)
450 {
451   const uint32_t renderableCount = static_cast<uint32_t>(renderList.Count());
452   // Reserve space if needed.
453   const uint32_t oldcapacity = static_cast<uint32_t>(mSortingHelper.size());
454   if(oldcapacity < renderableCount)
455   {
456     mSortingHelper.reserve(renderableCount);
457     // Add real objects (reserve does not construct objects).
458     mSortingHelper.insert(mSortingHelper.begin() + oldcapacity,
459                           (renderableCount - oldcapacity),
460                           RenderInstructionProcessor::SortAttributes());
461   }
462   else
463   {
464     // Clear extra elements from helper, does not decrease capability.
465     mSortingHelper.resize(renderableCount);
466   }
467
468   // Calculate the sorting value, once per item by calling the layers sort function.
469   // Using an if and two for-loops rather than if inside for as its better for branch prediction.
470   if(layer.UsesDefaultSortFunction())
471   {
472     for(uint32_t index = 0; index < renderableCount; ++index)
473     {
474       RenderItem& item = renderList.GetItem(index);
475
476       if(DALI_LIKELY(item.mRenderer))
477       {
478         item.mRenderer->SetSortAttributes(mSortingHelper[index]);
479       }
480
481       // texture set
482       mSortingHelper[index].textureSet = item.mTextureSet;
483
484       // The default sorting function should get inlined here.
485       mSortingHelper[index].zValue = Internal::Layer::ZValue(item.mModelViewMatrix.GetTranslation3()) - static_cast<float>(item.mDepthIndex);
486
487       // Keep the renderitem pointer in the helper so we can quickly reorder items after sort.
488       mSortingHelper[index].renderItem = &item;
489     }
490   }
491   else
492   {
493     const Dali::Layer::SortFunctionType sortFunction = layer.GetSortFunction();
494     for(uint32_t index = 0; index < renderableCount; ++index)
495     {
496       RenderItem& item = renderList.GetItem(index);
497
498       if(DALI_LIKELY(item.mRenderer))
499       {
500         item.mRenderer->SetSortAttributes(mSortingHelper[index]);
501       }
502
503       // texture set
504       mSortingHelper[index].textureSet = item.mTextureSet;
505
506       mSortingHelper[index].zValue = (*sortFunction)(item.mModelViewMatrix.GetTranslation3()) - static_cast<float>(item.mDepthIndex);
507
508       // Keep the RenderItem pointer in the helper so we can quickly reorder items after sort.
509       mSortingHelper[index].renderItem = &item;
510     }
511   }
512
513   // Here we determine which comparitor (of the 3) to use.
514   //   0 is LAYER_UI
515   //   1 is LAYER_3D
516   //   2 is LAYER_3D + Clipping
517   const unsigned int comparitorIndex = layer.GetBehavior() == Dali::Layer::LAYER_3D ? respectClippingOrder ? 2u : 1u : 0u;
518
519   std::stable_sort(mSortingHelper.begin(), mSortingHelper.end(), mSortComparitors[comparitorIndex]);
520
521   // Reorder / re-populate the RenderItems in the RenderList to correct order based on the sortinghelper.
522   DALI_LOG_INFO(gRenderListLogFilter, Debug::Verbose, "Sorted Transparent List:\n");
523   RenderItemContainer::Iterator renderListIter = renderList.GetContainer().Begin();
524   for(uint32_t index = 0; index < renderableCount; ++index, ++renderListIter)
525   {
526     *renderListIter = mSortingHelper[index].renderItem;
527     DALI_LOG_INFO(gRenderListLogFilter, Debug::Verbose, "  sortedList[%d] = %p\n", index, mSortingHelper[index].renderItem->mRenderer);
528   }
529 }
530
531 void RenderInstructionProcessor::Prepare(BufferIndex                 updateBufferIndex,
532                                          SortedLayerPointers&        sortedLayers,
533                                          RenderTask&                 renderTask,
534                                          bool                        cull,
535                                          bool                        hasClippingNodes,
536                                          RenderInstructionContainer& instructions)
537 {
538   // Retrieve the RenderInstruction buffer from the RenderInstructionContainer
539   // then populate with instructions.
540   RenderInstruction& instruction             = renderTask.PrepareRenderInstruction(updateBufferIndex);
541   bool               viewMatrixHasNotChanged = !renderTask.ViewMatrixUpdated();
542   bool               isRenderListAdded       = false;
543   bool               isRootLayerDirty        = false;
544
545   const Matrix&       viewMatrix = renderTask.GetViewMatrix(updateBufferIndex);
546   SceneGraph::Camera& camera     = renderTask.GetCamera();
547
548   Viewport viewport;
549   bool     viewportSet = renderTask.QueryViewport(updateBufferIndex, viewport);
550
551   const SortedLayersIter endIter = sortedLayers.end();
552   for(SortedLayersIter iter = sortedLayers.begin(); iter != endIter; ++iter)
553   {
554     Layer&      layer = **iter;
555     const bool  tryReuseRenderList(viewMatrixHasNotChanged && layer.CanReuseRenderers(&renderTask.GetCamera()));
556     const bool  isLayer3D  = layer.GetBehavior() == Dali::Layer::LAYER_3D;
557     RenderList* renderList = nullptr;
558
559     if(layer.IsRoot() && (layer.GetDirtyFlags() != NodePropertyFlags::NOTHING))
560     {
561       // If root-layer & dirty, i.e. a property has changed or a child has been deleted, then we need to ensure we render once more
562       isRootLayerDirty = true;
563     }
564
565     if(!layer.colorRenderables.Empty())
566     {
567       RenderableContainer& renderables = layer.colorRenderables;
568
569       if(!SetupRenderList(renderables, layer, instruction, tryReuseRenderList, &renderList))
570       {
571         renderList->SetHasColorRenderItems(true);
572         AddRenderersToRenderList(updateBufferIndex,
573                                  *renderList,
574                                  renderables,
575                                  viewMatrix,
576                                  camera,
577                                  isLayer3D,
578                                  viewportSet,
579                                  viewport,
580                                  cull);
581
582         // We only use the clipping version of the sort comparitor if any clipping nodes exist within the RenderList.
583         SortRenderItems(updateBufferIndex, *renderList, layer, hasClippingNodes);
584       }
585
586       isRenderListAdded = true;
587     }
588
589     if(!layer.overlayRenderables.Empty())
590     {
591       RenderableContainer& renderables = layer.overlayRenderables;
592
593       if(!SetupRenderList(renderables, layer, instruction, tryReuseRenderList, &renderList))
594       {
595         renderList->SetHasColorRenderItems(false);
596         AddRenderersToRenderList(updateBufferIndex,
597                                  *renderList,
598                                  renderables,
599                                  viewMatrix,
600                                  camera,
601                                  isLayer3D,
602                                  viewportSet,
603                                  viewport,
604                                  cull);
605
606         // Clipping hierarchy is irrelevant when sorting overlay items, so we specify using the non-clipping version of the sort comparitor.
607         SortRenderItems(updateBufferIndex, *renderList, layer, false);
608       }
609
610       isRenderListAdded = true;
611     }
612   }
613
614   // Inform the render instruction that all renderers have been added and this frame is complete.
615   instruction.UpdateCompleted();
616
617   if(isRenderListAdded || instruction.mIsClearColorSet || isRootLayerDirty)
618   {
619     instructions.PushBack(updateBufferIndex, &instruction);
620   }
621 }
622
623 } // namespace SceneGraph
624
625 } // namespace Internal
626
627 } // namespace Dali