RenderList

Render list interface.

Overview

Typical use cases:

  • Defining a common interface for render list management

Header

<RaeptorCogs/GAPI/Common/Core/RenderList.hpp>

Metadata

Author

Estorc

Version

v1.0

Copyright

Copyright (c) 2025 Estorc MIT License.

Types

Type Definitions

Type

Description

RaeptorCogs::GAPI::Common::BatchBuffer

Graphic batch handler structure.

RaeptorCogs::GAPI::Common::DirtyHandlersBuffer

Dirty handlers buffer.

RaeptorCogs::GAPI::Common::OrderIndicesBuffer

Order indices buffer.

RaeptorCogs::GAPI::Common::RenderListBuffer

Render list buffer type.

using RaeptorCogs::GAPI::Common::BatchBuffer = std::vector<GAPI::Common::GraphicBatchHandler>

Graphic batch handler structure.

Holds information about a graphic batch for rendering.

Note

Used for batching graphics with similar rendering parameters.

using RaeptorCogs::GAPI::Common::DirtyHandlersBuffer = std::vector<std::reference_wrapper<GraphicBatchHandler>>

Dirty handlers buffer.

Holds references to graphic batch handlers that need re-ordering.

Note

Used for tracking graphics that have changed and need to be re-ordered.

using RaeptorCogs::GAPI::Common::OrderIndicesBuffer = std::vector<unsigned int>

Order indices buffer.

Holds the order of indices for rendering.

Note

Used for indirect rendering and reordering.

using RaeptorCogs::GAPI::Common::RenderListBuffer = std::unordered_map<int, RenderList>

Render list buffer type.

Maps integer keys to RenderList instances.

Note

Used for managing multiple render lists.

Enums

Enumerations

Enum

Description

RaeptorCogs::GAPI::Common::RenderListFlags

Render list flags enumeration.

enum class RaeptorCogs::GAPI::Common::RenderListFlags : uint32_t

Render list flags enumeration.

Defines flags for render list state management.

Note

Used for tracking the state of the render list.

Values:

enumerator NONE

No flags set.

enumerator NEEDS_REORDER

Needs reordering.

enumerator REORDERED

Has been reordered.

enumerator SSBO_CREATED

SSBO created.

Structs

Structures

Struct

Description

RaeptorCogs::GAPI::Common::IndirectIterator::OrderedItem

Ordered item structure.

struct OrderedItem

Ordered item structure.

Holds the index and reference to a graphic batch handler.

Note

Used for dereferencing the iterator.

Public Members

size_t index

Index of the ordered item

reference value

Reference to the graphic batch handler

Classes

Classes

Class

Description

RaeptorCogs::GAPI::Common::IndirectIterator

Indirect iterator for render list.

RaeptorCogs::GAPI::Common::RenderList

Render list class.

class IndirectIterator

Indirect iterator for render list.

Provides an iterator to traverse graphic batch handlers in a render list indirectly.

Note

Used for iterating over graphics in a render list based on order indices.

Public Types

using iterator_category = std::forward_iterator_tag

Iterator category for indirect traversal of graphic batch handlers

using difference_type = std::ptrdiff_t

Difference type for iterator

using value_type = GraphicBatchHandler

Value type for iterator

using pointer = GraphicBatchHandler*

Pointer type for iterator

using reference = GraphicBatchHandler&

Reference type for iterator

Public Functions

inline IndirectIterator(BatchBuffer &batch, const OrderIndicesBuffer &order, size_t index)

Constructor for IndirectIterator.

Parameters:
  • batch – Reference to the batch buffer.

  • order – Reference to the order indices buffer.

  • index – Initial index for the iterator.

inline OrderedItem operator*() const

Dereference operator for IndirectIterator.

Returns:

OrderedItem containing the index and reference to the graphic batch handler.

inline pointer operator->() const

Arrow operator for IndirectIterator.

Returns:

Pointer to the graphic batch handler.

inline IndirectIterator &operator++()

Pre-increment operator for IndirectIterator.

Returns:

Reference to the incremented iterator.

inline IndirectIterator operator++(int)

Post-increment operator for IndirectIterator.

Returns:

Copy of the iterator before increment.

inline bool operator==(const IndirectIterator &other) const

Equality operator for IndirectIterator.

Note

Compares the current indices of both iterators.

Parameters:

other – The other IndirectIterator to compare with.

