MultidrawContext
Defines
-
USE_STAGING_MULTIDRAW_BUF
-
template<typename PerDrawDataT>
class MultidrawContext Multidraw Context
This class incapsulates logic of filling multidraw buffers. It implements draw call id/per draw parameters passing for different platforms and manages buffers required for it.
Public Functions
-
inline MultidrawContext(const char *name)
Default constructor.
- Parameters:
name – must be unique for each context.
-
MultidrawContext(MultidrawContext&&) = default
Default move constructor.
-
MultidrawContext &operator=(MultidrawContext&&) = default
Default move assignment operator.
-
MultidrawContext(MultidrawContext&) = delete
Removed copy constructor since we use unique buffer holders.
-
MultidrawContext &operator=(MultidrawContext&) = delete
Removed copy assignment operator since we use unique buffer holders.
-
template<typename T>
inline MultidrawRenderExecutor fillBuffers(uint32_t drawcalls_count, const T &set_cb) Fills multidraw buffers.
This method iterates over locked buffers content and calls params_setter for each draw call to fill only allowed parameters of drawcall. If the buffers are too small, it recreates them.
- Parameters:
drawcalls_count – number of draw calls.
set_cb – function that sets draw call parameters.
- Returns:
executor that could be used to render draw calls.
-
inline void close()
Closes buffers.
Private Functions
Private Members
-
eastl::string name
Name for context that is used as a buffer name and as a prefix for helper buffers.
-
RingDynamicSB multidrawArguments
Buffer for draw calls arguments.
-
UniqueBufHolder perDrawArgsBuffer
Buffer for per draw parameters.
-
uint32_t allocatedDrawcallsInBuffer = 0
Number of draw calls that can be stored in buffer.
-
uint32_t actualStart = 0
Offset in buffer for next draw call.
Private Static Functions
-
static inline constexpr bool needPerDrawParamsBuffer()
Checks if per draw parameter could be stored instead of draw id. In this case we don’t need per draw parameters buffer.
-
class MultidrawRenderExecutor
Executor for multidraw calls.
This class is used to pass multidraw buffers to a draw call. It could be constructed only by MultidrawContext. It is used to hide multidraw buffers from a user.
Public Functions
-
inline MultidrawRenderExecutor(const MultidrawContext *context)
Constructor.
- Parameters:
context – reference to a context that is used for rendering. If context is a nullptr, render method does nothing.
-
inline void render(uint32_t primitive_type, uint32_t first_drawcall, uint32_t drawcalls_count) const
Renders draw calls.
This method renders draw calls using multidraw indirect buffers.
- Parameters:
primitive_type – type of primitive.
first_drawcall – index of first draw call in the buffer.
drawcalls_count – number of draw calls to execute.
Private Functions
-
MultidrawRenderExecutor() = delete
Default constructors and operator= are deleted.
-
MultidrawRenderExecutor(MultidrawRenderExecutor&&) = delete
-
MultidrawRenderExecutor &operator=(MultidrawRenderExecutor&&) = delete
-
MultidrawRenderExecutor(MultidrawRenderExecutor&) = delete
-
MultidrawRenderExecutor &operator=(MultidrawRenderExecutor&) = delete
Private Members
-
const MultidrawContext *context
Pointer to a context that is used for rendering.
Friends
- friend class MultidrawContext
-
inline MultidrawRenderExecutor(const MultidrawContext *context)
-
inline MultidrawContext(const char *name)