TlasInstance

Struct TlasInstance 

Source
pub struct TlasInstance {
    pub(crate) blas: DispatchBlas,
    pub transform: [f32; 12],
    pub custom_data: u32,
    pub mask: u8,
}
Expand description

Safe instance for a Tlas.

A TlasInstance may be made invalid, if a TlasInstance is invalid, any attempt to build a Tlas 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
  • A user accessible transformation matrix
  • A user accessible mask
  • A user accessible custom index

Fields§

§blas: DispatchBlas§transform: [f32; 12]

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

§custom_data: 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_data: 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_data: 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.

Source

pub fn blas_as_custom<T: BlasInterface>(&self) -> Option<&T>

Available on custom only.

Returns custom implementation of the BLAS referenced by this instance (if the custom backend is active and the BLAS is internally of type T).

Trait Implementations§

Source§

impl Clone for TlasInstance

Source§

fn clone(&self) -> TlasInstance

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 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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

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

impl<T> Upcast<T> for T

§

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

Source§

impl<T> CommonTraits for T
where T: AsAny + Any + Debug + WasmNotSendSync,

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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