mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Validate on empty usages
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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")]
|
||||
|
||||
Reference in New Issue
Block a user