Take BufferUsage by value and never by ref

This commit is contained in:
Pierre Krieger 2017-05-19 15:26:57 +02:00
parent 421617eea8
commit 1e62e4fc78
11 changed files with 64 additions and 64 deletions

View File

@ -69,7 +69,7 @@ fn main() {
impl_vertex!(Vertex, position);
let vertex_buffer = vulkano::buffer::cpu_access::CpuAccessibleBuffer::<[Vertex]>
::from_iter(&device, &vulkano::buffer::BufferUsage::all(),
::from_iter(&device, vulkano::buffer::BufferUsage::all(),
Some(queue.family()), [
Vertex { position: [-0.5, -0.5 ] },
Vertex { position: [-0.5, 0.5 ] },
@ -112,7 +112,7 @@ fn main() {
// TODO: staging buffer instead
vulkano::buffer::cpu_access::CpuAccessibleBuffer::<[[u8; 4]]>
::from_iter(&device, &vulkano::buffer::BufferUsage::all(),
::from_iter(&device, vulkano::buffer::BufferUsage::all(),
Some(queue.family()), image_data_chunks)
.expect("failed to create buffer")
};

View File

@ -72,15 +72,15 @@ fn main() {
let depth_buffer = vulkano::image::attachment::AttachmentImage::transient(&device, images[0].dimensions(), vulkano::format::D16Unorm).unwrap().access();
let vertex_buffer = vulkano::buffer::cpu_access::CpuAccessibleBuffer
::from_iter(&device, &vulkano::buffer::BufferUsage::all(), Some(queue.family()), examples::VERTICES.iter().cloned())
::from_iter(&device, vulkano::buffer::BufferUsage::all(), Some(queue.family()), examples::VERTICES.iter().cloned())
.expect("failed to create buffer");
let normals_buffer = vulkano::buffer::cpu_access::CpuAccessibleBuffer
::from_iter(&device, &vulkano::buffer::BufferUsage::all(), Some(queue.family()), examples::NORMALS.iter().cloned())
::from_iter(&device, vulkano::buffer::BufferUsage::all(), Some(queue.family()), examples::NORMALS.iter().cloned())
.expect("failed to create buffer");
let index_buffer = vulkano::buffer::cpu_access::CpuAccessibleBuffer
::from_iter(&device, &vulkano::buffer::BufferUsage::all(), Some(queue.family()), examples::INDICES.iter().cloned())
::from_iter(&device, vulkano::buffer::BufferUsage::all(), Some(queue.family()), examples::INDICES.iter().cloned())
.expect("failed to create buffer");
// note: this teapot was meant for OpenGL where the origin is at the lower left
@ -90,7 +90,7 @@ fn main() {
let scale = cgmath::Matrix4::from_scale(0.01);
let uniform_buffer = vulkano::buffer::cpu_access::CpuAccessibleBuffer::<vs::ty::Data>
::from_data(&device, &vulkano::buffer::BufferUsage::all(), Some(queue.family()),
::from_data(&device, vulkano::buffer::BufferUsage::all(), Some(queue.family()),
vs::ty::Data {
world : <cgmath::Matrix4<f32> as cgmath::SquareMatrix>::identity().into(),
view : (view * scale).into(),

View File

@ -194,7 +194,7 @@ fn main() {
struct Vertex { position: [f32; 2] }
impl_vertex!(Vertex, position);
CpuAccessibleBuffer::from_iter(&device, &BufferUsage::all(), Some(queue.family()), [
CpuAccessibleBuffer::from_iter(&device, BufferUsage::all(), Some(queue.family()), [
Vertex { position: [-0.5, -0.25] },
Vertex { position: [0.0, 0.5] },
Vertex { position: [0.25, -0.1] }

View File

@ -77,7 +77,7 @@ impl<T> CpuAccessibleBuffer<T> {
/// Deprecated. Use `from_data` instead.
#[deprecated]
#[inline]
pub fn new<'a, I>(device: &Arc<Device>, usage: &BufferUsage, queue_families: I)
pub fn new<'a, I>(device: &Arc<Device>, usage: BufferUsage, queue_families: I)
-> Result<Arc<CpuAccessibleBuffer<T>>, OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -87,7 +87,7 @@ impl<T> CpuAccessibleBuffer<T> {
}
/// Builds a new buffer with some data in it. Only allowed for sized data.
pub fn from_data<'a, I>(device: &Arc<Device>, usage: &BufferUsage, queue_families: I, data: T)
pub fn from_data<'a, I>(device: &Arc<Device>, usage: BufferUsage, queue_families: I, data: T)
-> Result<Arc<CpuAccessibleBuffer<T>>, OomError>
where I: IntoIterator<Item = QueueFamily<'a>>,
T: Content + 'static,
@ -112,7 +112,7 @@ impl<T> CpuAccessibleBuffer<T> {
/// Builds a new uninitialized buffer. Only allowed for sized data.
#[inline]
pub unsafe fn uninitialized<'a, I>(device: &Arc<Device>, usage: &BufferUsage, queue_families: I)
pub unsafe fn uninitialized<'a, I>(device: &Arc<Device>, usage: BufferUsage, queue_families: I)
-> Result<Arc<CpuAccessibleBuffer<T>>, OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -123,7 +123,7 @@ impl<T> CpuAccessibleBuffer<T> {
impl<T> CpuAccessibleBuffer<[T]> {
/// Builds a new buffer that contains an array `T`. The initial data comes from an iterator
/// that produces that list of Ts.
pub fn from_iter<'a, I, Q>(device: &Arc<Device>, usage: &BufferUsage, queue_families: Q, data: I)
pub fn from_iter<'a, I, Q>(device: &Arc<Device>, usage: BufferUsage, queue_families: Q, data: I)
-> Result<Arc<CpuAccessibleBuffer<[T]>>, OomError>
where I: ExactSizeIterator<Item = T>,
T: Content + 'static,
@ -154,7 +154,7 @@ impl<T> CpuAccessibleBuffer<[T]> {
// TODO: remove
#[inline]
#[deprecated]
pub fn array<'a, I>(device: &Arc<Device>, len: usize, usage: &BufferUsage, queue_families: I)
pub fn array<'a, I>(device: &Arc<Device>, len: usize, usage: BufferUsage, queue_families: I)
-> Result<Arc<CpuAccessibleBuffer<[T]>>, OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -165,7 +165,7 @@ impl<T> CpuAccessibleBuffer<[T]> {
/// Builds a new buffer. Can be used for arrays.
#[inline]
pub unsafe fn uninitialized_array<'a, I>(device: &Arc<Device>, len: usize, usage: &BufferUsage,
pub unsafe fn uninitialized_array<'a, I>(device: &Arc<Device>, len: usize, usage: BufferUsage,
queue_families: I)
-> Result<Arc<CpuAccessibleBuffer<[T]>>, OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
@ -181,7 +181,7 @@ impl<T: ?Sized> CpuAccessibleBuffer<T> {
///
/// You must ensure that the size that you pass is correct for `T`.
///
pub unsafe fn raw<'a, I>(device: &Arc<Device>, size: usize, usage: &BufferUsage, queue_families: I)
pub unsafe fn raw<'a, I>(device: &Arc<Device>, size: usize, usage: BufferUsage, queue_families: I)
-> Result<Arc<CpuAccessibleBuffer<T>>, OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -195,7 +195,7 @@ impl<T: ?Sized> CpuAccessibleBuffer<T> {
Sharing::Exclusive
};
match UnsafeBuffer::new(device, size, &usage, sharing, SparseLevel::none()) {
match UnsafeBuffer::new(device, size, usage, sharing, SparseLevel::none()) {
Ok(b) => b,
Err(BufferCreationError::OomError(err)) => return Err(err),
Err(_) => unreachable!() // We don't use sparse binding, therefore the other

View File

@ -131,7 +131,7 @@ pub struct CpuBufferPoolSubbuffer<T: ?Sized, A> where A: MemoryPool {
impl<T> CpuBufferPool<T> {
#[inline]
pub fn new<'a, I>(device: Arc<Device>, usage: &BufferUsage, queue_families: I)
pub fn new<'a, I>(device: Arc<Device>, usage: BufferUsage, queue_families: I)
-> CpuBufferPool<T>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -146,13 +146,13 @@ impl<T> CpuBufferPool<T> {
/// family accesses.
#[inline]
pub fn upload(device: Arc<Device>) -> CpuBufferPool<T> {
CpuBufferPool::new(device, &BufferUsage::transfer_source(), iter::empty())
CpuBufferPool::new(device, BufferUsage::transfer_source(), iter::empty())
}
}
impl<T> CpuBufferPool<[T]> {
#[inline]
pub fn array<'a, I>(device: Arc<Device>, len: usize, usage: &BufferUsage, queue_families: I)
pub fn array<'a, I>(device: Arc<Device>, len: usize, usage: BufferUsage, queue_families: I)
-> CpuBufferPool<[T]>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -164,7 +164,7 @@ impl<T> CpuBufferPool<[T]> {
impl<T: ?Sized> CpuBufferPool<T> {
pub unsafe fn raw<'a, I>(device: Arc<Device>, one_size: usize,
usage: &BufferUsage, queue_families: I) -> CpuBufferPool<T>
usage: BufferUsage, queue_families: I) -> CpuBufferPool<T>
where I: IntoIterator<Item = QueueFamily<'a>>
{
let queue_families = queue_families.into_iter().map(|f| f.id())
@ -265,7 +265,7 @@ impl<T, A> CpuBufferPool<T, A> where A: MemoryPool {
None => return Err(OomError::OutOfDeviceMemory),
};
match UnsafeBuffer::new(&self.device, total_size, &self.usage, sharing, SparseLevel::none()) {
match UnsafeBuffer::new(&self.device, total_size, self.usage, sharing, SparseLevel::none()) {
Ok(b) => b,
Err(BufferCreationError::OomError(err)) => return Err(err),
Err(_) => unreachable!() // We don't use sparse binding, therefore the other

View File

@ -63,7 +63,7 @@ pub struct DeviceLocalBuffer<T: ?Sized, A = Arc<StdMemoryPool>> where A: MemoryP
impl<T> DeviceLocalBuffer<T> {
/// Builds a new buffer. Only allowed for sized data.
#[inline]
pub fn new<'a, I>(device: &Arc<Device>, usage: &BufferUsage, queue_families: I)
pub fn new<'a, I>(device: &Arc<Device>, usage: BufferUsage, queue_families: I)
-> Result<Arc<DeviceLocalBuffer<T>>, OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -76,7 +76,7 @@ impl<T> DeviceLocalBuffer<T> {
impl<T> DeviceLocalBuffer<[T]> {
/// Builds a new buffer. Can be used for arrays.
#[inline]
pub fn array<'a, I>(device: &Arc<Device>, len: usize, usage: &BufferUsage, queue_families: I)
pub fn array<'a, I>(device: &Arc<Device>, len: usize, usage: BufferUsage, queue_families: I)
-> Result<Arc<DeviceLocalBuffer<[T]>>, OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -93,7 +93,7 @@ impl<T: ?Sized> DeviceLocalBuffer<T> {
///
/// You must ensure that the size that you pass is correct for `T`.
///
pub unsafe fn raw<'a, I>(device: &Arc<Device>, size: usize, usage: &BufferUsage, queue_families: I)
pub unsafe fn raw<'a, I>(device: &Arc<Device>, size: usize, usage: BufferUsage, queue_families: I)
-> Result<Arc<DeviceLocalBuffer<T>>, OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -107,7 +107,7 @@ impl<T: ?Sized> DeviceLocalBuffer<T> {
Sharing::Exclusive
};
match UnsafeBuffer::new(device, size, &usage, sharing, SparseLevel::none()) {
match UnsafeBuffer::new(device, size, usage, sharing, SparseLevel::none()) {
Ok(b) => b,
Err(BufferCreationError::OomError(err)) => return Err(err),
Err(_) => unreachable!() // We don't use sparse binding, therefore the other

View File

@ -93,12 +93,12 @@ impl<T: ?Sized> ImmutableBuffer<T> {
/// the initial upload operation. In order to be allowed to use the `ImmutableBuffer`, you must
/// either submit your operation after this future, or execute this future and wait for it to
/// be finished before submitting your own operation.
pub fn from_data<'a, I>(data: T, usage: &BufferUsage, queue_families: I, queue: Arc<Queue>)
pub fn from_data<'a, I>(data: T, usage: BufferUsage, queue_families: I, queue: Arc<Queue>)
-> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferFromBufferFuture), OomError>
where I: IntoIterator<Item = QueueFamily<'a>>,
T: 'static + Send + Sync + Sized,
{
let source = CpuAccessibleBuffer::from_data(queue.device(), &BufferUsage::transfer_source(),
let source = CpuAccessibleBuffer::from_data(queue.device(), BufferUsage::transfer_source(),
iter::once(queue.family()), data)?;
ImmutableBuffer::from_buffer(source, usage, queue_families, queue)
}
@ -109,7 +109,7 @@ impl<T: ?Sized> ImmutableBuffer<T> {
/// the initial upload operation. In order to be allowed to use the `ImmutableBuffer`, you must
/// either submit your operation after this future, or execute this future and wait for it to
/// be finished before submitting your own operation.
pub fn from_buffer<'a, B, I>(source: B, usage: &BufferUsage, queue_families: I, queue: Arc<Queue>)
pub fn from_buffer<'a, B, I>(source: B, usage: BufferUsage, queue_families: I, queue: Arc<Queue>)
-> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferFromBufferFuture), OomError>
where B: Buffer + TypedBuffer<Content = T> + DeviceOwned, // TODO: remove + DeviceOwned once Buffer requires it
B::Access: 'static + Clone + Send + Sync,
@ -140,7 +140,7 @@ impl<T: ?Sized> ImmutableBuffer<T> {
}
/// Builds an `ImmutableBuffer` that copies its data from another buffer.
pub fn from_buffer_with_builder<'a, B, I, Cb, O>(source: B, usage: &BufferUsage, queue_families: I,
pub fn from_buffer_with_builder<'a, B, I, Cb, O>(source: B, usage: BufferUsage, queue_families: I,
builder: Cb)
-> Result<(Arc<ImmutableBuffer<T>>, O), ImmutableBufferFromBufferWithBuilderError>
where B: Buffer + TypedBuffer<Content = T> + DeviceOwned, // TODO: remove + DeviceOwned once Buffer requires it
@ -152,11 +152,11 @@ impl<T: ?Sized> ImmutableBuffer<T> {
// We automatically set `transfer_dest` to true in order to avoid annoying errors.
let actual_usage = BufferUsage {
transfer_dest: true,
.. *usage
.. usage
};
let (buffer, init) = ImmutableBuffer::raw(source.device().clone(), source.size(),
&actual_usage, queue_families)?;
actual_usage, queue_families)?;
let builder = builder.copy_buffer(source, init)?;
Ok((buffer, builder))
@ -182,7 +182,7 @@ impl<T> ImmutableBuffer<T> {
/// data, otherwise the content is undefined.
///
#[inline]
pub unsafe fn uninitialized<'a, I>(device: Arc<Device>, usage: &BufferUsage, queue_families: I)
pub unsafe fn uninitialized<'a, I>(device: Arc<Device>, usage: BufferUsage, queue_families: I)
-> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -191,13 +191,13 @@ impl<T> ImmutableBuffer<T> {
}
impl<T> ImmutableBuffer<[T]> {
pub fn from_iter<'a, D, I>(data: D, usage: &BufferUsage, queue_families: I, queue: Arc<Queue>)
pub fn from_iter<'a, D, I>(data: D, usage: BufferUsage, queue_families: I, queue: Arc<Queue>)
-> Result<(Arc<ImmutableBuffer<[T]>>, ImmutableBufferFromBufferFuture), OomError>
where I: IntoIterator<Item = QueueFamily<'a>>,
D: ExactSizeIterator<Item = T>,
T: 'static + Send + Sync + Sized,
{
let source = CpuAccessibleBuffer::from_iter(queue.device(), &BufferUsage::transfer_source(),
let source = CpuAccessibleBuffer::from_iter(queue.device(), BufferUsage::transfer_source(),
iter::once(queue.family()), data)?;
ImmutableBuffer::from_buffer(source, usage, queue_families, queue)
}
@ -219,7 +219,7 @@ impl<T> ImmutableBuffer<[T]> {
/// data, otherwise the content is undefined.
///
#[inline]
pub unsafe fn uninitialized_array<'a, I>(device: Arc<Device>, len: usize, usage: &BufferUsage,
pub unsafe fn uninitialized_array<'a, I>(device: Arc<Device>, len: usize, usage: BufferUsage,
queue_families: I)
-> Result<(Arc<ImmutableBuffer<[T]>>, ImmutableBufferInitialization<[T]>), OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
@ -245,7 +245,7 @@ impl<T: ?Sized> ImmutableBuffer<T> {
/// data.
///
#[inline]
pub unsafe fn raw<'a, I>(device: Arc<Device>, size: usize, usage: &BufferUsage, queue_families: I)
pub unsafe fn raw<'a, I>(device: Arc<Device>, size: usize, usage: BufferUsage, queue_families: I)
-> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), OomError>
where I: IntoIterator<Item = QueueFamily<'a>>
{
@ -255,7 +255,7 @@ impl<T: ?Sized> ImmutableBuffer<T> {
// Internal implementation of `raw`. This is separated from `raw` so that it doesn't need to be
// inlined.
unsafe fn raw_impl(device: Arc<Device>, size: usize, usage: &BufferUsage,
unsafe fn raw_impl(device: Arc<Device>, size: usize, usage: BufferUsage,
queue_families: SmallVec<[u32; 4]>)
-> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), OomError>
{
@ -266,7 +266,7 @@ impl<T: ?Sized> ImmutableBuffer<T> {
Sharing::Exclusive
};
match UnsafeBuffer::new(&device, size, &usage, sharing, SparseLevel::none()) {
match UnsafeBuffer::new(&device, size, usage, sharing, SparseLevel::none()) {
Ok(b) => b,
Err(BufferCreationError::OomError(err)) => return Err(err),
Err(_) => unreachable!() // We don't use sparse binding, therefore the other
@ -527,11 +527,11 @@ mod tests {
fn from_data_working() {
let (device, queue) = gfx_dev_and_queue!();
let (buffer, _) = ImmutableBuffer::from_data(12u32, &BufferUsage::all(),
let (buffer, _) = ImmutableBuffer::from_data(12u32, BufferUsage::all(),
iter::once(queue.family()),
queue.clone()).unwrap();
let dest = CpuAccessibleBuffer::from_data(&device, &BufferUsage::all(),
let dest = CpuAccessibleBuffer::from_data(&device, BufferUsage::all(),
iter::once(queue.family()), 0).unwrap();
let _ = AutoCommandBufferBuilder::new(device.clone(), queue.family()).unwrap()
@ -548,11 +548,11 @@ mod tests {
fn from_iter_working() {
let (device, queue) = gfx_dev_and_queue!();
let (buffer, _) = ImmutableBuffer::from_iter((0 .. 512u32).map(|n| n * 2), &BufferUsage::all(),
let (buffer, _) = ImmutableBuffer::from_iter((0 .. 512u32).map(|n| n * 2), BufferUsage::all(),
iter::once(queue.family()),
queue.clone()).unwrap();
let dest = CpuAccessibleBuffer::from_iter(&device, &BufferUsage::all(),
let dest = CpuAccessibleBuffer::from_iter(&device, BufferUsage::all(),
iter::once(queue.family()),
(0 .. 512).map(|_| 0u32)).unwrap();
@ -573,7 +573,7 @@ mod tests {
fn writing_forbidden() {
let (device, queue) = gfx_dev_and_queue!();
let (buffer, _) = ImmutableBuffer::from_data(12u32, &BufferUsage::all(),
let (buffer, _) = ImmutableBuffer::from_data(12u32, BufferUsage::all(),
iter::once(queue.family()),
queue.clone()).unwrap();
@ -590,11 +590,11 @@ mod tests {
let (device, queue) = gfx_dev_and_queue!();
let (buffer, _) = unsafe {
ImmutableBuffer::<u32>::uninitialized(device.clone(), &BufferUsage::all(),
ImmutableBuffer::<u32>::uninitialized(device.clone(), BufferUsage::all(),
iter::once(queue.family())).unwrap()
};
let src = CpuAccessibleBuffer::from_data(&device, &BufferUsage::all(),
let src = CpuAccessibleBuffer::from_data(&device, BufferUsage::all(),
iter::once(queue.family()), 0).unwrap();
let _ = AutoCommandBufferBuilder::new(device.clone(), queue.family()).unwrap()
@ -609,11 +609,11 @@ mod tests {
let (device, queue) = gfx_dev_and_queue!();
let (buffer, init) = unsafe {
ImmutableBuffer::<u32>::uninitialized(device.clone(), &BufferUsage::all(),
ImmutableBuffer::<u32>::uninitialized(device.clone(), BufferUsage::all(),
iter::once(queue.family())).unwrap()
};
let src = CpuAccessibleBuffer::from_data(&device, &BufferUsage::all(),
let src = CpuAccessibleBuffer::from_data(&device, BufferUsage::all(),
iter::once(queue.family()), 0).unwrap();
let _ = AutoCommandBufferBuilder::new(device.clone(), queue.family()).unwrap()
@ -630,11 +630,11 @@ mod tests {
let (device, queue) = gfx_dev_and_queue!();
let (buffer, init) = unsafe {
ImmutableBuffer::<u32>::uninitialized(device.clone(), &BufferUsage::all(),
ImmutableBuffer::<u32>::uninitialized(device.clone(), BufferUsage::all(),
iter::once(queue.family())).unwrap()
};
let src = CpuAccessibleBuffer::from_data(&device, &BufferUsage::all(),
let src = CpuAccessibleBuffer::from_data(&device, BufferUsage::all(),
iter::once(queue.family()), 0).unwrap();
let cb1 = AutoCommandBufferBuilder::new(device.clone(), queue.family()).unwrap()

View File

@ -64,14 +64,14 @@ impl UnsafeBuffer {
/// Panics if `sparse.sparse` is false and `sparse.sparse_residency` or
/// `sparse.sparse_aliased` is true.
///
pub unsafe fn new<'a, I>(device: &Arc<Device>, size: usize, usage: &BufferUsage,
pub unsafe fn new<'a, I>(device: &Arc<Device>, size: usize, usage: BufferUsage,
sharing: Sharing<I>, sparse: SparseLevel)
-> Result<(UnsafeBuffer, MemoryRequirements), BufferCreationError>
where I: Iterator<Item = u32>
{
let vk = device.pointers();
let usage_bits = usage_to_bits(&usage);
let usage_bits = usage_to_bits(usage);
// Checking sparse features.
assert!(sparse.sparse || !sparse.sparse_residency, "Can't enable sparse residency without \
@ -384,7 +384,7 @@ mod tests {
fn create() {
let (device, _) = gfx_dev_and_queue!();
let (buf, reqs) = unsafe {
UnsafeBuffer::new(&device, 128, &BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
UnsafeBuffer::new(&device, 128, BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
SparseLevel::none())
}.unwrap();
@ -399,7 +399,7 @@ mod tests {
let (device, _) = gfx_dev_and_queue!();
let sparse = SparseLevel { sparse: false, sparse_residency: true, sparse_aliased: false };
let _ = unsafe {
UnsafeBuffer::new(&device, 128, &BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
UnsafeBuffer::new(&device, 128, BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
sparse)
};
}
@ -410,7 +410,7 @@ mod tests {
let (device, _) = gfx_dev_and_queue!();
let sparse = SparseLevel { sparse: false, sparse_residency: false, sparse_aliased: true };
let _ = unsafe {
UnsafeBuffer::new(&device, 128, &BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
UnsafeBuffer::new(&device, 128, BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
sparse)
};
}
@ -420,7 +420,7 @@ mod tests {
let (device, _) = gfx_dev_and_queue!();
let sparse = SparseLevel { sparse: true, sparse_residency: false, sparse_aliased: false };
unsafe {
match UnsafeBuffer::new(&device, 128, &BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
match UnsafeBuffer::new(&device, 128, BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
sparse)
{
Err(BufferCreationError::SparseBindingFeatureNotEnabled) => (),
@ -434,7 +434,7 @@ mod tests {
let (device, _) = gfx_dev_and_queue!(sparse_binding);
let sparse = SparseLevel { sparse: true, sparse_residency: true, sparse_aliased: false };
unsafe {
match UnsafeBuffer::new(&device, 128, &BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
match UnsafeBuffer::new(&device, 128, BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
sparse)
{
Err(BufferCreationError::SparseResidencyBufferFeatureNotEnabled) => (),
@ -448,7 +448,7 @@ mod tests {
let (device, _) = gfx_dev_and_queue!(sparse_binding);
let sparse = SparseLevel { sparse: true, sparse_residency: false, sparse_aliased: true };
unsafe {
match UnsafeBuffer::new(&device, 128, &BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
match UnsafeBuffer::new(&device, 128, BufferUsage::all(), Sharing::Exclusive::<Empty<_>>,
sparse)
{
Err(BufferCreationError::SparseResidencyAliasedFeatureNotEnabled) => (),

View File

@ -181,7 +181,7 @@ impl BitOr for BufferUsage {
/// Turns a `BufferUsage` into raw bits.
#[inline]
pub fn usage_to_bits(usage: &BufferUsage) -> vk::BufferUsageFlagBits {
pub fn usage_to_bits(usage: BufferUsage) -> vk::BufferUsageFlagBits {
let mut result = 0;
if usage.transfer_source { result |= vk::BUFFER_USAGE_TRANSFER_SRC_BIT; }
if usage.transfer_dest { result |= vk::BUFFER_USAGE_TRANSFER_DST_BIT; }

View File

@ -31,7 +31,7 @@
//! .. BufferUsage::none()
//! };
//!
//! let (buffer, _future) = ImmutableBuffer::<[u32]>::from_iter((0..128).map(|n| n), &usage,
//! let (buffer, _future) = ImmutableBuffer::<[u32]>::from_iter((0..128).map(|n| n), usage,
//! Some(queue.family()),
//! queue.clone()).unwrap();
//! let _view = BufferView::new(buffer, format::R32Uint).unwrap();
@ -336,7 +336,7 @@ mod tests {
.. BufferUsage::none()
};
let (buffer, _) = ImmutableBuffer::<[[u8; 4]]>::from_iter((0..128).map(|_| [0; 4]), &usage,
let (buffer, _) = ImmutableBuffer::<[[u8; 4]]>::from_iter((0..128).map(|_| [0; 4]), usage,
Some(queue.family()), queue.clone()).unwrap();
let view = BufferView::new(buffer, format::R8G8B8A8Unorm).unwrap();
@ -353,7 +353,7 @@ mod tests {
.. BufferUsage::none()
};
let (buffer, _) = ImmutableBuffer::<[[u8; 4]]>::from_iter((0..128).map(|_| [0; 4]), &usage,
let (buffer, _) = ImmutableBuffer::<[[u8; 4]]>::from_iter((0..128).map(|_| [0; 4]), usage,
Some(queue.family()),
queue.clone()).unwrap();
let view = BufferView::new(buffer, format::R8G8B8A8Unorm).unwrap();
@ -371,7 +371,7 @@ mod tests {
.. BufferUsage::none()
};
let (buffer, _) = ImmutableBuffer::<[u32]>::from_iter((0..128).map(|_| 0), &usage,
let (buffer, _) = ImmutableBuffer::<[u32]>::from_iter((0..128).map(|_| 0), usage,
Some(queue.family()),
queue.clone()).unwrap();
let view = BufferView::new(buffer, format::R32Uint).unwrap();
@ -386,7 +386,7 @@ mod tests {
let (device, queue) = gfx_dev_and_queue!();
let (buffer, _) = ImmutableBuffer::<[[u8; 4]]>::from_iter((0..128).map(|_| [0; 4]),
&BufferUsage::none(),
BufferUsage::none(),
Some(queue.family()),
queue.clone()).unwrap();
@ -407,7 +407,7 @@ mod tests {
};
let (buffer, _) = ImmutableBuffer::<[[f64; 4]]>::from_iter((0..128).map(|_| [0.0; 4]),
&usage, Some(queue.family()),
usage, Some(queue.family()),
queue.clone()).unwrap();
// TODO: what if R64G64B64A64Sfloat is supported?

View File

@ -144,7 +144,7 @@ mod tests {
fn basic() {
let (device, queue) = gfx_dev_and_queue!();
let buffer = CpuAccessibleBuffer::from_data(&device, &BufferUsage::transfer_dest(),
let buffer = CpuAccessibleBuffer::from_data(&device, BufferUsage::transfer_dest(),
Some(queue.family()), 0u32).unwrap();
let _ = PrimaryCbBuilder::new(&device, queue.family())