Skip to main content

AccelerationStructure

Struct AccelerationStructure 

Source
pub struct AccelerationStructure {
    pub buffer: Buffer,
    pub handle: AccelerationStructureKHR,
    pub info: AccelerationStructureInfo,
    pub name: Option<String>,
    /* private fields */
}
Expand description

Smart pointer handle to an [acceleration structure] object.

Also contains the backing buffer and information about the object.

let info = AccelerationStructureInfo::blas(0);
let accel_struct = AccelerationStructure::create(&device, info)?;
let addr = accel_struct.device_address();

assert_eq!(accel_struct.info, info);
assert_ne!(accel_struct.handle, vk::AccelerationStructureKHR::null());

See VkAccelerationStructureKHR.

Fields§

§buffer: Buffer

The native Vulkan resource handle of the buffer which supports this acceleration structure.

Note: This field is read-only.

§handle: AccelerationStructureKHR

The native Vulkan resource handle of this acceleration structure.

Note: This field is read-only.

§info: AccelerationStructureInfo

Information used to create this object.

Note: This field is read-only.

§name: Option<String>

A name for debugging purposes.

Implementations§

Source§

impl AccelerationStructure

Source

pub fn create( device: &Device, info: impl Into<AccelerationStructureInfo>, ) -> Result<Self, DriverError>

Creates a new acceleration structure on the given device.

§Examples

Basic usage:

const SIZE: vk::DeviceSize = 1024;
let info = AccelerationStructureInfo::blas(SIZE);
let accel_struct = AccelerationStructure::create(&device, info)?;

assert_ne!(accel_struct.handle, vk::AccelerationStructureKHR::null());
assert_eq!(accel_struct.info.size, SIZE);
Source

pub fn access(&self, next_access: AccessType) -> AccessType

Keeps track of some next_access which affects this object.

Returns the previous access for which a pipeline barrier should be used to prevent data corruption.

§Note

Used to maintain object state when passing a vk-graph-created vk::AccelerationStructureKHR handle to external code such as Ash or Erupt bindings.

§Examples

Basic usage:

// Initially we want to "Build Write"
let next = AccessType::AccelerationStructureBuildWrite;
let prev = AccelerationStructure::access(&my_accel_struct, next);
assert_eq!(prev, AccessType::Nothing);

// External code may now "Build Write"; no barrier required

// Subsequently we want to "Build Read"
let next = AccessType::AccelerationStructureBuildRead;
let prev = AccelerationStructure::access(&my_accel_struct, next);
assert_eq!(prev, AccessType::AccelerationStructureBuildWrite);

// A barrier on "Build Write" before "Build Read" is required!
Source

pub fn debug_name(self, name: impl Into<String>) -> Self

Sets the debugging name assigned to this acceleration structure.

Source

pub fn device_address(&self) -> DeviceAddress

Returns the device address of this object.

§Examples

Basic usage:

let addr = AccelerationStructure::device_address(&my_accel_struct);

assert_ne!(addr, 0);
Source

pub fn instance_slice(instances: &[AccelerationStructureInstanceKHR]) -> &[u8]

Helper function which is used to prepare instance buffers.

Source

pub fn size_of( device: &Device, info: &AccelerationStructureGeometryInfo<impl AsRef<AccelerationStructureGeometry>>, ) -> AccelerationStructureSize

Returns the size of some geometry info which is then used to create a new AccelerationStructure instance or update an existing instance.

§Examples

Basic usage:

let my_geom = AccelerationStructureGeometry {
    max_primitive_count: 1,
    flags: vk::GeometryFlagsKHR::OPAQUE,
    geometry: my_geom_triangles,
};
let build_range = vk::AccelerationStructureBuildRangeInfoKHR {
    primitive_count: 1,
    primitive_offset: 0,
    first_vertex: 0,
    transform_offset: 0,
};
let my_info = AccelerationStructureGeometryInfo::blas([(my_geom, build_range)]);
let res = AccelerationStructure::size_of(&device, &my_info);

assert_eq!(res.create_size, 2432);
assert_eq!(res.build_size, 640);
assert_eq!(res.update_size, 0);

Trait Implementations§

Source§

impl Debug for AccelerationStructure

Source§

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

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

impl Drop for AccelerationStructure

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl PartialEq for AccelerationStructure

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Pool<AccelerationStructureInfo, AccelerationStructure> for FifoPool

Source§

impl Pool<AccelerationStructureInfo, AccelerationStructure> for HashPool

Source§

impl Pool<AccelerationStructureInfo, AccelerationStructure> for LazyPool

Source§

impl Resource for AccelerationStructure

Source§

type Node = AccelerationStructureNode

The resource handle type.
Source§

impl Eq for AccelerationStructure

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> Pool<AccelerationStructureInfoBuilder, AccelerationStructure> for T

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.