#define DALI_INTERNAL_RENDER_GEOMETRY_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
* limitations under the License.
*/
-#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/rendering/geometry.h>
+// INTERNAL INCLUDES
#include <dali/devel-api/common/owner-container.h>
-#include <dali/internal/common/owner-pointer.h>
+#include <dali/graphics-api/graphics-controller.h>
+#include <dali/graphics-api/graphics-types.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/common/owner-pointer.h>
-#include <dali/integration-api/gl-abstraction.h>
-#include <dali/integration-api/gl-defines.h>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/rendering/geometry.h>
namespace Dali
{
namespace Internal
{
-class Context;
class Program;
class GpuBuffer;
namespace Render
{
-class PropertyBuffer;
+class VertexBuffer;
/**
* This class encapsulates the GPU buffers. It is used to upload vertex data
class Geometry
{
public:
- typedef Dali::Geometry::Type Type;
+ using Type = Dali::Geometry::Type;
+ using IndexType = Dali::Graphics::Format;
+
+ using Uint16ContainerType = Dali::Vector<uint16_t>;
+ using Uint32ContainerType = Dali::Vector<uint32_t>;
Geometry();
~Geometry();
/**
- * Called on Gl Context created
- */
- void GlContextCreated( Context& context );
-
- /**
- * Called on Gl Context destroyed.
- */
- void GlContextDestroyed();
-
- /**
* Adds a property buffer to the geometry
- * @param[in] dataProvider The PropertyBuffer data provider
+ * @param[in] dataProvider The VertexBuffer data provider
*/
- void AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer );
+ void AddVertexBuffer(Render::VertexBuffer* vertexBuffer);
/**
* Set the data for the index buffer to be used by the geometry
* @param[in] indices A vector containing the indices
*/
- void SetIndexBuffer( Dali::Vector<unsigned short>& indices );
+ void SetIndexBuffer(Uint16ContainerType& indices);
/**
- * Obtains pointer to the storage of indexed elements
- * @return Pointer to the index buffer
- */
- const Dali::Vector<unsigned short>* GetIndexBuffer() const;
-
- /**
- * Removes a PropertyBuffer from the geometry
- * @param[in] propertyBuffer The property buffer to be removed
+ * Set the data for the index buffer to be used by the geometry
+ * @param[in] indices A vector containing the indices
*/
- void RemovePropertyBuffer( const Render::PropertyBuffer* propertyBuffer );
+ void SetIndexBuffer(Uint32ContainerType& indices);
/**
- * Returns property buffer at specified index
- * @param[in] index of the property buffer
- * @return pointer to the property buffer or NULL
+ * Removes a VertexBuffer from the geometry
+ * @param[in] vertexBuffer The property buffer to be removed
*/
- const Render::PropertyBuffer* GetPropertyBuffer( size_t index ) const;
+ void RemoveVertexBuffer(const Render::VertexBuffer* vertexBuffer);
/**
- * Gets the attribute locations on the shader for the attributes defined in the geometry RenderBuffers
- * @param[out] attributeLocation The vector where the attributes locations will be stored
- * @param[in] program The program
- * @param[in] bufferIndex The current buffer index
+ * Get the vertex buffers
+ * @return the list of vertex buffers
*/
- void GetAttributeLocationFromProgram( Vector<GLint>& attributeLocation, Program& program, BufferIndex bufferIndex ) const;
+ [[nodiscard]] const Vector<Render::VertexBuffer*>& GetVertexBuffers() const;
/**
* Called from RenderManager to notify the geometry that current rendering pass has finished.
void OnRenderFinished();
/**
- * Chack if the attributes for the geometry have changed
+ * Check if the attributes for the geometry have changed
* @return True if vertex buffers have been added or removed since last frame, false otherwise
*/
- bool AttributesChanged() const
+ [[maybe_unused]] [[nodiscard]] bool AttributesChanged() const
{
return mAttributesChanged;
}
* Sets the geometry type
* @param[in] type The new geometry type
*/
- void SetType( Type type )
+ void SetType(Type type)
{
mGeometryType = type;
}
/**
- * Upload the geometry if it has changed, set up the attributes and perform
- * the Draw call corresponding to the geometry type
- * @param[in] context The GL context
- * @param[in] bufferIndex The current buffer index
- * @param[in] attributeLocation The location for the attributes in the shader
+ * @return the topology of this geometry
+ */
+ [[nodiscard]] Graphics::PrimitiveTopology GetTopology() const;
+
+ /**
+ * Upload the geometry if it has changed
+ */
+ void Upload(Graphics::Controller& graphicsController);
+
+ /**
+ * Set up the attributes and perform the Draw call corresponding to the geometry type.
+ *
+ * @param[in] graphicsController The graphics controller
+ * @param[in,out] commandBuffer The current command buffer queue
* @param[in] elementBufferOffset The index of first element to draw if index buffer bound
* @param[in] elementBufferCount Number of elements to draw if index buffer bound, uses whole buffer when 0
+ * @return true if the draw command was issued, false otherwise
*/
- void UploadAndDraw(Context& context,
- BufferIndex bufferIndex,
- Vector<GLint>& attributeLocation,
- size_t elementBufferOffset,
- size_t elementBufferCount );
+ bool Draw(Graphics::Controller& graphicsController,
+ Graphics::CommandBuffer& commandBuffer,
+ uint32_t elementBufferOffset,
+ uint32_t elementBufferCount);
-private:
+ /**
+ * @brief Set up the attributes bind commaneds
+ *
+ * @param[in,out] commandBuffer The current command buffer queue
+ * @return true if the bind command was issued, false otherwise
+ */
+ bool BindVertexAttributes(Graphics::CommandBuffer& commandBuffer);
- // PropertyBuffers
- Vector< Render::PropertyBuffer* > mVertexBuffers;
+private:
+ // VertexBuffers
+ Vector<Render::VertexBuffer*> mVertexBuffers;
- Dali::Vector< unsigned short> mIndices;
- OwnerPointer< GpuBuffer > mIndexBuffer;
- Type mGeometryType;
+ Uint16ContainerType mIndices;
+ OwnerPointer<GpuBuffer> mIndexBuffer;
+ IndexType mIndexType;
+ Type mGeometryType;
// Booleans
bool mIndicesChanged : 1;