23 const auto identity = drawList.
sortIdentity(entity.
id(), layer, 0);
33std::vector<u32> g_indexScratch;
35template <
typename IndexT>
36void pushBatchCommandImpl(TransientBufferPool& pool, DrawList& drawList,
const ClipState& clips,
37 u32 vertexByteOffset,
u32 vertexCount,
38 const IndexT* localIndices,
u32 indexCount,
39 const BatchDrawKey& key) {
40 if (indexCount == 0 || !
batchEntityVisible(drawList, clips, key.entity, key.layer, key.cullBit))
return;
42 u32 baseVertex = vertexByteOffset / pool.vertexStride(key.layoutId);
43 g_indexScratch.resize(indexCount);
44 for (
u32 i = 0; i < indexCount; ++i) {
45 g_indexScratch[i] = baseVertex +
static_cast<u32>(localIndices[i]);
47 u32 indexOffset = pool.appendIndices(key.layoutId, g_indexScratch.data(), indexCount);
49 pushBatchDraw(drawList, clips, vertexByteOffset, vertexCount, indexOffset, indexCount, key);
55 u32 vertexByteOffset,
u32 vertexCount,
u32 indexOffset,
u32 indexCount,
73 const auto resolve = drawList.
layerOrder(layer);
105 ? ((
static_cast<u32>(key.
vertexBuffer) * 2654435761u) ^ (indexOffset * 2246822519u)) >> 24 | 1u
192 u32 vertexByteOffset,
u32 vertexCount,
193 const u32* localIndices,
u32 indexCount,
195 pushBatchCommandImpl(pool, drawList, clips, vertexByteOffset, vertexCount, localIndices, indexCount, key);
199 u32 vertexByteOffset,
u32 vertexCount,
200 const u16* localIndices,
u32 indexCount,
202 pushBatchCommandImpl(pool, drawList, clips, vertexByteOffset, vertexCount, localIndices, indexCount, key);
206 const void* verts,
u32 vertexCount,
207 const u32* localIndices,
u32 indexCount,
209 if (vertexCount == 0 || indexCount == 0
213 pushBatchCommandImpl(pool, drawList, clips, vertexByteOffset, vertexCount, localIndices, indexCount, key);
218 const u32* localIndices,
u32 indexCount,
220 appendIndexedDraw(pool, drawList, clips, verts, vertexCount, localIndices, indexCount, key);
226 const u32 vertexCount = quadCount * 4;
229 const u32 indexCount = quadCount * 6;
230 g_indexScratch.resize(indexCount);
231 for (
u32 q = 0; q < quadCount; ++q) {
235 pushBatchDraw(drawList, clips, vertexByteOffset, vertexCount, indexOffset, indexCount, key);
The single submission face: the ONLY place a DrawCommand is assembled.
bool isEmptyScissor(Entity entity) const
void applyTo(Entity entity, DrawCommand &cmd) const
const GroupIdentity * sortingGroupOf(u32 entity) const
The group entity belongs to, or null when it sorts on its own.
static u32 layerBit(i32 layer)
The mask bit of a sorting layer, or 0 when it has none (outside 0..31).
SortIdentity sortIdentity(u32 entity, i32 ownLayer, i32 ownOrder) const
The one answer to "where does this draw sit". Asked by the draw path when it builds a key,...
LayerOrder layerOrder(i32 layer) const
The one answer for layer, from two masks that are two spellings of the same question.
void push(const DrawCommand &cmd)
u32 treeSequenceOf(Entity entity) const
bool layerVisible(u32 layerBit) const
Whether a draw belonging to layerBit survives this camera's mask. Bit 0 means "no layer" (outside 0....
u32 appendVertices(LayoutId layout, const void *data, u32 byteSize)
u32 vertexStride(LayoutId layout) const
u32 appendIndices(LayoutId layout, const u32 *data, u32 count)
void appendQuads(TransientBufferPool &pool, DrawList &drawList, const ClipState &clips, const BatchVertex *quads, u32 quadCount, const BatchDrawKey &key)
std::int32_t i32
Signed 32-bit integer.
void 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 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,...
std::uint32_t u32
Unsigned 32-bit integer.
std::uint8_t u8
Unsigned 8-bit integer.
std::uint16_t u16
Unsigned 16-bit integer.
void 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 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.
bool batchEntityVisible(const DrawList &drawList, const ClipState &clips, Entity entity, i32 layer, u32 cullBit)
constexpr u32 BATCH_QUAD_INDICES[6]
Canonical two-triangle quad winding shared by every batch path.
Non-geometry attributes of a batch draw — everything needed to build the sort key + DrawCommand.
i16 depthBias
Depth-buffer units toward the eye.
GfxTopology topology
How the indices assemble.
BufferHandle instanceBuffer
BufferHandle vertexBuffer
u8 cull
CullMode: 0 = none, 1 = back, 2 = front.
VertexLayoutHandle vertexLayout
One vertex of the shared batch stream.
static u64 buildSortKey(RenderStage stage, i32 layer, u32 shaderId, BlendMode blend, u16 stateFlags, f32 depth, u32 materialId=0, i32 order=0, u32 geometry=0)
BufferHandle instance_buffer
static u64 buildSortKeyTree(RenderStage stage, i32 layer, u32 sequence, u32 shaderId, BlendMode blend, u16 stateFlags, i32 order=0)
static u64 withGroupOrder(u64 key, i32 memberOrder)
Re-stamps a member's own order into a key whose top fields a SortingGroup has taken over.
i16 depth_bias
Depth-buffer units toward the eye.
VertexLayoutHandle vertex_layout
u32 texture_ids[MAX_CMD_TEXTURE_SLOTS]
static u64 buildSortKeyYSorted(RenderStage stage, i32 layer, f32 worldY, u32 shaderId, BlendMode blend, u16 stateFlags, i32 order=0)
BufferHandle index_buffer
GfxTopology topology
Triangles or lines.
u8 cull
CullMode: 0 = none, 1 = back, 2 = front.
BufferHandle vertex_buffer
The sorting identity a SortingGroup imposes on one of its members.
Where a draw sits in the frame's order, once any group has had its say.
Entity identifier with packed index + generation.
constexpr u32 id() const
Returns the raw packed value for FFI serialization.