Struct wgpu::TlasInstance

source ·
pub struct TlasInstance {
    pub transform: [f32; 12],
    pub custom_index: u32,
    pub mask: u8,
    /* private fields */
}
Expand description

Safe instance for a Tlas.

A TlasInstance may be made invalid, if a TlasInstance is invalid, any attempt to build a TlasPackage containing an invalid TlasInstance will generate a validation error

Each one contains:

  • A reference to a BLAS, this must be interacted with using TlasInstance::new or TlasInstance::set_blas, a TlasInstance that references a BLAS keeps that BLAS from being dropped, but if the BLAS is explicitly destroyed (e.g. using Blas::destroy) the TlasInstance becomes invalid
  • A user accessible transformation matrix
  • A user accessible mask
  • A user accessible custom index

Fields§

§transform: [f32; 12]

Affine transform matrix 3x4 (rows x columns, row major order).

§custom_index: u32

Custom index for the instance used inside the shader.

This must only use the lower 24 bits, if any bits are outside that range (byte 4 does not equal 0) the TlasInstance becomes invalid and generates a validation error when built

§mask: u8

Mask for the instance used inside the shader to filter instances. Reports hit only if (shader_cull_mask & tlas_instance.mask) != 0u.

Implementations§

source§

impl TlasInstance

source

pub fn new( blas: &Blas, transform: [f32; 12], custom_index: u32, mask: u8 ) -> Self

Construct TlasInstance.

  • blas: Reference to the bottom level acceleration structure
  • transform: Transform buffer offset in bytes (optional, required if transform buffer is present)
  • custom_index: Custom index for the instance used inside the shader (max 24 bits)
  • mask: Mask for the instance used inside the shader to filter instances

Note: while one of these contains a reference to a BLAS that BLAS will not be dropped, but it can still be destroyed. Destroying a BLAS that is referenced by one or more TlasInstance(s) will immediately make them invalid. If one or more of those invalid TlasInstances is inside a TlasPackage that is attempted to be built, the build will generate a validation error.

source

pub fn set_blas(&mut self, blas: &Blas)

Set the bottom level acceleration structure.

See the note on TlasInstance about the guarantees of keeping a BLAS alive.

Trait Implementations§

source§

impl Clone for TlasInstance

source§

fn clone(&self) -> TlasInstance

Returns a copy 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 Debug for TlasInstance

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
§

impl<T> Downcast<T> for T

§

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

§

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>,

§

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>,

§

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.
§

impl<T> Upcast<T> for T

§

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,