mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-25 08:51:05 +01:00
Validate on empty usages
This commit is contained in:
1 parent
b3422257ef
commit
6c6ce2f28c
2 files changed
+12
No files matched your search
@@ -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