|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
#include <DrawCommand.hpp>
Public Member Functions | |
| bool | hasPersistentGeometry () const |
| u8 | textureSlotBudget (u8 reservedSlots) const |
Finds texId in this command's texture set, adds it (returns its slot), or -1 if the set is full. Used by the merge to assign per-vertex sampler slots. limit is how many slots the merge may spend: a frame with a 2D shadow mask keeps the top one for it, and a merge that took it would bind a sprite where every Lit fragment reads its shadow. | |
| i32 | addTextureSlot (u32 texId, u8 limit=MAX_CMD_TEXTURE_SLOTS) |
| bool | orderIndependent () const |
| bool | sameInstancedGeometry (const DrawCommand &next) const |
| BatchBreak | mergeBlocker (const DrawCommand &next) const |
| bool | canMergeWith (const DrawCommand &next) const |
Static Public Member Functions | |
| static u64 | buildSortKey (RenderStage stage, i32 layer, u32 shaderId, BlendMode blend, u16 stateFlags, f32 depth, u32 materialId=0, i32 order=0, u32 geometry=0) |
| static u64 | blendBits (BlendMode blend) |
| The blend field, 3 bits wide wherever it appears. | |
| static u64 | orderBits (i32 order) |
| The order field at [47:40], biased so a negative order sorts below zero. | |
| 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. | |
| static u32 | orderedFloatBits (f32 v) |
| static u64 | buildSortKeyYSorted (RenderStage stage, i32 layer, f32 worldY, u32 shaderId, BlendMode blend, u16 stateFlags, i32 order=0) |
| static u64 | buildSortKeyTree (RenderStage stage, i32 layer, u32 sequence, u32 shaderId, BlendMode blend, u16 stateFlags, i32 order=0) |
Definition at line 99 of file DrawCommand.hpp.
|
inline |
Definition at line 359 of file DrawCommand.hpp.
References esengine::MAX_CMD_TEXTURE_SLOTS, texture_count, and texture_ids.
Referenced by esengine::DrawList::finalize().
The blend field, 3 bits wide wherever it appears.
Masked, because the enum outgrew the field: BlendMode::None is 9, and unmasked it set a bit in the SHADER field above it. Aliasing None onto Additive costs a merge; the spill cost a wrong order.
Definition at line 258 of file DrawCommand.hpp.
Referenced by buildSortKey(), buildSortKeyTree(), and buildSortKeyYSorted().
|
inlinestatic |
Definition at line 218 of file DrawCommand.hpp.
References blendBits(), layer, orderBits(), orderedFloatBits(), esengine::Overlay, stage, and esengine::Transparent.
Referenced by esengine::pushBatchDraw().
|
inlinestatic |
Definition at line 323 of file DrawCommand.hpp.
References blendBits(), layer, orderBits(), and stage.
Referenced by esengine::pushBatchDraw().
|
inlinestatic |
Definition at line 303 of file DrawCommand.hpp.
References blendBits(), layer, orderBits(), orderedFloatBits(), and stage.
Referenced by esengine::pushBatchDraw().
|
inline |
Definition at line 489 of file DrawCommand.hpp.
References mergeBlocker(), esengine::None, and planar_index.
|
inline |
Definition at line 181 of file DrawCommand.hpp.
References esengine::Invalid, and vertex_buffer.
Referenced by sameInstancedGeometry().
|
inline |
Definition at line 418 of file DrawCommand.hpp.
References esengine::Blend, blend_mode, esengine::CMD_STATE_SCISSOR, esengine::CMD_STATE_STENCIL_TEST, esengine::CMD_STATE_STENCIL_WRITE, esengine::CMD_STATE_UI_STENCIL, esengine::Cull, cull, esengine::Depth, depth_bias, depth_shader_id, depth_test, depth_write, index_buffer, index_count, index_offset, esengine::IndexGap, instance_count, esengine::Instanced, esengine::Layout, layout_id, esengine::Material, material_id, esengine::None, planar_index, probe_index, esengine::PROBE_MAX_INSTANCES, sameInstancedGeometry(), esengine::Scissor, scissor, esengine::Shader, shader_id, esengine::State, state_flags, esengine::Stencil, stencil_ref, texture_count, texture_ids, esengine::TextureSlots, topology, vertex_buffer, and vertex_layout.
Referenced by canMergeWith(), and esengine::DrawList::finalize().
The order field at [47:40], biased so a negative order sorts below zero.
CLAMPED, not wrapped: an order past the range pins to the extreme it ran past, where a wrap would land it on the far side — "very much on top" turning into "behind everything" is the one failure a clamp cannot make.
Definition at line 266 of file DrawCommand.hpp.
Referenced by buildSortKey(), buildSortKeyTree(), and buildSortKeyYSorted().
Definition at line 285 of file DrawCommand.hpp.
Referenced by buildSortKey(), and buildSortKeyYSorted().
|
inline |
Why next cannot join this draw, or None if it can.
The predicate answers with the reason rather than a bare no: a frame is some number of draw calls, and the only actionable thing about that number is what kept them apart. canMergeWith is this, read as a bool. Whether this draw's result is the same wherever it happens among its peers: it replaces what it covers rather than reading it, and depth decides what covers what. Only such draws can be merged into one — a merge is exactly the loss of their relative order.
Definition at line 381 of file DrawCommand.hpp.
References blend_mode, depth_test, depth_write, and esengine::None.
Referenced by sameInstancedGeometry().
|
inline |
Whether two instanced draws are the same geometry drawn again — what a second instance record answers, rather than a second draw. Both must be order-independent, since merging is the loss of their relative order; a skinned draw is out because one draw can only be in one pose.
Definition at line 391 of file DrawCommand.hpp.
References hasPersistentGeometry(), index_buffer, index_count, index_offset, instance_stride, morph_index, orderIndependent(), planar_index, skin_count, texture_count, texture_ids, vertex_buffer, and vertex_layout.
Referenced by mergeBlocker().
Finds texId in this command's texture set, adds it (returns its slot), or -1 if the set is full. Used by the merge to assign per-vertex sampler slots. limit is how many slots the merge may spend: a frame with a 2D shadow mask keeps the top one for it, and a merge that took it would bind a sprite where every Lit fragment reads its shadow.
How many sprite textures a merged run headed by this draw may carry.
The Batch stream merges draws of different textures by giving each its own sampler slot and stamping the slot on its vertices — which only the engine's own batch program reads. A material's shader samples the sprite at slot 0 and nothing else (u_textures[0] / t0), so a run of material draws that merged across textures drew every sprite with the first one's picture. Such a run keeps to one texture; a second one starts a new draw.
Definition at line 354 of file DrawCommand.hpp.
References material_id, and esengine::MAX_CMD_TEXTURE_SLOTS.
Referenced by esengine::DrawList::finalize().
Re-stamps a member's own order into a key whose top fields a SortingGroup has taken over.
[37:30] is the only field directly under stage in ALL three packings, and it must be one field or two members of a group are incomparable. Costs those bits' projection (depth, shader, worldY) inside a group only.
Definition at line 278 of file DrawCommand.hpp.
Referenced by esengine::pushBatchDraw().
| BlendMode esengine::DrawCommand::blend_mode = BlendMode::Normal |
Definition at line 110 of file DrawCommand.hpp.
Referenced by mergeBlocker(), orderIndependent(), esengine::pushBatchDraw(), and esengine::FrameCapture::record().
| BatchBreak esengine::DrawCommand::break_reason = BatchBreak::RunStart |
Why this draw call started.
Definition at line 123 of file DrawCommand.hpp.
Referenced by esengine::FrameCapture::record().
| u8 esengine::DrawCommand::cull = 0 |
CullMode: 0 = none, 1 = back, 2 = front.
Definition at line 120 of file DrawCommand.hpp.
Referenced by mergeBlocker(), and esengine::pushBatchDraw().
| i16 esengine::DrawCommand::depth_bias = 0 |
Depth-buffer units toward the eye.
Definition at line 121 of file DrawCommand.hpp.
Referenced by mergeBlocker(), and esengine::pushBatchDraw().
| u32 esengine::DrawCommand::depth_shader_id = 0 |
The program that writes only this draw's depth, for the scene's depth prepass (0 = the draw takes no part in one). Its vertex stage is the draw's own, so the depth it writes is the depth the draw's colour pass lands on.
Definition at line 109 of file DrawCommand.hpp.
Referenced by mergeBlocker(), esengine::pushBatchDraw(), and esengine::takesPartInPrepass().
| bool esengine::DrawCommand::depth_test = false |
Definition at line 118 of file DrawCommand.hpp.
Referenced by mergeBlocker(), orderIndependent(), esengine::DrawList::push(), esengine::pushBatchDraw(), and esengine::takesPartInPrepass().
| bool esengine::DrawCommand::depth_write = true |
Definition at line 119 of file DrawCommand.hpp.
Referenced by mergeBlocker(), orderIndependent(), esengine::DrawList::push(), esengine::pushBatchDraw(), and esengine::takesPartInPrepass().
| Entity esengine::DrawCommand::entity = INVALID_ENTITY |
Definition at line 133 of file DrawCommand.hpp.
Referenced by esengine::pushBatchDraw().
| u32 esengine::DrawCommand::entity_count = 1 |
Definition at line 140 of file DrawCommand.hpp.
Referenced by esengine::DrawList::finalize(), and esengine::DrawList::push().
| BufferHandle esengine::DrawCommand::index_buffer = BufferHandle::Invalid |
Definition at line 159 of file DrawCommand.hpp.
Referenced by mergeBlocker(), esengine::pushBatchDraw(), and sameInstancedGeometry().
| u32 esengine::DrawCommand::index_count = 0 |
Definition at line 103 of file DrawCommand.hpp.
Referenced by esengine::DrawList::execute(), esengine::DrawList::finalize(), mergeBlocker(), esengine::pushBatchDraw(), esengine::FrameCapture::record(), and sameInstancedGeometry().
| u32 esengine::DrawCommand::index_offset = 0 |
Definition at line 102 of file DrawCommand.hpp.
Referenced by esengine::DrawList::execute(), mergeBlocker(), esengine::pushBatchDraw(), and sameInstancedGeometry().
| BufferHandle esengine::DrawCommand::instance_buffer = BufferHandle::Invalid |
Definition at line 153 of file DrawCommand.hpp.
Referenced by esengine::pushBatchDraw().
| u32 esengine::DrawCommand::instance_count = 0 |
Definition at line 147 of file DrawCommand.hpp.
Referenced by esengine::DrawList::execute(), esengine::DrawList::finalize(), mergeBlocker(), esengine::pushBatchDraw(), and esengine::FrameCapture::record().
| u32 esengine::DrawCommand::instance_stride = 0 |
Definition at line 150 of file DrawCommand.hpp.
Referenced by esengine::DrawList::finalize(), esengine::pushBatchDraw(), and sameInstancedGeometry().
| bool esengine::DrawCommand::instances_relocated = false |
This draw's instance records have been moved to the end of the stream, where the run it heads is growing. Set by the merge, read by it alone.
Definition at line 143 of file DrawCommand.hpp.
Referenced by esengine::DrawList::finalize().
| i32 esengine::DrawCommand::layer = 0 |
Definition at line 139 of file DrawCommand.hpp.
Referenced by buildSortKey(), buildSortKeyTree(), buildSortKeyYSorted(), esengine::pushBatchDraw(), and esengine::FrameCapture::record().
| LayoutId esengine::DrawCommand::layout_id = LayoutId::Batch |
Definition at line 111 of file DrawCommand.hpp.
Referenced by esengine::DrawList::finalize(), mergeBlocker(), and esengine::pushBatchDraw().
| u32 esengine::DrawCommand::material_id = 0 |
Definition at line 115 of file DrawCommand.hpp.
Referenced by mergeBlocker(), esengine::pushBatchDraw(), esengine::FrameCapture::record(), and textureSlotBudget().
| u32 esengine::DrawCommand::morph_index = 0 |
Definition at line 169 of file DrawCommand.hpp.
Referenced by esengine::pushBatchDraw(), and sameInstancedGeometry().
| u32 esengine::DrawCommand::planar_index = 0 |
Definition at line 175 of file DrawCommand.hpp.
Referenced by canMergeWith(), mergeBlocker(), esengine::pushBatchDraw(), and sameInstancedGeometry().
| u32 esengine::DrawCommand::probe_base = 0 |
Definition at line 179 of file DrawCommand.hpp.
| u32 esengine::DrawCommand::probe_index = 0 |
Definition at line 174 of file DrawCommand.hpp.
Referenced by mergeBlocker(), and esengine::pushBatchDraw().
| ScissorRect esengine::DrawCommand::scissor |
Definition at line 129 of file DrawCommand.hpp.
Referenced by esengine::ClipState::applyTo(), mergeBlocker(), and esengine::FrameCapture::record().
| u32 esengine::DrawCommand::shader_id = 0 |
Definition at line 106 of file DrawCommand.hpp.
Referenced by mergeBlocker(), esengine::pushBatchDraw(), and esengine::FrameCapture::record().
| u32 esengine::DrawCommand::skin_count = 0 |
Definition at line 165 of file DrawCommand.hpp.
Referenced by esengine::pushBatchDraw(), and sameInstancedGeometry().
| u32 esengine::DrawCommand::skin_offset = 0 |
Definition at line 164 of file DrawCommand.hpp.
Referenced by esengine::pushBatchDraw().
| u64 esengine::DrawCommand::sort_key = 0 |
Definition at line 100 of file DrawCommand.hpp.
Referenced by esengine::pushBatchDraw().
| RenderStage esengine::DrawCommand::stage = RenderStage::Transparent |
Definition at line 138 of file DrawCommand.hpp.
Referenced by buildSortKey(), buildSortKeyTree(), buildSortKeyYSorted(), esengine::pushBatchDraw(), and esengine::FrameCapture::record().
| u16 esengine::DrawCommand::state_flags = 0 |
Definition at line 128 of file DrawCommand.hpp.
Referenced by esengine::ClipState::applyTo(), mergeBlocker(), esengine::DrawList::push(), esengine::FrameCapture::record(), and esengine::takesPartInPrepass().
| u16 esengine::DrawCommand::stencil_depth = 0 |
Definition at line 131 of file DrawCommand.hpp.
Referenced by esengine::ClipState::applyTo().
| i32 esengine::DrawCommand::stencil_ref = 0 |
Definition at line 130 of file DrawCommand.hpp.
Referenced by esengine::ClipState::applyTo(), mergeBlocker(), and esengine::FrameCapture::record().
| u8 esengine::DrawCommand::texture_count = 0 |
Definition at line 125 of file DrawCommand.hpp.
Referenced by addTextureSlot(), esengine::DrawList::finalize(), mergeBlocker(), esengine::pushBatchDraw(), esengine::FrameCapture::record(), and sameInstancedGeometry().
| u32 esengine::DrawCommand::texture_ids[MAX_CMD_TEXTURE_SLOTS] = {} |
Definition at line 126 of file DrawCommand.hpp.
Referenced by addTextureSlot(), esengine::DrawList::finalize(), mergeBlocker(), esengine::pushBatchDraw(), esengine::FrameCapture::record(), and sameInstancedGeometry().
| GfxTopology esengine::DrawCommand::topology = GfxTopology::Triangles |
Triangles or lines.
Definition at line 122 of file DrawCommand.hpp.
Referenced by mergeBlocker(), and esengine::pushBatchDraw().
| RenderType esengine::DrawCommand::type = RenderType::Sprite |
Definition at line 134 of file DrawCommand.hpp.
Referenced by esengine::DrawList::push(), esengine::pushBatchDraw(), and esengine::FrameCapture::record().
| BufferHandle esengine::DrawCommand::vertex_buffer = BufferHandle::Invalid |
Definition at line 158 of file DrawCommand.hpp.
Referenced by hasPersistentGeometry(), mergeBlocker(), esengine::pushBatchDraw(), and sameInstancedGeometry().
| u32 esengine::DrawCommand::vertex_byte_offset = 0 |
Definition at line 104 of file DrawCommand.hpp.
Referenced by esengine::DrawList::finalize(), and esengine::pushBatchDraw().
| u32 esengine::DrawCommand::vertex_count = 0 |
Definition at line 185 of file DrawCommand.hpp.
Referenced by esengine::pushBatchDraw().
| VertexLayoutHandle esengine::DrawCommand::vertex_layout = VertexLayoutHandle::Invalid |
Definition at line 160 of file DrawCommand.hpp.
Referenced by mergeBlocker(), esengine::pushBatchDraw(), and sameInstancedGeometry().