Returns:

true if both iterators are equal, false otherwise.

inline bool operator!=(const IndirectIterator &other) const

Not-equal operator for IndirectIterator.

Note

Compares the current indices of both iterators.

Parameters:

other – The other IndirectIterator to compare with.

Returns:

true if both iterators are not equal, false otherwise.

Private Members

BatchBuffer &batch_

Reference to the batch buffer.

Holds the batch handlers for rendering.

const OrderIndicesBuffer &order_

Reference to the order indices buffer.

Holds the order of indices for rendering.

size_t index_

Current index in the order indices buffer.

Indicates the current position in the iteration.

struct OrderedItem

Ordered item structure.

Holds the index and reference to a graphic batch handler.

Note

Used for dereferencing the iterator.

Public Members

size_t index

Index of the ordered item

reference value

Reference to the graphic batch handler

class RenderList

Render list class.

Manages a list of graphic batch handlers for rendering.

Note

Used for organizing and rendering graphics in batches.

Public Functions

RenderList(BatchBuffer &batch)

Constructor for RenderList.

Note

Initializes the render list with the given batch buffer.

Parameters:

batch – Reference to the batch buffer.

GraphicBatchHandler &getHandler(size_t index)

Get the graphic batch handler at the specified index.

Note

Used for accessing batch handlers directly.

Parameters:

index – Index of the graphic batch handler to retrieve.

Returns:

Reference to the GraphicBatchHandler.

GraphicBatchHandler &getIndirectHandler(size_t index)

Get the graphic batch handler indirectly at the specified index.

Note

Used for accessing batch handlers based on order indices.

Parameters:

index – Index of the graphic batch handler to retrieve.

Returns:

Reference to the GraphicBatchHandler.

GraphicBatchHandler &createHandler(BatchKey key, Graphic2D *graphic, InstanceAllocator &instanceAllocator)

Create a new graphic batch handler.

Parameters:
Returns:

Reference to the created GraphicBatchHandler.

bool empty() const

Check if the render list is empty.

Returns:

true if the render list is empty, false otherwise.

void clear()

Clear the render list.

Note

Removes all graphic batch handlers from the render list.

void erase(GraphicBatchHandler &handler, InstanceAllocator &instanceAllocator)

Erase a graphic batch handler from the render list.

Parameters:
void bind()

Bind the index indirection SSBO.

bool needsReorder() const

Check if reordering is needed.

Returns:

true if reordering is needed, false otherwise.

bool wasReordered() const

Check if the render list was reordered.

Returns:

true if the render list was reordered, false otherwise.

void reorder()

Reorder the render list.

Note

Chooses the appropriate reordering method based on the number of dirty handlers.

void markDirty(GraphicBatchHandler &handler)

Mark a graphic batch handler as dirty.

Note

Adds the handler to the dirty handlers buffer.

Parameters:

handler – Reference to the GraphicBatchHandler to mark as dirty.

void uploadOrderIndices()

Upload the order indices to the SSBO.

inline size_t size() const

Get the size of the render list.

Returns:

The number of graphic batch handlers in the render list.

inline IndirectIterator begin()

Begin iterator for the render list.

Returns:

IndirectIterator to the beginning of the render list.

inline IndirectIterator end()

End iterator for the render list.

Returns:

IndirectIterator to the end of the render list.

Private Functions

void binarySearchReorder(const GraphicBatchHandler &handler)

Do a binary search reorder of the render list.

Note

Uses binary search to find the correct position for the handler.

Parameters:

handler – Reference to the GraphicBatchHandler that triggered the reorder.

void radixReorder()

Radix reorder of the render list.

Note

Uses radix sort algorithm for reordering.

Private Members

BatchBuffer &batch

Reference to the batch buffer.

Holds the batch handlers for rendering.

Note

Shared with the renderer backend.

OrderIndicesBuffer orderIndices

Order indices buffer.

Holds the order of indices for rendering.

Note

Used for indirect rendering and reordering.

DirtyHandlersBuffer dirtyHandlers

Dirty handlers buffer.

Holds references to graphic batch handlers that need re-ordering.

RenderListFlags flags

Render list flags.

Holds the state flags for the render list.

RaeptorCogs::GAPI::ObjectHandler<Common::SSBO> indexIndirectionSSBO

SSBO for index indirection.

Holds the shader storage buffer object for index indirection.