Skip to main content

PrefixScan

Struct PrefixScan 

Source
pub struct PrefixScan { /* private fields */ }
Expand description

The compiled scan pipelines.

Implementations§

Source§

impl PrefixScan

Source

pub const BLOCK: u32 = BLOCK

Elements one workgroup scans.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for PrefixScan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,