mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 23:05:43 +00:00
Add some constructors for Usage
This commit is contained in:
parent
300ac96524
commit
6db8e56380
@ -467,6 +467,9 @@ impl<T: ?Sized, M> Drop for Buffer<T, M> {
|
||||
/// Describes how a buffer is going to be used. This is **not** an optimization.
|
||||
///
|
||||
/// If you try to use a buffer in a way that you didn't declare, a panic will happen.
|
||||
///
|
||||
/// Some methods are provided to build `Usage` structs for some common situations. However
|
||||
/// there is no restriction in the combination of usages that can be enabled.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct Usage {
|
||||
pub transfer_source: bool,
|
||||
@ -522,6 +525,64 @@ impl Usage {
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a `Usage` with `vertex_buffer` set to true and the rest to false.
|
||||
#[inline]
|
||||
pub fn vertex_buffer() -> Usage {
|
||||
Usage {
|
||||
vertex_buffer: true,
|
||||
.. Usage::none()
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a `Usage` with `vertex_buffer` and `transfer_dest` set to true and the rest to false.
|
||||
#[inline]
|
||||
pub fn vertex_buffer_transfer_dest() -> Usage {
|
||||
Usage {
|
||||
vertex_buffer: true,
|
||||
transfer_dest: true,
|
||||
.. Usage::none()
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a `Usage` with `index_buffer` set to true and the rest to false.
|
||||
#[inline]
|
||||
pub fn index_buffer() -> Usage {
|
||||
Usage {
|
||||
index_buffer: true,
|
||||
.. Usage::none()
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a `Usage` with `index_buffer` and `transfer_dest` set to true and the rest to false.
|
||||
#[inline]
|
||||
pub fn index_buffer_transfer_dest() -> Usage {
|
||||
Usage {
|
||||
index_buffer: true,
|
||||
transfer_dest: true,
|
||||
.. Usage::none()
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a `Usage` with `uniform_buffer` set to true and the rest to false.
|
||||
#[inline]
|
||||
pub fn uniform_buffer() -> Usage {
|
||||
Usage {
|
||||
uniform_buffer: true,
|
||||
.. Usage::none()
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a `Usage` with `uniform_buffer` and `transfer_dest` set to true and the rest
|
||||
/// to false.
|
||||
#[inline]
|
||||
pub fn uniform_buffer_transfer_dest() -> Usage {
|
||||
Usage {
|
||||
uniform_buffer: true,
|
||||
transfer_dest: true,
|
||||
.. Usage::none()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_usage_bits(&self) -> vk::BufferUsageFlagBits {
|
||||
let mut result = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user