pub struct GeneratedDraws {
pub args: BufferHandle,
pub args_id: BufferId,
pub counts: BufferHandle,
pub counts_id: BufferId,
pub flat_args_offset: u64,
pub runs_id: BufferId,
pub group_state_id: BufferId,
pub visible_count_id: BufferId,
}Expand description
What one frame’s generated draws live in.
Returned by DrawGen::add_passes and consumed by the caller’s render
pass, which needs both halves: the BufferIds to declare its reads with,
so the graph transitions them, and the handles to name in the indirect call
itself.
Fields§
§args: BufferHandleThe indirect arguments, draw_gen::DRAW_ARGS_SIZE bytes per bucket.
A buffer of its own, unlike the counts and dispatch extents below, and for the one reason that survives the storage-buffer squeeze the module docs describe: the mesh path reads these as a shader read in the same pass that executes those as indirect arguments, and a resource is in one state at a time.
args_id: BufferIdThe same buffer as the graph knows it. Declare it in
ResourceState::IndirectArgument, or as a shader read on the mesh path.
counts: BufferHandleThe per-bucket draw counts and the per-bucket mesh-dispatch arguments, in that order, in one buffer.
At DrawGen::count_offset(b) is bucket b’s u32 draw count: 1
for a bucket with something in it and 0 for one without, which is what
GeometryPath::IndirectCount’s
call reads. At DrawGen::mesh_args_offset(b) are its
draw_gen::MESH_ARGS_SIZE bytes of (clusters, surviving instances, 1) — or, where DrawGenDesc::task_lanes is non-zero,
task_extents of those two —
which is what
CommandEncoder::draw_mesh_tasks_indirect
reads on
GeometryPath::MeshShader.
One buffer because no pass reads both: the two indirect tails execute the
counts and the mesh path executes the extents, so it is in
ResourceState::IndirectArgument either way and never in two states at
once.
counts_id: BufferIdThe same buffer as the graph knows it. Declare it in
ResourceState::IndirectArgument — once, whichever region the
pass reads.
flat_args_offset: u64Byte offset in counts of region 0’s first flat task
dispatch: behind every region this generator allocates, one
draw_gen::MESH_ARGS_SIZE structure per
flat segment a region, which is where a flat
call’s arguments are — see DrawGen::flat_args_offset. Per generator
rather than per renderer, because it sits behind however many regions
the generator was built with.
runs_id: BufferIdcull.slang’s survivor list, each survivor’s route, the per-bucket runs
of surviving instance indices the vertex stage reads, and where each run
starts this frame, in that order, in one buffer. Declare it as a shader
read.
A pass that draws reads only the starts and the runs: bucket b’s start
at word DrawGen::bucket_start_word(b) — which is the number
DrawConstants::start_at
carries — and then the run from the word that start names.
group_state_id: BufferIdTopic 25’s hysteresis state, as the graph knows it.
Here because a caller whose geometry path has an amplification stage
reads it: mesh_cluster.slang looks up the two groups a cluster
names, so the pass that runs it declares ResourceState::ShaderRead on
this id and the graph orders that read after the draw-argument pass’s
write. A caller on a path with no amplification stage declares nothing,
and the state is then written and read by that pass alone.
visible_count_id: BufferIdThe frame’s culling statistics, as the graph knows them — the buffer
DrawGen::visible_count hands out.
Here because §3.5’s amplification stage writes it: it counts
surviving clusters into
CLUSTER_SURVIVOR_WORD,
so the pass that runs it declares
ResourceState::ShaderReadWrite on this id and the graph orders that
write after the draw-argument pass’s read. A caller on a geometry path
with no amplification stage declares nothing and the counter keeps the
zero the clearing pass wrote.