20#include <unordered_map>
38 template <
typename Remap>
51 if (commands_.empty())
return false;
55 lo = std::min(lo,
command.sort_key);
56 hi = std::max(hi,
command.sort_key);
64 shader_run_sink_ = other.shader_run_sink_;
65 defer_screen_color_ = other.defer_screen_color_;
66 layer_alpha_ = other.layer_alpha_;
67 layerless_visible_ = other.layerless_visible_;
68 std::copy(std::begin(other.mask_2d_textures_), std::end(other.mask_2d_textures_), std::begin(mask_2d_textures_));
69 gbuffer_pass_ = other.gbuffer_pass_;
70 mask_2d_slots_ = other.mask_2d_slots_;
71 ysort_mask_ = other.ysort_mask_;
72 tree_mask_ = other.tree_mask_;
73 depth_mask_ = other.depth_mask_;
74 culling_mask_ = other.culling_mask_;
134 const glm::mat4*
skinMatrices()
const {
return skin_matrices_.data(); }
148 const auto index =
static_cast<u32>(type);
149 return index < entity_counts_.size() ? entity_counts_[index] : 0;
196 return index < tree_sequence_.size() ? tree_sequence_[index] : 0u;
213 bool needsDepth()
const {
return depth_mask_ != 0 || depth_required_; }
223 return layerBit == 0 ? layerless_visible_ : (culling_mask_ &
layerBit) != 0;
228 return (layer < 0 || layer >= 32) ? 0u : (1u << layer);
247 const u32 bit = 1u << layer;
270 group_identities_[entity] = identity;
276 if (group_identities_.empty())
return nullptr;
277 auto it = group_identities_.find(entity);
278 return it != group_identities_.end() ? &it->second :
nullptr;
296 return {ownLayer, ownOrder};
300 std::function<void(
const char*)> shader_run_sink_;
301 u32 skipped_for_program_ = 0;
304 std::vector<u8> prepass_skipped_;
305 bool defer_screen_color_ =
false;
306 bool layer_alpha_ =
false;
307 bool layerless_visible_ =
true;
313 std::vector<DrawCommand> commands_;
316 std::vector<glm::mat4> skin_matrices_;
317 std::vector<MorphConstants> morph_shapes_;
318 std::vector<ProbeConstants> probes_;
319 std::vector<PlanarConstants> planar_;
323 std::vector<u32> probe_slots_;
326 std::vector<Entity> run_entities_;
327 std::vector<u32> run_first_;
330 std::vector<glm::vec4> probe_run_;
332 struct StagedBlocks {
333 PerDrawBlocks::Range skin, probe, instance, planar;
335 std::vector<StagedBlocks> staged_;
337 std::vector<u32> run_length_;
339 std::vector<u32> entry_texel_;
340 std::vector<u32> run_counts_, run_offsets_, run_instances_;
342 static bool joinsRun(
const DrawCommand& prev,
const DrawCommand& next);
344 static bool readsRecords(
const DrawCommand& cmd);
346 bool probeLitAt(
const DrawCommand& cmd)
const;
348 void writeEntries(TransientBufferPool& pool);
349 void stageBlocks(
const PerDrawBlockSet& blocks,
bool drawRuns);
352 std::vector<SortEntry> sort_entries_;
353 std::vector<u64> sorted_keys_;
354 std::vector<DrawCommand> sorted_scratch_;
356 std::vector<DrawCommand> stencil_commands_scratch_;
357 std::vector<DrawCommand> stencil_stack_scratch_;
358 std::vector<u32> stencil_level_first_;
359 bool ui_stencil_required_ =
false;
363 bool gbuffer_pass_ =
false;
364 u32 mask_2d_slots_ = 0;
365 u32 merged_draw_calls_ = 0;
366 u32 merged_away_ = 0;
369 std::unordered_map<u32, GroupIdentity> group_identities_;
372 std::vector<u32> tree_sequence_;
375 bool depth_required_ =
false;
376 u32 culling_mask_ = 0xFFFFFFFFu;
One frame's draw calls as the device received them, for the frame debugger.
Abstract graphics device interface.
WHERE one draw's entry is in the frame's per-object record texture, and what an entry says.
Math utilities and GLM configuration for ESEngine.
The shapes one draw is blended towards: which targets, and how far.
A uniform range per draw, so two draws never write into one block.
The indirect light where ONE draw stands, when a grid was baked for it.
Core type definitions and utilities for ESEngine.
const DrawCommand * commands() const
u32 skippedForProgram() const
How many merged draws the last execute left out because their program was not ready (GfxDevice::setSk...
const GroupIdentity * sortingGroupOf(u32 entity) const
The group entity belongs to, or null when it sorts on its own.
bool anyUsesScreenColor(const MaterialStore &materials) const
bool sortKeyRange(u64 &lo, u64 &hi) const
u32 mergedDrawCallCount() const
u32 addProbe(const ProbeConstants &probe)
u64 contentHashOfRecords(u64 seed, TransientBufferPool &pool, bool &trusted) const
contentHash with the instance records each command reads from pool in place of where they lie in it: ...
void finalize(TransientBufferPool &pool)
void setDeferScreenColor(bool defer)
u32 sourceEntityCount(RenderType type) const
bool anyUsesSceneColor(const MaterialStore &materials) const
Whether any merged draw reads the picture behind it.
const glm::mat4 * skinMatrices() const
void setDepthMask(u32 mask)
void setYSortMask(u32 mask)
std::vector< u32 > & treeSequence()
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,...
u32 addSkinMatrices(const glm::mat4 *matrices, u32 count)
u32 depthPrepassDraws() const
How many of the merged draws take part in a depth prepass; 0 means a prepass has nothing to draw.
void clearSortingGroups()
const DrawCommand & command(u32 index) const
void remapPrograms(Remap &&remap)
LayerOrder layerOrder(i32 layer) const
The one answer for layer, from two masks that are two spellings of the same question.
void execute(GfxDevice &device, TransientBufferPool &buffers, MaterialStore &materials, u32 white_texture_id=0, FrameCapture *capture=nullptr, const PerDrawBlockSet &blocks={}, Phase phase=Phase::All, DrawPass pass=DrawPass::Color)
void setTreeMask(u32 mask)
u32 mergedAwayCount() const
bool anyBlendedWithoutSceneColor(const MaterialStore &materials) const
Whether the list holds a blended draw that does not refract: what has to be ordered against a refract...
u32 addMorphShapes(const MorphConstants &shapes)
u32 addPlanar(const PlanarConstants &value)
bool needsDepth() const
Whether a frame holding these draws has to be handed a depth buffer.
void setSortingGroup(u32 entity, const GroupIdentity &identity)
Resolved once per collect, by the one walk that knows the hierarchy — the draw path only reads it,...
bool anyUsesSceneDepth(const MaterialStore &materials) const
Whether any merged draw reads the distance to the opaque scene behind it.
void setMask2DTexture(u32 unit, u32 textureId)
void push(const DrawCommand &cmd)
void setGBufferPass(bool on)
void reserveMask2DSlots(u32 count)
bool anyNeedsScenePicture(const MaterialStore &materials) const
Whether a draw is of a material that does not work without a picture of the scene (MaterialStore::nee...
void setShaderRunSink(std::function< void(const char *)> sink)
u32 treeSequenceOf(Entity entity) const
void setCullingMask(u32 mask)
bool layerVisible(u32 layerBit) const
Whether a draw belonging to layerBit survives this camera's mask. Bit 0 means "no layer" (outside 0....
LayerOrder
How one sorting layer resolves the draws inside it.
void setLayerlessVisible(bool visible)
void copySettingsFrom(const DrawList &other)
void setLayerAlpha(bool layer)
u64 contentHash(u64 seed) const
A hash of what the list draws: each command's program, geometry, state and ranges,...
std::span< const Entity > runEntities(u32 index) const
u32 breakCount(BatchBreak reason) const
Abstract graphics device interface.
Maps a material handle to its resolved record. Owned by RenderContext so it is reachable from both th...
std::int32_t i32
Signed 32-bit integer.
std::uint64_t u64
Unsigned 64-bit integer.
std::uint32_t u32
Unsigned 32-bit integer.
std::uint8_t u8
Unsigned 8-bit integer.
static constexpr u32 MAX_CMD_TEXTURE_SLOTS
auto sink(SignalType &signal)
Create a sink for a signal.
The sorting identity a SortingGroup imposes on one of its members.
i32 layer
What the whole group presents outward — the key's top two fields.
Where a draw sits in the frame's order, once any group has had its say.
bool operator<(const SortIdentity &o) const
bool operator<=(const SortIdentity &o) const
Entity identifier with packed index + generation.
constexpr u32 index() const
Gets the entity index.
One draw's shapes, laid out as the texels they are written as.
The uniform blocks a draw rewrites immediately before it.
The indirect light one instance stands in — both halves of it.