mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
move hal_usage_error
from the vk backend to lib.rs
This commit is contained in:
parent
e25051ec8f
commit
29e288f81c
@ -345,6 +345,12 @@ pub enum DeviceError {
|
||||
Unexpected,
|
||||
}
|
||||
|
||||
#[allow(dead_code)] // may be unused on some platforms
|
||||
#[cold]
|
||||
fn hal_usage_error<T: fmt::Display>(txt: T) -> ! {
|
||||
panic!("wgpu-hal invariant was violated (usage error): {txt}")
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Error)]
|
||||
pub enum ShaderError {
|
||||
#[error("Compilation failed: {0:?}")]
|
||||
|
@ -2010,7 +2010,7 @@ impl crate::Adapter for super::Adapter {
|
||||
vk::Result::ERROR_TOO_MANY_OBJECTS => crate::DeviceError::OutOfMemory,
|
||||
vk::Result::ERROR_INITIALIZATION_FAILED => crate::DeviceError::Lost,
|
||||
vk::Result::ERROR_EXTENSION_NOT_PRESENT | vk::Result::ERROR_FEATURE_NOT_PRESENT => {
|
||||
super::hal_usage_error(err)
|
||||
crate::hal_usage_error(err)
|
||||
}
|
||||
other => super::map_host_device_oom_and_lost_err(other),
|
||||
}
|
||||
|
@ -970,14 +970,14 @@ impl crate::Device for super::Device {
|
||||
.contains(gpu_alloc::MemoryPropertyFlags::HOST_COHERENT);
|
||||
Ok(crate::BufferMapping { ptr, is_coherent })
|
||||
} else {
|
||||
super::hal_usage_error("tried to map external buffer")
|
||||
crate::hal_usage_error("tried to map external buffer")
|
||||
}
|
||||
}
|
||||
unsafe fn unmap_buffer(&self, buffer: &super::Buffer) {
|
||||
if let Some(ref block) = buffer.block {
|
||||
unsafe { block.lock().unmap(&*self.shared) };
|
||||
} else {
|
||||
super::hal_usage_error("tried to unmap external buffer")
|
||||
crate::hal_usage_error("tried to unmap external buffer")
|
||||
}
|
||||
}
|
||||
|
||||
@ -2520,7 +2520,7 @@ impl super::DeviceShared {
|
||||
}
|
||||
}
|
||||
None => {
|
||||
super::hal_usage_error(format!(
|
||||
crate::hal_usage_error(format!(
|
||||
"no signals reached value {}",
|
||||
wait_value
|
||||
));
|
||||
@ -2537,7 +2537,7 @@ impl From<gpu_alloc::AllocationError> for crate::DeviceError {
|
||||
use gpu_alloc::AllocationError as Ae;
|
||||
match error {
|
||||
Ae::OutOfDeviceMemory | Ae::OutOfHostMemory | Ae::TooManyObjects => Self::OutOfMemory,
|
||||
Ae::NoCompatibleMemoryTypes => super::hal_usage_error(error),
|
||||
Ae::NoCompatibleMemoryTypes => crate::hal_usage_error(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2546,7 +2546,7 @@ impl From<gpu_alloc::MapError> for crate::DeviceError {
|
||||
use gpu_alloc::MapError as Me;
|
||||
match error {
|
||||
Me::OutOfDeviceMemory | Me::OutOfHostMemory | Me::MapFailed => Self::OutOfMemory,
|
||||
Me::NonHostVisible | Me::AlreadyMapped => super::hal_usage_error(error),
|
||||
Me::NonHostVisible | Me::AlreadyMapped => crate::hal_usage_error(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1360,8 +1360,3 @@ fn get_lost_err() -> crate::DeviceError {
|
||||
#[allow(unreachable_code)]
|
||||
crate::DeviceError::Lost
|
||||
}
|
||||
|
||||
#[cold]
|
||||
fn hal_usage_error<T: fmt::Display>(txt: T) -> ! {
|
||||
panic!("wgpu-hal invariant was violated (usage error): {txt}")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user