pub struct AccelerationStructure {
    pub buffer: Buffer,
    pub info: AccelerationStructureInfo,
    /* private fields */
}
Expand description

Smart pointer handle to an acceleration structure object.

Also contains the backing buffer and information about the object.

Deref behavior

AccelerationStructure automatically dereferences to vk::AccelerationStructureKHR (via the Deref trait), so you can call vk::AccelerationStructureKHR’s methods on a value of type AccelerationStructure. To avoid name clashes with vk::AccelerationStructureKHR’s methods, the methods of AccelerationStructure itself are associated functions, called using fully qualified syntax:

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

Fields

buffer: Buffer

Backing storage buffer for this object.

info: AccelerationStructureInfo

Information used to create this object.

Implementations

Creates a new acceleration structure on the given device.

Examples

Basic usage:

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

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

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 Screen 13-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!

Returns the device address of this object.

Examples

Basic usage:

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

assert_ne!(addr, 0);

Helper function which is used to prepare instance buffers.

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_info = AccelerationStructureGeometryInfo {
    ty: vk::AccelerationStructureTypeKHR::BOTTOM_LEVEL,
    flags: vk::BuildAccelerationStructureFlagsKHR::empty(),
    geometries: vec![AccelerationStructureGeometry {
        max_primitive_count: 1,
        flags: vk::GeometryFlagsKHR::OPAQUE,
        geometry: my_geom,
    }],
};
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

Binds the resource to a graph-like object. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Executes the destructor for this type. Read more
Lease a resource.
Lease a resource.
Lease a resource.
Lease a resource.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.