95 default:
return "batch.break.none";
212 "RenderStage outgrew the sort key's 2-bit field — re-lay the key out");
220 i32 order = 0,
u32 geometry = 0) {
221 i32 normalizedLayer = std::clamp(
layer + 32768, 0, 65535);
222 u64 layerKey =
static_cast<u64>(normalizedLayer & 0xFFFF) << 48;
236 return layerKey |
orderBits(order) | stageKey
237 | (
static_cast<u64>(orderedDepth >> 12) << 18)
238 | (
static_cast<u64>(shaderId & 0xFF) << 10)
240 | (
static_cast<u64>(stateFlags & 0x03) << 5)
241 | (
static_cast<u64>(materialId) & 0x1F);
243 const u64 depthField = geometry != 0
244 ? (
static_cast<u64>(geometry & 0xFF) << 6) |
static_cast<u64>(orderedDepth >> 26)
245 :
static_cast<u64>(orderedDepth >> 18);
246 return layerKey |
orderBits(order) | stageKey
247 | (
static_cast<u64>(shaderId & 0xFF) << 30)
249 | (
static_cast<u64>(stateFlags & 0x03) << 25)
250 | ((
static_cast<u64>(materialId) & 0x7FF) << 14)
259 return static_cast<u64>(blend) & 0x7;
267 return static_cast<u64>(std::clamp(order + 128, 0, 255)) << 40;
279 constexpr u64 field = 0xFFull << 30;
280 return (key & ~field) | (
static_cast<u64>(std::clamp(memberOrder + 128, 0, 255)) << 30);
286 u32 bits = std::bit_cast<u32>(v);
287 return (bits & 0x80000000u) ? ~bits : (bits | 0x80000000u);
306 i32 normalizedLayer = std::clamp(
layer + 32768, 0, 65535);
307 u64 layerKey =
static_cast<u64>(normalizedLayer & 0xFFFF) << 48;
312 u64 yKey =
static_cast<u64>(yDescending & 0xFFFFFF) << 14;
314 u64 shaderKey =
static_cast<u64>(shaderId & 0xFF) << 6;
316 u64 flagsKey =
static_cast<u64>(stateFlags & 0x03) << 1;
318 return stageKey | layerKey |
orderBits(order) | yKey | shaderKey | blendKey | flagsKey;
326 i32 normalizedLayer = std::clamp(
layer + 32768, 0, 65535);
327 u64 layerKey =
static_cast<u64>(normalizedLayer & 0xFFFF) << 48;
330 u64 sequenceKey =
static_cast<u64>(sequence & 0xFFFFFF) << 14;
332 u64 shaderKey =
static_cast<u64>(shaderId & 0xFF) << 6;
334 u64 flagsKey =
static_cast<u64>(stateFlags & 0x03) << 1;
336 return stageKey | layerKey |
orderBits(order) | sequenceKey | shaderKey | blendKey | flagsKey;
Blend mode enumeration for custom rendering.
Immutable GPU pipeline state — the backend-agnostic unit of "how to draw".
The indirect light where ONE draw stands, when a grid was baked for it.
Core type definitions and utilities for ESEngine.
GPU shader program for rendering.
GfxStencilMode stencilModeOf(u16 stateFlags)
The stencil mode a draw's state flags mean.
static constexpr u16 CMD_STATE_UI_STENCIL
std::int32_t i32
Signed 32-bit integer.
static constexpr u16 CMD_STATE_STENCIL_DECREMENT
std::uint64_t u64
Unsigned 64-bit integer.
GfxStencilMode
Stencil behaviour baked into a pipeline. The reference value is dynamic (GfxDevice::setStencilReferen...
@ Test
Draw only INSIDE the mask: func Equal, op Keep.
@ Write
Write the reference where drawn (mask fill): func Always, op Replace, color write off.
@ Decrement
Restore the parent reference on leaving a nested mask.
@ Increment
Enter a nested mask only where the parent reference matches.
@ TestOutside
Draw only OUTSIDE it: func NotEqual, op Keep — a hole, not a window.
@ Off
No stencil test; full color write.
@ Zero
Retire a root mask without writing color.
static constexpr u16 CMD_STATE_STENCIL_INCREMENT
constexpr Entity INVALID_ENTITY
Invalid entity sentinel value.
std::int16_t i16
Signed 16-bit integer.
static constexpr u16 CMD_STATE_STENCIL_ZERO
static constexpr u16 CMD_STATE_SCISSOR
constexpr u32 PROBE_MAX_INSTANCES
How many instances of one merged draw carry their own irradiance.
std::uint32_t u32
Unsigned 32-bit integer.
BlendMode
Predefined blend modes for rendering.
static constexpr u16 CMD_STATE_STENCIL_OUT
std::uint8_t u8
Unsigned 8-bit integer.
static constexpr u16 CMD_STATE_STENCIL_WRITE
std::uint16_t u16
Unsigned 16-bit integer.
LayoutId
Identifies a transient vertex stream / vertex format. Each layout has its own VBO+EBO+VAO in Transien...
const char * batchBreakCounter(BatchBreak r)
static constexpr u16 CMD_STATE_CUSTOM_DRAW
static constexpr u32 MAX_CMD_TEXTURE_SLOTS
static constexpr u16 CMD_STATE_STENCIL_TEST
GfxTopology
How a pipeline's indices assemble into primitives. Baked into the pipeline, as WebGPU bakes it,...
@ Triangles
Every three indices a triangle: all geometry the engine draws.
float f32
32-bit floating point
static u64 buildSortKey(RenderStage stage, i32 layer, u32 shaderId, BlendMode blend, u16 stateFlags, f32 depth, u32 materialId=0, i32 order=0, u32 geometry=0)
i32 addTextureSlot(u32 texId, u8 limit=MAX_CMD_TEXTURE_SLOTS)
BufferHandle instance_buffer
BatchBreak mergeBlocker(const DrawCommand &next) const
static u64 buildSortKeyTree(RenderStage stage, i32 layer, u32 sequence, u32 shaderId, BlendMode blend, u16 stateFlags, i32 order=0)
bool sameInstancedGeometry(const DrawCommand &next) const
bool hasPersistentGeometry() const
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.
bool canMergeWith(const DrawCommand &next) const
static u32 orderedFloatBits(f32 v)
static u64 blendBits(BlendMode blend)
The blend field, 3 bits wide wherever it appears.
bool orderIndependent() const
VertexLayoutHandle vertex_layout
BatchBreak break_reason
Why this draw call started.
static u64 orderBits(i32 order)
The order field at [47:40], biased so a negative order sorts below zero.
u32 texture_ids[MAX_CMD_TEXTURE_SLOTS]
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....
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
Entity identifier with packed index + generation.