Skip to main content

GpuSdfMultiDispatch

Struct GpuSdfMultiDispatch 

Source
pub struct GpuSdfMultiDispatch {
    pub batches: Vec<GpuSdfInstancedBatch>,
}
Expand description

Multi-SDF dispatch — groups queries by SDF for the minimum number of GPU kernel calls per frame (one dispatch per unique sdf_id).

§Usage

use alice_physics::gpu_sdf::{GpuSdfMultiDispatch, GpuSdfQuery};

let mut dispatch = GpuSdfMultiDispatch::new();
let sphere_queries = vec![GpuSdfQuery { x: 0.0, y: 0.0, z: 0.0, radius: 0.5 }];
let box_queries = vec![GpuSdfQuery { x: 1.0, y: 1.0, z: 1.0, radius: 0.0 }];
dispatch.add_batch(0, sphere_queries);
dispatch.add_batch(1, box_queries);

assert_eq!(dispatch.total_queries(), 2);
assert_eq!(dispatch.total_dispatches(), 2);

Fields§

§batches: Vec<GpuSdfInstancedBatch>

One entry per unique SDF — ordered by insertion.

Implementations§

Source§

impl GpuSdfMultiDispatch

Source

pub const fn new() -> Self

Create an empty multi-dispatch container.

Source

pub fn add_batch(&mut self, sdf_id: u32, queries: Vec<GpuSdfQuery>)

Append a batch of queries for a single SDF.

sdf_id identifies which GPU-side SDF buffer to bind during this dispatch. Queries for an sdf_id that already has a batch are appended to it (in call order), so there is one batch, and one dispatch, per unique sdf_id; batches keep the order of their first add_batch.

Source

pub fn total_queries(&self) -> usize

Total number of individual SDF point queries across all batches.

Source

pub fn total_dispatches(&self) -> usize

Number of GPU kernel dispatches that will be issued (one per batch, so one per unique sdf_id).

Trait Implementations§

Source§

impl Default for GpuSdfMultiDispatch

Source§

fn default() -> Self

Returns the “default value” for a type. 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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.