pub struct PrefixScan { /* private fields */ }Expand description
The compiled scan pipelines.
Implementations§
Source§impl PrefixScan
impl PrefixScan
Sourcepub fn new(device: &Device) -> Result<Self>
pub fn new(device: &Device) -> Result<Self>
Compile both entry points.
§Errors
Propagates composition failure, which would mean this crate’s own shaders are inconsistent.
Sourcepub fn scan(
&self,
device: &Device,
queue: &Queue,
counts: &Buffer,
n: u32,
) -> Result<ScanOutput>
pub fn scan( &self, device: &Device, queue: &Queue, counts: &Buffer, n: u32, ) -> Result<ScanOutput>
Exclusive prefix sum of the first n u32s in counts.
counts needs STORAGE. The returned offsets buffer carries
STORAGE | COPY_SRC, so it can be bound to the emit pass or read back
for comparison.
Blocks once, for four bytes: the grand total, which the caller needs to size whatever the scan is feeding.
§Errors
Anything the four-byte read-back can report, and
Error::ScanTooLong from the dispatch bound scan_deferred checks.
Sourcepub fn scan_deferred(
&self,
device: &Device,
queue: &Queue,
counts: &Buffer,
n: u32,
) -> Result<DeferredScan>
pub fn scan_deferred( &self, device: &Device, queue: &Queue, counts: &Buffer, n: u32, ) -> Result<DeferredScan>
The same scan, leaving the total in GPU memory.
Nothing is read back and nothing is waited on, so the caller can carry on
recording work. Pair it with
write_draw_args to turn the total into a draw
the GPU issues to itself.
n = 0 is the empty scan: total holds zero, offsets is a 4-byte
placeholder nothing will read, and no dispatch is recorded.
§Errors
Error::ScanTooLong if level 0 needs more workgroups than the device
dispatches per dimension. Checked here rather than trusted, because the
symptom of not checking is a wgpu validation panic instead of a named
error.
Sourcepub fn write_draw_args(
&self,
device: &Device,
queue: &Queue,
total: &Buffer,
indirect: &Buffer,
draw_params: &Buffer,
batch: u32,
budget: u32,
)
pub fn write_draw_args( &self, device: &Device, queue: &Queue, total: &Buffer, indirect: &Buffer, draw_params: &Buffer, batch: u32, budget: u32, )
Turn a scanned total into a mesh-shader draw the GPU issues to itself.
Writes [ceil(drawn / batch), 1, 1] into indirect for
draw_mesh_tasks_indirect, and drawn into draw_params for the
shader’s own bound — where drawn = min(total, budget), so the draw
stops where the emit pass stopped writing. Neither number is ever known
to the CPU; the un-clamped total stays in the scan’s own buffer for the
caller who asks whether truncation happened.
indirect needs INDIRECT | STORAGE; draw_params needs
UNIFORM | STORAGE.