Validate on empty usages

This commit is contained in:
Connor Fitzgerald
2020-12-21 15:54:57 -05:00
parent b3422257ef
commit 6c6ce2f28c
2 changed files with 12 additions and 0 deletions

View File

@@ -438,6 +438,10 @@ impl<B: GfxBackend> Device<B> {
}
}
if desc.usage.is_empty() {
return Err(resource::CreateBufferError::EmptyUsage);
}
let mem_usage = {
use gpu_alloc::UsageFlags as Uf;
use wgt::BufferUsage as Bu;
@@ -537,6 +541,10 @@ impl<B: GfxBackend> Device<B> {
_ => {}
}
if desc.usage.is_empty() {
return Err(resource::CreateTextureError::EmptyUsage);
}
let kind = conv::map_texture_dimension_size(desc.dimension, desc.size, desc.sample_count)?;
let format = conv::map_texture_format(desc.format, self.private_features);
let aspects = format.surface_desc().aspects;

View File

@@ -174,6 +174,8 @@ pub enum CreateBufferError {
AccessError(#[from] BufferAccessError),
#[error("buffers that are mapped at creation have to be aligned to `COPY_BUFFER_ALIGNMENT`")]
UnalignedSize,
#[error("Buffers cannot have empty usage flags")]
EmptyUsage,
#[error("`MAP` usage can only be combined with the opposite `COPY`, requested {0:?}")]
UsageMismatch(wgt::BufferUsage),
}
@@ -230,6 +232,8 @@ pub enum CreateTextureError {
Device(#[from] DeviceError),
#[error("D24Plus textures cannot be copied")]
CannotCopyD24Plus,
#[error("Textures cannot have empty usage flags")]
EmptyUsage,
#[error(transparent)]
InvalidDimension(#[from] TextureDimensionError),
#[error("texture descriptor mip level count ({0}) is invalid")]