GaussiansBuffer

Struct GaussiansBuffer 

Source
pub struct GaussiansBuffer<G: GaussianPod>(/* private fields */);
Expand description

The Gaussians storage buffer.

This buffer holds an array of Gaussians represented by the specified GaussianPod.

Implementations§

Source§

impl<G: GaussianPod> GaussiansBuffer<G>

Source

pub fn new(device: &Device, gaussians: &impl IterGaussian) -> Self

Create a new Gaussians buffer.

Examples found in repository?
examples/read_ply.rs (line 40)
15async fn main() {
16    let model_path = std::env::args()
17        .nth(1)
18        .unwrap_or_else(|| "examples/model.ply".to_string());
19
20    let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::default());
21
22    let adapter = instance
23        .request_adapter(&wgpu::RequestAdapterOptions::default())
24        .await
25        .expect("adapter");
26
27    let (device, _) = adapter
28        .request_device(&wgpu::DeviceDescriptor {
29            label: Some("Device"),
30            required_limits: adapter.limits(),
31            ..Default::default()
32        })
33        .await
34        .expect("device");
35
36    println!("Reading gaussians from {}", model_path);
37
38    let gaussians = gs::PlyGaussians::read_from_file(&model_path).expect("gaussians");
39
40    let gaussians_buffer = gs::GaussiansBuffer::<GaussianPod>::new(&device, &gaussians);
41
42    println!(
43        "Loaded {} gaussians ({:.3} KB) into GPU buffer.",
44        gaussians_buffer.len(),
45        gaussians_buffer.buffer().size() as f32 / 1024.0,
46    );
47}
More examples
Hide additional examples
examples/read_spz.rs (line 42)
15async fn main() {
16    let model_path = std::env::args()
17        .nth(1)
18        .unwrap_or_else(|| "examples/model.spz".to_string());
19
20    let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::default());
21
22    let adapter = instance
23        .request_adapter(&wgpu::RequestAdapterOptions::default())
24        .await
25        .expect("adapter");
26
27    let (device, _) = adapter
28        .request_device(&wgpu::DeviceDescriptor {
29            label: Some("Device"),
30            required_limits: adapter.limits(),
31            ..Default::default()
32        })
33        .await
34        .expect("device");
35
36    println!("Reading gaussians from {}", model_path);
37
38    let gaussians = gs::SpzGaussians::read_from_file(&model_path).expect("gaussians");
39
40    println!("Header: {:?}", gaussians.header);
41
42    let gaussians_buffer = gs::GaussiansBuffer::<GaussianPod>::new(&device, &gaussians);
43
44    println!(
45        "Loaded {} gaussians ({:.3} KB) into GPU buffer.",
46        gaussians_buffer.len(),
47        gaussians_buffer.buffer().size() as f32 / 1024.0,
48    );
49}
Source

pub fn new_with_usage( device: &Device, gaussians: &impl IterGaussian, usage: BufferUsages, ) -> Self

Create a new Gaussians buffer with the specified size with wgpu::BufferUsages.

Source

pub fn new_with_pods(device: &Device, gaussians: &[G]) -> Self

Create a new Gaussians buffer with GaussianPod.

Source

pub fn new_with_pods_and_usage( device: &Device, gaussians: &[G], usage: BufferUsages, ) -> Self

Create a new Gaussians buffer with GaussianPod and the specified size and wgpu::BufferUsages.

Source

pub fn new_empty(device: &Device, len: usize) -> Self

Create a new Gaussians buffer with the specified size.

Source

pub fn new_empty_with_usage( device: &Device, len: usize, usage: BufferUsages, ) -> Self

Create a new Gaussians buffer with the specified size and wgpu::BufferUsages.

Source

pub fn len(&self) -> usize

Get the number of Gaussians.

