19constexpr u32 NO_EXPECTED_OFFSET = 0xFFFFFFFFu;
25 for (
u32 k = 0; k < cmd.vertex_count; ++k) verts[k].texIndex =
withTextureSlot(verts[k].texIndex, slot);
36 const u32 bytes = cmd.instance_stride * std::max(cmd.instance_count, 1u);
38 if (expectedAt != NO_EXPECTED_OFFSET && at != expectedAt)
return false;
41 std::memmove(base + at, base + cmd.vertex_byte_offset, bytes);
42 cmd.vertex_byte_offset = at;
50 if (stride == 0)
return false;
53 && cmd.index_count != 0 && cmd.index_offset <= used && cmd.index_count <= used - cmd.index_offset
54 && cmd.vertex_byte_offset <= vertexBytes
55 && cmd.vertex_count <= (vertexBytes - cmd.vertex_byte_offset) / stride;
57 if (!owned(head) || !owned(next) || head.depth_bias != next.depth_bias
58 || head.topology != next.topology)
return false;
60 if (head.index_offset + head.index_count != used) {
61 if (!pool.copyIndexRange(
LayoutId::Batch, head.index_offset, head.index_count, at))
return false;
62 head.index_offset = at;
64 if (!pool.copyIndexRange(
LayoutId::Batch, next.index_offset, next.index_count, at))
return false;
65 next.index_offset = at;
66 return head.index_offset + head.index_count == next.index_offset;
72 entity_counts_.fill(0);
73 skin_matrices_.clear();
74 morph_shapes_.clear();
78 run_entities_.clear();
80 merged_draw_calls_ = 0;
81 skipped_for_program_ = 0;
82 depth_required_ =
false;
83 ui_stencil_required_ =
false;
87 const u32 at =
static_cast<u32>(skin_matrices_.size());
88 skin_matrices_.insert(skin_matrices_.end(), matrices, matrices + count);
93 morph_shapes_.push_back(shapes);
94 return static_cast<u32>(morph_shapes_.size());
98 probes_.push_back(probe);
99 return static_cast<u32>(probes_.size());
107 const auto type =
static_cast<u32>(cmd.
type);
108 if (type < entity_counts_.size()) entity_counts_[type] += cmd.
entity_count;
109 commands_.push_back(cmd);
114 u32 count =
static_cast<u32>(commands_.size());
116 merged_draw_calls_ = 0;
119 entry_texel_.clear();
120 std::fill(std::begin(breaks_), std::end(breaks_), 0u);
127 bool sameKeys = sorted_keys_.size() == count && sort_entries_.size() == count;
128 for (
u32 i = 0; sameKeys && i < count; ++i) sameKeys = sorted_keys_[i] == commands_[i].sort_key;
131 sort_entries_.resize(count);
132 sorted_keys_.resize(count);
133 for (
u32 i = 0; i < count; ++i) {
134 sort_entries_[i] = { commands_[i].sort_key, i };
135 sorted_keys_[i] = commands_[i].sort_key;
141 std::sort(sort_entries_.begin(), sort_entries_.end(),
142 [](
const SortEntry& a,
const SortEntry& b) {
143 return a.key < b.key || (a.key == b.key && a.index < b.index);
149 sorted_scratch_.resize(count);
150 for (
u32 i = 0; i < count; ++i) {
151 sorted_scratch_[i] = commands_[sort_entries_[i].index];
153 commands_.swap(sorted_scratch_);
158 if (ui_stencil_required_) {
159 stencil_commands_scratch_.clear();
160 stencil_stack_scratch_.clear();
161 stencil_level_first_.clear();
162 const auto leaveMask = [&]() {
163 const u32 first = stencil_level_first_.back();
164 stencil_level_first_.pop_back();
165 while (stencil_stack_scratch_.size() > first) {
166 stencil_commands_scratch_.push_back(stencil_stack_scratch_.back());
167 auto& restore = stencil_commands_scratch_.back();
168 stencil_stack_scratch_.pop_back();
169 restore.state_flags |= restore.stencil_depth == 1
171 restore.entity_count = 0;
173 restore.depth_test =
false;
174 restore.depth_write =
false;
180 const bool continuation = mask && !stencil_stack_scratch_.empty()
181 && stencil_stack_scratch_.back().entity == source.entity
182 && stencil_stack_scratch_.back().stencil_depth == source.stencil_depth;
183 const u32 wanted = ui ? source.stencil_depth - (mask && !continuation ? 1 : 0) : 0;
184 while (stencil_level_first_.size() > wanted) leaveMask();
187 if (ui && stencil_level_first_.size() != wanted)
continue;
188 stencil_commands_scratch_.push_back(source);
189 auto&
command = stencil_commands_scratch_.back();
192 stencil_level_first_.push_back(
static_cast<u32>(stencil_stack_scratch_.size()));
194 stencil_stack_scratch_.push_back(
command);
197 if (
command.stencil_depth > 1) {
203 while (!stencil_level_first_.empty()) leaveMask();
204 commands_.swap(stencil_commands_scratch_);
205 count =
static_cast<u32>(commands_.size());
208 merged_draw_calls_ = 0;
209 run_entities_.clear();
214 for (
u32 i = 0; i < count; ++i) {
215 bool didMerge =
false;
227 if (std::find(begin, end, commands_[i].texture_ids[0]) == end) {
232 && joinBatchIndexRanges(pool, head, commands_[i])) {
240 || relocateInstance(pool, head, NO_EXPECTED_OFFSET);
242 ok = relocateInstance(pool, commands_[i],
252 probe_slots_.insert(probe_slots_.end(), std::max(commands_[i].instance_count, 1u), commands_[i].probe_index);
267 if (slot != 0) rewriteTexIndex(pool, commands_[i], slot);
283 commands_[writeIdx] = commands_[i];
285 run_first_.push_back(
static_cast<u32>(run_entities_.size()));
286 if (commands_[writeIdx].instance_count != 0) {
287 commands_[writeIdx].probe_base =
static_cast<u32>(probe_slots_.size());
288 probe_slots_.insert(probe_slots_.end(), commands_[writeIdx].instance_count, commands_[writeIdx].probe_index);
290 commands_[writeIdx].break_reason = blocker;
291 ++breaks[
static_cast<u32>(blocker)];
296 if (commands_[i].entity !=
INVALID_ENTITY) run_entities_.push_back(commands_[i].entity);
298 commands_.resize(writeIdx);
299 merged_draw_calls_ = writeIdx;
301 merged_away_ = count - merged_draw_calls_;
302 std::copy(std::begin(breaks), std::end(breaks), std::begin(breaks_));
308 if (index >= run_first_.size())
return {};
309 const u32 first = run_first_[index];
310 const u32 end = index + 1 < run_first_.size() ? run_first_[index + 1]
311 :
static_cast<u32>(run_entities_.size());
312 return {run_entities_.data() + first, end - first};
319bool DrawList::joinsRun(
const DrawCommand& p,
const DrawCommand& c) {
322 const auto runnable = [](
const DrawCommand& d) {
326 if (!runnable(p) || !runnable(c))
return false;
328 return p.vertex_buffer == c.vertex_buffer && p.index_buffer == c.index_buffer && p.vertex_layout == c.vertex_layout
329 && p.shader_id == c.shader_id && p.depth_shader_id == c.depth_shader_id && p.material_id == c.material_id
330 && p.blend_mode == c.blend_mode && p.depth_test == c.depth_test && p.depth_write == c.depth_write && p.cull == c.cull
331 && p.depth_bias == c.depth_bias && p.topology == c.topology && p.stage == c.stage && p.state_flags == c.state_flags
332 && (!(p.state_flags &
CMD_STATE_SCISSOR) || p.scissor == c.scissor) && p.stencil_ref == c.stencil_ref
333 && p.texture_count == c.texture_count && std::equal(p.texture_ids, p.texture_ids + p.texture_count, c.texture_ids);
336bool DrawList::probeLitAt(
const DrawCommand& cmd)
const {
338 for (
u32 k = 0; k < n; ++k) {
339 const size_t at =
static_cast<size_t>(cmd.probe_base) + k;
340 if (at < probe_slots_.size() && probe_slots_[at] != 0)
return true;
346 run_length_.assign(merged_draw_calls_, 1u);
347 entry_texel_.assign(merged_draw_calls_, 0u);
351 if (pool.device().supportsMultiDraw()) {
352 u32 head = 0, instances = 0;
354 for (
u32 i = 0; i < merged_draw_calls_; ++i) {
355 const DrawCommand& cmd = commands_[i];
356 const bool cmdLit = probeLitAt(cmd);
357 if (i > 0 && run_length_[head] <
MULTI_DRAW_MAX && joinsRun(commands_[i - 1], cmd)
361 instances += cmd.instance_count;
366 instances = cmd.instance_count;
372 u32 entries = 0, shapeTexels = 0;
373 for (
u32 i = 0; i < merged_draw_calls_; ++i) {
374 const DrawCommand& cmd = commands_[i];
375 if (!readsRecords(cmd))
continue;
377 if (cmd.morph_index > 0) shapeTexels += 1u +
static_cast<u32>(morph_shapes_[cmd.morph_index - 1].info.x);
379 if (entries == 0)
return;
381 const u32 bytes = (entries + shapeTexels) * 16u;
386 std::memset(base + offset, 0, padded);
387 auto* texels =
reinterpret_cast<glm::vec4*
>(base + offset);
388 const u32 first = offset / 16u;
389 u32 entry = 0, shapes = entries;
390 for (
u32 i = 0; i < merged_draw_calls_;) {
391 const u32 length = std::max(run_length_[i], 1u);
393 for (
u32 k = 0; k < length; ++k) {
394 const DrawCommand& cmd = commands_[i + k];
395 if (!readsRecords(cmd))
continue;
396 entry_texel_[i + k] = first + entry;
397 glm::vec4& e = texels[entry++];
399 e.y =
static_cast<f32>(runInstance);
400 runInstance += cmd.instance_count;
401 if (cmd.morph_index > 0) {
402 const MorphConstants& shaped = morph_shapes_[cmd.morph_index - 1];
403 const u32 live =
static_cast<u32>(shaped.info.x);
404 e.z =
static_cast<f32>(first + shapes);
405 texels[shapes] = shaped.info;
406 std::memcpy(&texels[shapes + 1], shaped.shape, live *
sizeof(glm::vec4));
414void DrawList::stageBlocks(
const PerDrawBlockSet& blocks,
bool drawRuns) {
415 staged_.assign(merged_draw_calls_, StagedBlocks{});
416 if (run_length_.size() != merged_draw_calls_) run_length_.assign(merged_draw_calls_, 1u);
417 if (entry_texel_.size() != merged_draw_calls_) entry_texel_.assign(merged_draw_calls_, 0u);
418 const auto stageEntry = [&](
u32 i) {
419 if (!blocks.instance || !readsRecords(commands_[i]))
return;
420 const InstanceConstants at{entry_texel_[i], {}};
421 staged_[i].instance = blocks.instance->stage(&at,
sizeof(at));
423 for (
u32 i = 0; i < merged_draw_calls_; ++i) {
424 const auto& cmd = commands_[i];
425 StagedBlocks& staged = staged_[i];
426 const u32 length = run_length_[i];
427 if (length == 0)
continue;
432 for (
u32 k = 0; k < length; ++k) {
433 instances += commands_[i + k].instance_count;
434 anyLit = anyLit || probeLitAt(commands_[i + k]);
436 if (anyLit && blocks.probe) {
437 probe_run_.assign(
static_cast<size_t>(instances) *
PROBE_TEXELS, glm::vec4(0.0f));
439 for (
u32 k = 0; k < length; ++k) {
440 const DrawCommand& member = commands_[i + k];
441 for (
u32 n = 0; n < member.instance_count; ++n, ++at) {
442 const size_t slot =
static_cast<size_t>(member.probe_base) + n;
443 const u32 index = slot < probe_slots_.size() ? probe_slots_[slot] : 0u;
444 if (index == 0)
continue;
445 std::memcpy(&probe_run_[
static_cast<size_t>(at) *
PROBE_TEXELS], &probes_[index - 1],
sizeof(ProbeConstants));
448 staged.probe = blocks.probe->stage(probe_run_.data(),
static_cast<u32>(probe_run_.size() *
sizeof(glm::vec4)));
454 for (
u32 k = 1; k < length; ++k) {
456 staged_[i + k].probe = staged.probe;
462 if (blocks.planar && cmd.planar_index > 0) {
463 staged.planar = blocks.planar->stage(&planar_[cmd.planar_index - 1],
sizeof(PlanarConstants));
468 if (cmd.skin_count > 0 && blocks.skin) {
469 staged.skin = blocks.skin->stage(skin_matrices_.data() + cmd.skin_offset,
470 cmd.skin_count *
static_cast<u32>(
sizeof(glm::mat4)));
478 if (blocks.probe && probeLitAt(cmd)) {
482 const u32 runs = std::min(cmd.instance_count > 0 ? cmd.instance_count : 1u,
484 probe_run_.assign(
static_cast<size_t>(runs) *
PROBE_TEXELS, glm::vec4(0.0f));
485 for (
u32 n = 0; n < runs; ++n) {
486 const size_t at =
static_cast<size_t>(cmd.probe_base) + n;
487 const u32 index = at < probe_slots_.size() ? probe_slots_[at] : 0u;
488 if (index == 0)
continue;
489 std::memcpy(&probe_run_[
static_cast<size_t>(n) *
PROBE_TEXELS],
490 &probes_[index - 1],
sizeof(ProbeConstants));
492 staged.probe = blocks.probe->stage(
493 probe_run_.data(),
static_cast<u32>(probe_run_.size() *
sizeof(glm::vec4)));
499 for (PerDrawBlocks* pool : {blocks.skin, blocks.probe, blocks.instance, blocks.planar}) {
500 if (pool) pool->upload();
505 for (
usize i = 0; i < commands_.size(); ++i) {
506 if (commands_[i].material_id != 0 && materials.
needsScenePicture(commands_[i].material_id))
return true;
512 for (
u32 i = 0; i < merged_draw_calls_; ++i) {
513 if (commands_[i].material_id != 0 && materials.
usesSceneColor(commands_[i].material_id))
return true;
519 for (
u32 i = 0; i < merged_draw_calls_; ++i) {
520 if (commands_[i].material_id != 0 && materials.
usesScreenColor(commands_[i].material_id))
return true;
532 for (
u32 i = 0; i < merged_draw_calls_; ++i) {
533 const auto& cmd = commands_[i];
546 for (
u32 i = 0; i < merged_draw_calls_; ++i) {
553 for (
u32 i = 0; i < merged_draw_calls_; ++i) {
554 if (commands_[i].material_id != 0 && materials.
usesSceneDepth(commands_[i].material_id))
return true;
566 const std::string* lastRun =
nullptr;
567 skipped_for_program_ = 0;
582 if (!afterPrepass) stageBlocks(blocks, drawRuns);
583 if (prepass) prepass_skipped_.assign(merged_draw_calls_, 0u);
584 else if (!afterPrepass) prepass_skipped_.clear();
585 if (run_length_.size() != merged_draw_calls_) run_length_.assign(merged_draw_calls_, 1u);
588 for (
u32 i = 0, next = 0; i < merged_draw_calls_; i = next) {
591 const u32 runLength = drawRuns ? std::max(run_length_[i], 1u) : 1u;
592 next = i + runLength;
593 const auto& cmd = commands_[i];
594 const StagedBlocks& staged = staged_[i];
597 const bool screen = cmd.material_id != 0 && materials.
usesScreenColor(cmd.material_id);
601 const bool refracts = cmd.material_id != 0 && materials.
usesSceneColor(cmd.material_id);
612 if (!drawn)
continue;
615 if (shader_run_sink_) {
616 const std::string& run = materials.
shaderLabel(cmd.material_id);
617 if (&run != lastRun && (!lastRun || run != *lastRun)) shader_run_sink_(run.c_str());
631 desc.
blend = cmd.blend_mode;
662 }
else if (afterPrepass &&
takesPartInPrepass(cmd) && !(i < prepass_skipped_.size() && prepass_skipped_[i])) {
672 ++skipped_for_program_;
674 if (prepass && i < prepass_skipped_.size()) prepass_skipped_[i] = 1u;
686 if (cmd.skin_count > 0 && blocks.
skin) {
698 device.
setScissor(cmd.scissor.x, cmd.scissor.y, cmd.scissor.w, cmd.scissor.h);
707 if (cmd.texture_count > 0) {
709 if (!((sampled >> slot) & 1u))
continue;
714 u32 tex = masked ? (mask_2d_textures_[slot] != 0 ? mask_2d_textures_[slot]
716 : ((slot < cmd.texture_count) ? cmd.texture_ids[slot]
726 if (cmd.material_id != 0) {
730 if (cmd.hasPersistentGeometry()) {
733 if (blocks.
instance && cmd.instance_count != 0) {
738 const u32 firstIndexByte =
static_cast<u32>(
static_cast<uintptr_t
>(cmd.index_offset) *
sizeof(
u32));
740 run_counts_.resize(runLength);
741 run_offsets_.resize(runLength);
742 run_instances_.resize(runLength);
743 for (
u32 k = 0; k < runLength; ++k) {
746 run_offsets_[k] =
static_cast<u32>(
static_cast<uintptr_t
>(member.
index_offset) *
sizeof(
u32));
750 run_instances_.data(), runLength);
752 }
else if (cmd.instance_count != 0) {
757 }
else if (cmd.instance_count > 0) {
771 static_cast<u32>(
static_cast<uintptr_t
>(cmd.index_offset) *
sizeof(
u32)));
774 if (capture && !prepass) {
788 mix(commands_.size());
792 mix((
static_cast<u64>(c.index_offset) << 32) | c.index_count);
794 mix((
static_cast<u64>(c.shader_id) << 32) | c.material_id);
795 mix((
static_cast<u64>(c.instance_count) << 32) | c.instance_stride);
796 mix((
static_cast<u64>(
static_cast<u32>(c.vertex_buffer)) << 32) |
static_cast<u32>(c.index_buffer));
797 mix((
static_cast<u64>(
static_cast<u32>(c.vertex_layout)) << 32) |
static_cast<u32>(c.instance_buffer));
798 mix((
static_cast<u64>(c.skin_offset) << 32) | c.skin_count);
799 mix((
static_cast<u64>(c.morph_index) << 32) |
static_cast<u32>(c.layout_id));
800 mix((
static_cast<u64>(
static_cast<u16>(c.depth_bias)) << 32) | (
static_cast<u64>(c.cull) << 24)
801 | (
static_cast<u64>(c.depth_test) << 16) | (
static_cast<u64>(c.depth_write) << 8)
802 |
static_cast<u64>(c.blend_mode) | (
static_cast<u64>(c.topology) << 40));
803 mix(c.texture_count);
810 const usize bytes =
static_cast<usize>(c.instance_count) * c.instance_stride;
815 words(pool.
vertexData(c.layout_id) + c.vertex_byte_offset, bytes);
817 mix(skin_matrices_.size());
818 if (!skin_matrices_.empty()) words(skin_matrices_.data(), skin_matrices_.size() *
sizeof(glm::mat4));
819 mix(morph_shapes_.size());
820 if (!morph_shapes_.empty()) words(morph_shapes_.data(), morph_shapes_.size() *
sizeof(
MorphConstants));
826 mix(commands_.size());
829 mix((
static_cast<u64>(c.index_offset) << 32) | c.index_count);
830 mix((
static_cast<u64>(c.vertex_byte_offset) << 32) | c.vertex_count);
831 mix((
static_cast<u64>(c.shader_id) << 32) | c.material_id);
832 mix((
static_cast<u64>(c.instance_count) << 32) | c.instance_stride);
833 mix((
static_cast<u64>(
static_cast<u32>(c.vertex_buffer)) << 32) |
static_cast<u32>(c.index_buffer));
834 mix((
static_cast<u64>(
static_cast<u32>(c.vertex_layout)) << 32) |
static_cast<u32>(c.instance_buffer));
835 mix((
static_cast<u64>(c.skin_offset) << 32) | c.skin_count);
836 mix((
static_cast<u64>(c.morph_index) << 32) |
static_cast<u32>(c.layout_id));
837 mix((
static_cast<u64>(
static_cast<u16>(c.depth_bias)) << 32) | (
static_cast<u64>(c.cull) << 24)
838 | (
static_cast<u64>(c.depth_test) << 16) | (
static_cast<u64>(c.depth_write) << 8)
839 |
static_cast<u64>(c.blend_mode) | (
static_cast<u64>(c.topology) << 40));
840 mix(c.texture_count);
844 mix(skin_matrices_.size());
845 if (!skin_matrices_.empty()) words(skin_matrices_.data(), skin_matrices_.size() *
sizeof(glm::mat4));
846 mix(morph_shapes_.size());
847 if (!morph_shapes_.empty()) words(morph_shapes_.data(), morph_shapes_.size() *
sizeof(
MorphConstants));
Per-frame CPU scope timing (ES_PROFILE_SCOPE) read by the editor profiler.
#define ES_PROFILE_COUNTER(name, value)
WHERE one draw's entry is in the frame's per-object record texture, and what an entry says.
Engine-side material registry — the resolved "how to draw" for a material handle.
The pose one skinned draw is deformed by: a bone matrix per joint.
bool anyUsesScreenColor(const MaterialStore &materials) 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)
bool anyUsesSceneColor(const MaterialStore &materials) const
Whether any merged draw reads the picture behind it.
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.
const DrawCommand & command(u32 index) const
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)
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)
bool anyUsesSceneDepth(const MaterialStore &materials) const
Whether any merged draw reads the distance to the opaque scene behind it.
void push(const DrawCommand &cmd)
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...
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
void record(const DrawCommand &cmd, std::span< const Entity > entities)
void counter(const char *name, double value)
static FrameProfiler & get()
Abstract graphics device interface.
virtual void bindTexture(u32 slot, TextureHandle texture)=0
Activates a texture slot and binds a 2D texture.
bool programReady(ShaderHandle program)
Whether program can be drawn with now, without waiting: linked, or finished linking in the background...
virtual void setVertexBuffer(u32 slot, BufferHandle buffer, u32 offsetBytes)=0
Binds a vertex buffer to a layout slot for subsequent draws.
virtual void drawElementsInstancedMulti(GfxDataType indexType, const u32 *counts, const u32 *byteOffsets, const u32 *instanceCounts, u32 drawCount)
drawCount indexed instanced draws through the bound pipeline and buffers, as one call where supportsM...
bool skipPendingPrograms() const
virtual void drawElements(u32 indexCount, GfxDataType indexType, u32 byteOffset)=0
Draws indexed triangles.
virtual void setIndexBuffer(BufferHandle buffer)=0
Binds the index buffer for subsequent indexed draws.
u32 boundSamplerUnits()
The texture units the bound program samples, one bit a unit; every unit where the backend cannot say.
virtual void drawElementsInstanced(u32 indexCount, GfxDataType indexType, u32 byteOffset, u32 instanceCount)=0
Draws indexed triangles with instancing.
virtual void setScissorTest(bool enabled)=0
Enables or disables scissor test.
virtual bool supportsUnblendedSurfaceTarget() const
Whether a blended draw can write the surface record's second attachment unblended.
void setPipeline(PipelineHandle handle)
Binds a pipeline: applies its program, blend, depth, stencil compare/op and culling.
PipelineHandle createPipeline(const PipelineDesc &desc)
Resolves a pipeline description to a cached handle (creating it on first use).
virtual void setStencilReference(i32 ref)=0
Sets the dynamic stencil reference for the bound pipeline's stencil mode (no-op if Off).
virtual bool supportsMultiDraw() const
Whether drawElementsInstancedMulti is one call here, its draws told apart by gl_DrawID (WEBGL_multi_d...
virtual void setScissor(i32 x, i32 y, i32 w, i32 h)=0
Sets the scissor rectangle.
Maps a material handle to its resolved record. Owned by RenderContext so it is reachable from both th...
bool programWritesAlbedo(u32 programId) const
Of those, the ones that also write the surface's diffuse colour (location 2, fragAlbedo).
void bindForDraw(u32 materialId, u32 samplerUnits=0xFFFFFFFFu)
bool usesSceneColor(u32 materialId) const
const std::string & shaderLabel(u32 materialId) const
The name of the shader materialId draws with, or "default" for the path's own batch shader.
bool usesSceneDepth(u32 materialId) const
bool usesScreenColor(u32 materialId) const
bool alphaIsCoverage(u32 materialId) const
bool programWritesGBuffer(u32 programId) const
bool needsScenePicture(u32 materialId) const
void bind(u32 slot, Range range) const
Binds range to slot — the zero block for a range staging refused.
VertexLayoutHandle layoutHandle(LayoutId layout) const
void bindInstanceLayout(LayoutId layout, u32 instanceByteOffset)
TextureHandle instanceTexture() const
The frame's per-object records. Invalid until a frame writes some.
void bindLayout(LayoutId layout)
u32 vertexBytesUsed(LayoutId layout) const
u8 * vertexData(LayoutId layout)
void bindInstanceBuffer(LayoutId layout, BufferHandle instances)
constexpr u64 combine(u64 h, u64 v)
u64 combineWords(u64 h, const void *data, usize bytes)
GfxStencilMode stencilModeOf(u16 stateFlags)
The stencil mode a draw's state flags mean.
static constexpr u32 MESH_INSTANCE_STRIDE
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.
f32 withTextureSlot(f32 texIndex, i32 slot)
GfxStencilMode
Stencil behaviour baked into a pipeline. The reference value is dynamic (GfxDevice::setStencilReferen...
@ Off
No stencil test; full color write.
std::size_t usize
Size type for indexing and sizes.
static constexpr u16 CMD_STATE_STENCIL_INCREMENT
constexpr Entity INVALID_ENTITY
Invalid entity sentinel value.
constexpr i32 BATCH_SLOT_BITS
static constexpr u16 CMD_STATE_STENCIL_ZERO
constexpr u32 SKIN_CONSTANTS_BINDING
Indexed UBO binding point for the per-draw SkinConstants block.
static constexpr u16 CMD_STATE_SCISSOR
constexpr u32 PROBE_CONSTANTS_BINDING
Indexed UBO binding point for the per-draw ProbeConstants block.
static bool takesPartInPrepass(const DrawCommand &cmd)
A draw the prepass takes in: opaque and depth-writing, with a program of its own for it,...
PipelineHandle
Opaque handle to a cached pipeline; PipelineHandle{0} is the null/invalid handle.
constexpr u32 MULTI_DRAW_MAX
The most draws one call may carry where the device draws runs (WEBGL_multi_draw).
constexpr u32 PROBE_MAX_INSTANCES
How many instances of one merged draw carry their own irradiance.
std::uint32_t u32
Unsigned 32-bit integer.
static constexpr u32 MESH_INSTANCE_TEXTURE_UNIT
std::uint8_t u8
Unsigned 8-bit integer.
static constexpr u16 CMD_STATE_STENCIL_WRITE
std::uint16_t u16
Unsigned 16-bit integer.
constexpr u32 PLANAR_CONSTANTS_BINDING
static constexpr u32 MAX_CMD_TEXTURE_SLOTS
constexpr u32 PROBE_TEXELS
Texels one instance's indirect light occupies in that block.
constexpr u32 INSTANCE_CONSTANTS_BINDING
Indexed UBO binding point for the per-draw InstanceConstants block. Nine and not four: slot 4 is DRAW...
static bool isBlendedStage(RenderStage stage)
float f32
32-bit floating point
One vertex of the shared batch stream.
i32 addTextureSlot(u32 texId, u8 limit=MAX_CMD_TEXTURE_SLOTS)
BufferHandle instance_buffer
BatchBreak mergeBlocker(const DrawCommand &next) const
bool hasPersistentGeometry() const
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....
One draw's shapes, laid out as the texels they are written as.
The uniform blocks a draw rewrites immediately before it.
Immutable description of a draw pipeline. Equality keys the pipeline cache, so two draws with the sam...
bool colorWrite
False writes no colour, to either attachment: a depth-only pass, whose surfaces are then drawn again ...
VertexLayoutHandle vertexLayout
The indirect light one instance stands in — both halves of it.