rt(mtl): don't allow buffers of size 0
This commit is contained in:
parent
c0ecae844c
commit
efdfd56e0e
1 changed files with 6 additions and 1 deletions
|
@ -24,7 +24,7 @@ impl AsRef<ProtocolObject<dyn MTLBuffer>> for MetalBuffer {
|
|||
impl MetalBuffer {
|
||||
pub fn new(
|
||||
device: &ProtocolObject<dyn MTLDevice>,
|
||||
size: usize,
|
||||
mut size: usize,
|
||||
label: &str,
|
||||
) -> error::Result<Self> {
|
||||
let storage_mode = if cfg!(all(target_arch = "aarch64", target_vendor = "apple")) {
|
||||
|
@ -33,6 +33,11 @@ impl MetalBuffer {
|
|||
MTLResourceStorageModeManaged
|
||||
};
|
||||
|
||||
// Can't create buffer of size 0.
|
||||
if size == 0 {
|
||||
size = 16;
|
||||
};
|
||||
|
||||
let buffer = device
|
||||
.newBufferWithLength_options(size, storage_mode)
|
||||
.ok_or(FilterChainError::BufferError)?;
|
||||
|
|
Loading…
Add table
Reference in a new issue