1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_PROCESSOR_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_PROCESSOR_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/internal/common/buffer-index.h>
25 #include <dali/internal/render/common/render-item-key.h>
26 #include <dali/internal/update/manager/sorted-layers.h>
44 class RenderInstructionContainer;
47 * @brief This class handles the sorting and preparation of Renderers for each layer.
49 class RenderInstructionProcessor
55 RenderInstructionProcessor();
60 ~RenderInstructionProcessor();
63 * @brief Structure to store information for sorting the renderers.
64 * (Note, depthIndex is stored within the renderItem).
77 RenderItemKey renderItem; ///< The render item that is being sorted (includes depth index)
78 const Shader* shader; ///< The shader instance
79 const void* textureSet; ///< The textureSet instance
80 const Render::Geometry* geometry; ///< The geometry instance
81 float zValue; ///< The Z value of the given renderer (either distance from camera, or a custom calculated value)
85 * @brief Sorts and prepares the list of opaque/transparent Renderers for each layer.
86 * Whilst iterating through each layer, update the RenderItems ModelView matrices
88 * The opaque and transparent render lists are sorted first by depth
89 * index, then by Z (for transparent only), then by shader
90 * and geometry. The render algorithm should then work through both
91 * lists simultaneously, working through opaque then transparent
92 * items at each depth index, resetting the flags appropriately.
94 * @param[in] updateBufferIndex The current update buffer index.
95 * @param[in] sortedLayers The layers containing lists of opaque/transparent renderables.
96 * @param[in] renderTask The rendering task information.
97 * @param[in] cull Whether frustum culling is enabled or not
98 * @param[in] hasClippingNodes Whether any clipping nodes exist within this layer, to optimize sorting if not
99 * @param[out] instructions The rendering instructions for the next frame.
101 void Prepare(BufferIndex updateBufferIndex,
102 SortedLayerPointers& sortedLayers,
103 RenderTask& renderTask,
105 bool hasClippingNodes,
106 RenderInstructionContainer& instructions);
110 * Undefine copy and assignment operators.
112 RenderInstructionProcessor(const RenderInstructionProcessor& renderInstructionProcessor); ///< No definition
113 RenderInstructionProcessor& operator=(const RenderInstructionProcessor& renderInstructionProcessor); ///< No definition
117 * @brief Sort render items
118 * @param bufferIndex The buffer to read from
119 * @param renderList to sort
120 * @param layer where the Renderers are from
121 * @param respectClippingOrder Sort with the correct clipping hierarchy.
122 * @param isOrthographicCamera Whether the camera is orthographic or not.
124 inline void SortRenderItems(BufferIndex bufferIndex, RenderList& renderList, Layer& layer, bool respectClippingOrder, bool isOrthographicCamera);
126 /// Sort comparitor function pointer type.
127 using ComparitorPointer = bool (*)(const SortAttributes&, const SortAttributes&);
129 using SortingHelper = std::vector<SortAttributes>;
131 Dali::Vector<ComparitorPointer> mSortComparitors; ///< Contains all sort comparitors, used for quick look-up
132 RenderInstructionProcessor::SortingHelper mSortingHelper; ///< Helper used to sort Renderers
135 } // namespace SceneGraph
137 } // namespace Internal
141 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_PROCESSOR_H