Skip to content

Commit 912abdf

Browse files
shuni64rukai
authored andcommitted
Make buffer::sys::UnsafeBuffer::new panic if the usage parameter is empty (#1161)
1 parent d388824 commit 912abdf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: vulkano/src/buffer/sys.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ impl UnsafeBuffer {
6060
///
6161
/// # Panic
6262
///
63-
/// Panics if `sparse.sparse` is false and `sparse.sparse_residency` or
64-
/// `sparse.sparse_aliased` is true.
63+
/// - Panics if `sparse.sparse` is false and `sparse.sparse_residency` or `sparse.sparse_aliased` is true.
64+
/// - Panics if `usage` is empty.
6565
///
6666
pub unsafe fn new<'a, I>(device: Arc<Device>, size: usize, usage: BufferUsage,
6767
sharing: Sharing<I>, sparse: SparseLevel)
@@ -80,6 +80,10 @@ impl UnsafeBuffer {
8080

8181
let usage_bits = usage.to_vulkan_bits();
8282

83+
// Checking for empty BufferUsage.
84+
assert!(usage_bits != 0,
85+
"Can't create buffer with empty BufferUsage");
86+
8387
// Checking sparse features.
8488
assert!(sparse.sparse || !sparse.sparse_residency,
8589
"Can't enable sparse residency without enabling sparse binding as well");

0 commit comments

Comments
 (0)