mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 06:45:23 +00:00
Add a reinterpret
function to BufferSlice
(#1038)
Add a `reinterpret` function to `BufferSlice`
This commit is contained in:
parent
d8bcc6b126
commit
e3bfe4270c
@ -1,8 +1,9 @@
|
||||
# Unreleased (Breaking)
|
||||
|
||||
- Split 'PersistentDescriptorSetError::MissingUsage' into 'MissingImageUsage' and 'MissingBufferUsage'
|
||||
- Split `PersistentDescriptorSetError::MissingUsage` into `MissingImageUsage` and `MissingBufferUsage`
|
||||
each with a matching enum indicating the usage that was missing.
|
||||
- Fix instance_count when using draw_index with instance buffers
|
||||
- Added a `reinterpret` function to `BufferSlice`
|
||||
|
||||
# Version 0.10.0 (2018-08-10)
|
||||
|
||||
|
@ -132,6 +132,38 @@ impl<T: ?Sized, B> BufferSlice<T, B> {
|
||||
size: size,
|
||||
}
|
||||
}
|
||||
|
||||
/// Changes the `T` generic parameter of the `BufferSlice` to the desired type. This can be
|
||||
/// useful when you have a buffer with various types of data and want to create a typed slice
|
||||
/// of a region that contains a single type of data.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// # use std::sync::Arc;
|
||||
/// # use vulkano::buffer::BufferSlice;
|
||||
/// # use vulkano::buffer::immutable::ImmutableBuffer;
|
||||
/// # struct VertexImpl;
|
||||
/// let blob_slice: BufferSlice<[u8], Arc<ImmutableBuffer<[u8]>>> = return;
|
||||
/// let vertex_slice: BufferSlice<[VertexImpl], Arc<ImmutableBuffer<[u8]>>> = unsafe {
|
||||
/// blob_slice.reinterpret::<[VertexImpl]>()
|
||||
/// };
|
||||
/// ```
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Correct `offset` and `size` must be ensured before using this `BufferSlice` on the device.
|
||||
/// See `BufferSlice::slice` for adjusting these properties.
|
||||
#[inline]
|
||||
pub unsafe fn reinterpret<R: ?Sized>(self) -> BufferSlice<R, B>
|
||||
{
|
||||
BufferSlice {
|
||||
marker: PhantomData,
|
||||
resource: self.resource,
|
||||
offset: self.offset,
|
||||
size: self.size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B> BufferSlice<[T], B> {
|
||||
|
Loading…
Reference in New Issue
Block a user