mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-21 14:24:18 +00:00
Add Suballocation[Node]::as[_usize]_range
(#2586)
This commit is contained in:
parent
303bdfc9e3
commit
8a365cf905
@ -12,6 +12,7 @@ use crate::{image::ImageTiling, DeviceSize};
|
||||
use std::{
|
||||
error::Error,
|
||||
fmt::{self, Debug, Display},
|
||||
ops::Range,
|
||||
};
|
||||
|
||||
mod buddy;
|
||||
@ -287,6 +288,24 @@ pub struct Suballocation {
|
||||
pub handle: AllocationHandle,
|
||||
}
|
||||
|
||||
impl Suballocation {
|
||||
/// Returns the suballocation as a `DeviceSize` range.
|
||||
///
|
||||
/// This is identical to `self.offset..self.offset + self.size`.
|
||||
#[inline]
|
||||
pub fn as_range(&self) -> Range<DeviceSize> {
|
||||
self.offset..self.offset + self.size
|
||||
}
|
||||
|
||||
/// Returns the suballocation as a `usize` range.
|
||||
///
|
||||
/// This is identical to `self.offset as usize..(self.offset + self.size) as usize`.
|
||||
#[inline]
|
||||
pub fn as_usize_range(&self) -> Range<usize> {
|
||||
self.offset as usize..(self.offset + self.size) as usize
|
||||
}
|
||||
}
|
||||
|
||||
/// Error that can be returned when creating an [allocation] using a [suballocator].
|
||||
///
|
||||
/// [allocation]: Suballocation
|
||||
@ -331,6 +350,24 @@ pub struct SuballocationNode {
|
||||
pub allocation_type: SuballocationType,
|
||||
}
|
||||
|
||||
impl SuballocationNode {
|
||||
/// Returns the suballocation as a `DeviceSize` range.
|
||||
///
|
||||
/// This is identical to `self.offset..self.offset + self.size`.
|
||||
#[inline]
|
||||
pub fn as_range(&self) -> Range<DeviceSize> {
|
||||
self.offset..self.offset + self.size
|
||||
}
|
||||
|
||||
/// Returns the suballocation as a `usize` range.
|
||||
///
|
||||
/// This is identical to `self.offset as usize..(self.offset + self.size) as usize`.
|
||||
#[inline]
|
||||
pub fn as_usize_range(&self) -> Range<usize> {
|
||||
self.offset as usize..(self.offset + self.size) as usize
|
||||
}
|
||||
}
|
||||
|
||||
/// Tells us if an allocation within a [suballocator]'s list/tree of suballocations is free, and if
|
||||
/// not, what type of resources can be bound to it. The suballocator needs to keep track of this in
|
||||
/// order to be able to respect the buffer-image granularity.
|
||||
|
Loading…
Reference in New Issue
Block a user