pub struct TlasInstance {
pub(crate) blas: DispatchBlas,
pub transform: [f32; 12],
pub custom_index: 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 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
- 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_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
impl TlasInstance
sourcepub fn new(
blas: &Blas,
transform: [f32; 12],
custom_index: u32,
mask: u8,
) -> Self
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.
sourcepub fn set_blas(&mut self, blas: &Blas)
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
impl Clone for TlasInstance
source§fn clone(&self) -> TlasInstance
fn clone(&self) -> TlasInstance
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for TlasInstance
impl !RefUnwindSafe for TlasInstance
impl Send for TlasInstance
impl Sync for TlasInstance
impl Unpin for TlasInstance
impl !UnwindSafe for TlasInstance
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)