Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
BatchBuilder.hpp File Reference

The single submission face: the ONLY place a DrawCommand is assembled. More...

#include "../../core/Types.hpp"
#include "./BatchVertex.hpp"
#include "./BlendMode.hpp"
#include "./ClipState.hpp"
#include "./DrawCommand.hpp"
#include "./DrawList.hpp"
#include "./RenderItem.hpp"
#include "../frame/RenderStage.hpp"
#include "../rhi/TransientBufferPool.hpp"
#include <glm/glm.hpp>
Include dependency graph for BatchBuilder.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  esengine::BatchDrawKey
 Non-geometry attributes of a batch draw — everything needed to build the sort key + DrawCommand. More...

Namespaces

namespace  esengine

Functions

glm::vec3 esengine::rotatePoint (const glm::vec3 &center, f32 px, f32 py, f32 cosA, f32 sinA)
 Rotates a point around center in the XY plane, carrying the center's z through untouched — the rotation a 2D renderer means is about z.
bool esengine::batchEntityVisible (const DrawList &drawList, const ClipState &clips, Entity entity, i32 layer, u32 cullBit)
void esengine::pushBatchDraw (DrawList &drawList, const ClipState &clips, u32 vertexByteOffset, u32 vertexCount, u32 indexOffset, u32 indexCount, const BatchDrawKey &key)
 Atomic primitive: assemble + clip + push one DrawCommand for an index range ALREADY written into (or, for instanced draws, static in) the key's stream.
void esengine::pushBatchCommand (TransientBufferPool &pool, DrawList &drawList, const ClipState &clips, u32 vertexByteOffset, u32 vertexCount, const u32 *localIndices, u32 indexCount, const BatchDrawKey &key)
 Pushes a DrawCommand for vertices ALREADY resident in the Batch stream at vertexByteOffset.
void esengine::pushBatchCommand (TransientBufferPool &pool, DrawList &drawList, const ClipState &clips, u32 vertexByteOffset, u32 vertexCount, const u16 *localIndices, u32 indexCount, const BatchDrawKey &key)
void esengine::appendIndexedDraw (TransientBufferPool &pool, DrawList &drawList, const ClipState &clips, const void *verts, u32 vertexCount, const u32 *localIndices, u32 indexCount, const BatchDrawKey &key)
 Copies raw vertices into the key's stream, then pushes one DrawCommand spanning them.
void esengine::appendIndexedBatch (TransientBufferPool &pool, DrawList &drawList, const ClipState &clips, const BatchVertex *verts, u32 vertexCount, const u32 *localIndices, u32 indexCount, const BatchDrawKey &key)
 Copies verts into the Batch stream, then pushes one DrawCommand spanning them.
void esengine::appendQuads (TransientBufferPool &pool, DrawList &drawList, const ClipState &clips, const BatchVertex *quads, u32 quadCount, const BatchDrawKey &key)
void esengine::appendQuad (TransientBufferPool &pool, DrawList &drawList, const ClipState &clips, const BatchVertex quad[4], const BatchDrawKey &key)

Variables

constexpr glm::vec4 esengine::BATCH_QUAD_POSITIONS [4]
 Canonical centered unit-quad corner positions (CCW).
constexpr glm::vec2 esengine::BATCH_QUAD_TEX_COORDS [4]
 Unit-quad texture coordinates matching BATCH_QUAD_POSITIONS.
constexpr u32 esengine::BATCH_QUAD_INDICES [6] = { 0, 1, 2, 2, 3, 0 }
 Canonical two-triangle quad winding shared by every batch path.

Detailed Description

The single submission face: the ONLY place a DrawCommand is assembled.

Every render path — the batch-quad plugins (sprite/UI/text), the dedicated streams (shape/particle/tilemap), and RenderFrame's spine/text/tile direct submits — describes its draw as a BatchDrawKey plus geometry, and this face does the rest: append vertices, offset indices by baseVertex, build the sort key, assemble the DrawCommand, apply clip state, push into the DrawList. Renderers only generate commands; sorting, merging, and GfxDevice submission live unified in DrawList. The invariant is CI-enforced (tools/check-draw-command-boundary.mjs): DrawCommand assembly outside this translation unit fails the build.

Author
ESEngine Team
Date
2026

Definition in file BatchBuilder.hpp.