Examples found in repository?
examples/read_ply.rs (line 44)
15async fn main() {
16    let model_path = std::env::args()
17        .nth(1)
18        .unwrap_or_else(|| "examples/model.ply".to_string());
19
20    let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::default());
21
22    let adapter = instance
23        .request_adapter(&wgpu::RequestAdapterOptions::default())
24        .await
25        .expect("adapter");
26
27    let (device, _) = adapter
28        .request_device(&wgpu::DeviceDescriptor {
29            label: Some("Device"),
30            required_limits: adapter.limits(),
31            ..Default::default()
32        })
33        .await
34        .expect("device");
35
36    println!("Reading gaussians from {}", model_path);
37
38    let gaussians = gs::PlyGaussians::read_from_file(&model_path).expect("gaussians");
39
40    let gaussians_buffer = gs::GaussiansBuffer::<GaussianPod>::new(&device, &gaussians);
41
42    println!(
43        "Loaded {} gaussians ({:.3} KB) into GPU buffer.",
44        gaussians_buffer.len(),
45        gaussians_buffer.buffer().size() as f32 / 1024.0,
46    );
47}
More examples
Hide additional examples
examples/read_spz.rs (line 46)
15async fn main() {
16    let model_path = std::env::args()
17        .nth(1)
18        .unwrap_or_else(|| "examples/model.spz".to_string());
19
20    let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::default());
21
22    let adapter = instance
23        .request_adapter(&wgpu::RequestAdapterOptions::default())
24        .await
25        .expect("adapter");
26
27    let (device, _) = adapter
28        .request_device(&wgpu::DeviceDescriptor {
29            label: Some("Device"),
30            required_limits: adapter.limits(),
31            ..Default::default()
32        })
33        .await
34        .expect("device");
35
36    println!("Reading gaussians from {}", model_path);
37
38    let gaussians = gs::SpzGaussians::read_from_file(&model_path).expect("gaussians");
39
40    println!("Header: {:?}", gaussians.header);
41
42    let gaussians_buffer = gs::GaussiansBuffer::<GaussianPod>::new(&device, &gaussians);
43
44    println!(
45        "Loaded {} gaussians ({:.3} KB) into GPU buffer.",
46        gaussians_buffer.len(),
47        gaussians_buffer.buffer().size() as f32 / 1024.0,
48    );
49}
Source

pub fn is_empty(&self) -> bool

Check if the buffer is empty.

Source

pub fn update( &self, queue: &Queue, gaussians: &impl IterGaussian, ) -> Result<(), GaussiansBufferUpdateError>

Update the buffer.

gaussians should have the same number of Gaussians as the buffer.

Source

pub fn update_with_pod( &self, queue: &Queue, pods: &[G], ) -> Result<(), GaussiansBufferUpdateError>

Update the buffer with GaussianPod.

pods should have the same number of Gaussians as the buffer.

Source

pub fn update_range( &self, queue: &Queue, start: usize, gaussians: &[Gaussian], ) -> Result<(), GaussiansBufferUpdateRangeError>

Update a range of the buffer.

gaussians should fit in the buffer starting from start.

Source

pub fn update_range_with_pod( &self, queue: &Queue, start: usize, pods: &[G], ) -> Result<(), GaussiansBufferUpdateRangeError>

Update a range of the buffer with GaussianPod.

pods should fit in the buffer starting from start.

Source

pub async fn download_gaussians( &self, device: &Device, queue: &Queue, ) -> Result<Vec<Gaussian>, DownloadBufferError>

Download the buffer data into a Vec of Gaussian.

Trait Implementations§

Source§

impl<G: GaussianPod> BufferWrapper for GaussiansBuffer<G>

Source§

const DEFAULT_USAGES: BufferUsages

The default usages.
Source§

fn buffer(&self) -> &Buffer

Returns a reference to the buffer data.
Source§

fn download<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, device: &'life1 Device, queue: &'life2 Queue, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>, DownloadBufferError>> + Send + 'async_trait>>
where Self: Send + Sync + 'async_trait, T: 'async_trait + NoUninit + AnyBitPattern, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Download the buffer data into a Vec.
Source§

fn prepare_download( &self, device: &Device, encoder: &mut CommandEncoder, ) -> Buffer

Prepare for downloading the buffer data. Read more
Source§

fn map_download<'life0, 'life1, 'async_trait, T>( download: &'life0 Buffer, device: &'life1 Device, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>, DownloadBufferError>> + Send + 'async_trait>>
where T: 'async_trait + NoUninit + AnyBitPattern, Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Map the download buffer to read the buffer data. Read more
Source§

fn map_download_with_poll_type<'life0, 'life1, 'async_trait, T>( download: &'life0 Buffer, device: &'life1 Device, poll_type: PollType, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>, DownloadBufferError>> + Send + 'async_trait>>
where T: 'async_trait + NoUninit + AnyBitPattern, 'life0: 'async_trait, 'life1: 'async_trait,

Map the download buffer to read the buffer data with custom wgpu::PollType. Read more
Source§

impl<G: Clone + GaussianPod> Clone for GaussiansBuffer<G>

Source§

fn clone(&self) -> GaussiansBuffer<G>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<G: Debug + GaussianPod> Debug for GaussiansBuffer<G>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<G: GaussianPod> From<GaussiansBuffer<G>> for Buffer

Source§

fn from(wrapper: GaussiansBuffer<G>) -> Self

Converts to this type from the input type.
Source§

impl<G: GaussianPod> TryFrom<Buffer> for GaussiansBuffer<G>

Source§

type Error = GaussiansBufferTryFromBufferError

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

fn try_from(buffer: Buffer) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<G> Freeze for GaussiansBuffer<G>

§

impl<G> !RefUnwindSafe for GaussiansBuffer<G>

§

impl<G> Send for GaussiansBuffer<G>

§

impl<G> Sync for GaussiansBuffer<G>

§

impl<G> Unpin for GaussiansBuffer<G>
where G: Unpin,

§

impl<G> !UnwindSafe for GaussiansBuffer<G>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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