1 #ifndef DALI_INTERNAL_RENDER_GEOMETRY_H
2 #define DALI_INTERNAL_RENDER_GEOMETRY_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.
21 #include <dali/devel-api/common/owner-container.h>
22 #include <dali/graphics-api/graphics-controller.h>
23 #include <dali/graphics-api/graphics-types.h>
24 #include <dali/internal/common/buffer-index.h>
25 #include <dali/internal/common/owner-pointer.h>
26 #include <dali/public-api/common/dali-vector.h>
27 #include <dali/public-api/rendering/geometry.h>
41 * This class encapsulates the GPU buffers. It is used to upload vertex data
42 * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute
48 using Type = Dali::Geometry::Type;
49 using IndexType = Dali::Graphics::Format;
51 using Uint16ContainerType = Dali::Vector<uint16_t>;
52 using Uint32ContainerType = Dali::Vector<uint32_t>;
62 * Adds a property buffer to the geometry
63 * @param[in] dataProvider The VertexBuffer data provider
65 void AddVertexBuffer(Render::VertexBuffer* vertexBuffer);
68 * Set the data for the index buffer to be used by the geometry
69 * @param[in] indices A vector containing the indices
71 void SetIndexBuffer(Uint16ContainerType& indices);
74 * Set the data for the index buffer to be used by the geometry
75 * @param[in] indices A vector containing the indices
77 void SetIndexBuffer(Uint32ContainerType& indices);
80 * Removes a VertexBuffer from the geometry
81 * @param[in] vertexBuffer The property buffer to be removed
83 void RemoveVertexBuffer(const Render::VertexBuffer* vertexBuffer);
86 * Get the vertex buffers
87 * @return the list of vertex buffers
89 [[nodiscard]] const Vector<Render::VertexBuffer*>& GetVertexBuffers() const;
92 * Called from RenderManager to notify the geometry that current rendering pass has finished.
94 void OnRenderFinished();
97 * Check if the attributes for the geometry have changed
98 * @return True if vertex buffers have been added or removed since last frame, false otherwise
100 [[maybe_unused]] [[nodiscard]] bool AttributesChanged() const
102 return mAttributesChanged;
106 * Sets the geometry type
107 * @param[in] type The new geometry type
109 void SetType(Type type)
111 mGeometryType = type;
115 * @return the topology of this geometry
117 [[nodiscard]] Graphics::PrimitiveTopology GetTopology() const;
120 * Upload the geometry if it has changed
122 void Upload(Graphics::Controller& graphicsController);
125 * Set up the attributes and perform the Draw call corresponding to the geometry type.
127 * @param[in] graphicsController The graphics controller
128 * @param[in] bufferIndex The current buffer index
129 * @param[in] elementBufferOffset The index of first element to draw if index buffer bound
130 * @param[in] elementBufferCount Number of elements to draw if index buffer bound, uses whole buffer when 0
131 * @return true if the draw command was issued, false otherwise
133 bool Draw(Graphics::Controller& graphicsController,
134 Graphics::CommandBuffer& commandBuffer,
135 uint32_t elementBufferOffset,
136 uint32_t elementBufferCount);
140 Vector<Render::VertexBuffer*> mVertexBuffers;
142 Uint16ContainerType mIndices;
143 OwnerPointer<GpuBuffer> mIndexBuffer;
144 IndexType mIndexType;
148 bool mIndicesChanged : 1;
149 bool mHasBeenUpdated : 1;
150 bool mAttributesChanged : 1;
153 } // namespace Render
154 } // namespace Internal
157 #endif // DALI_INTERNAL_RENDER_GEOMETRY_H