mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
rename WrongDevice
to DeviceMismatch
This commit is contained in:
parent
ce716adb5e
commit
c01a1335aa
@ -385,14 +385,14 @@ fn map_buffer<A: HalApi>(
|
|||||||
pub struct InvalidDevice;
|
pub struct InvalidDevice;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct WrongDevice {
|
pub struct DeviceMismatch {
|
||||||
pub(super) res: ResourceErrorIdent,
|
pub(super) res: ResourceErrorIdent,
|
||||||
pub(super) res_device: ResourceErrorIdent,
|
pub(super) res_device: ResourceErrorIdent,
|
||||||
pub(super) target: Option<ResourceErrorIdent>,
|
pub(super) target: Option<ResourceErrorIdent>,
|
||||||
pub(super) target_device: ResourceErrorIdent,
|
pub(super) target_device: ResourceErrorIdent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for WrongDevice {
|
impl std::fmt::Display for DeviceMismatch {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
@ -406,7 +406,7 @@ impl std::fmt::Display for WrongDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for WrongDevice {}
|
impl std::error::Error for DeviceMismatch {}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Error)]
|
#[derive(Clone, Debug, Error)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
@ -422,7 +422,7 @@ pub enum DeviceError {
|
|||||||
#[error("QueueId is invalid")]
|
#[error("QueueId is invalid")]
|
||||||
InvalidQueueId,
|
InvalidQueueId,
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
WrongDevice(#[from] Box<WrongDevice>),
|
DeviceMismatch(#[from] Box<DeviceMismatch>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<hal::DeviceError> for DeviceError {
|
impl From<hal::DeviceError> for DeviceError {
|
||||||
|
@ -16,7 +16,7 @@ pub enum PipelineCacheValidationError {
|
|||||||
#[error("The pipeline cacha data was out of date and so cannot be safely used")]
|
#[error("The pipeline cacha data was out of date and so cannot be safely used")]
|
||||||
Outdated,
|
Outdated,
|
||||||
#[error("The cache data was created for a different device")]
|
#[error("The cache data was created for a different device")]
|
||||||
WrongDevice,
|
DeviceMismatch,
|
||||||
#[error("Pipeline cacha data was created for a future version of wgpu")]
|
#[error("Pipeline cacha data was created for a future version of wgpu")]
|
||||||
Unsupported,
|
Unsupported,
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ impl PipelineCacheValidationError {
|
|||||||
/// That is, is there a mistake in user code interacting with the cache
|
/// That is, is there a mistake in user code interacting with the cache
|
||||||
pub fn was_avoidable(&self) -> bool {
|
pub fn was_avoidable(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
PipelineCacheValidationError::WrongDevice => true,
|
PipelineCacheValidationError::DeviceMismatch => true,
|
||||||
PipelineCacheValidationError::Truncated
|
PipelineCacheValidationError::Truncated
|
||||||
| PipelineCacheValidationError::Unsupported
|
| PipelineCacheValidationError::Unsupported
|
||||||
| PipelineCacheValidationError::Extended
|
| PipelineCacheValidationError::Extended
|
||||||
@ -57,10 +57,10 @@ pub fn validate_pipeline_cache<'d>(
|
|||||||
return Err(PipelineCacheValidationError::Outdated);
|
return Err(PipelineCacheValidationError::Outdated);
|
||||||
}
|
}
|
||||||
if header.backend != adapter.backend as u8 {
|
if header.backend != adapter.backend as u8 {
|
||||||
return Err(PipelineCacheValidationError::WrongDevice);
|
return Err(PipelineCacheValidationError::DeviceMismatch);
|
||||||
}
|
}
|
||||||
if header.adapter_key != adapter_key {
|
if header.adapter_key != adapter_key {
|
||||||
return Err(PipelineCacheValidationError::WrongDevice);
|
return Err(PipelineCacheValidationError::DeviceMismatch);
|
||||||
}
|
}
|
||||||
if header.validation_key != validation_key {
|
if header.validation_key != validation_key {
|
||||||
// If the validation key is wrong, that means that this device has changed
|
// If the validation key is wrong, that means that this device has changed
|
||||||
@ -420,7 +420,7 @@ mod tests {
|
|||||||
];
|
];
|
||||||
let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
|
let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
|
||||||
let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
|
let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
|
||||||
assert_eq!(validation_result, Err(E::WrongDevice));
|
assert_eq!(validation_result, Err(E::DeviceMismatch));
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn wrong_adapter() {
|
fn wrong_adapter() {
|
||||||
@ -436,7 +436,7 @@ mod tests {
|
|||||||
];
|
];
|
||||||
let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
|
let cache = cache.into_iter().flatten().collect::<Vec<u8>>();
|
||||||
let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
|
let validation_result = super::validate_pipeline_cache(&cache, &ADAPTER, VALIDATION_KEY);
|
||||||
assert_eq!(validation_result, Err(E::WrongDevice));
|
assert_eq!(validation_result, Err(E::DeviceMismatch));
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn wrong_validation() {
|
fn wrong_validation() {
|
||||||
|
@ -3,8 +3,8 @@ use crate::device::trace;
|
|||||||
use crate::{
|
use crate::{
|
||||||
binding_model::BindGroup,
|
binding_model::BindGroup,
|
||||||
device::{
|
device::{
|
||||||
queue, resource::DeferredDestroy, BufferMapPendingClosure, Device, DeviceError, HostMap,
|
queue, resource::DeferredDestroy, BufferMapPendingClosure, Device, DeviceError,
|
||||||
MissingDownlevelFlags, MissingFeatures, WrongDevice,
|
DeviceMismatch, HostMap, MissingDownlevelFlags, MissingFeatures,
|
||||||
},
|
},
|
||||||
global::Global,
|
global::Global,
|
||||||
hal_api::HalApi,
|
hal_api::HalApi,
|
||||||
@ -162,7 +162,7 @@ pub(crate) trait ParentDevice<A: HalApi>: Resource {
|
|||||||
Arc::ptr_eq(self.device(), other.device())
|
Arc::ptr_eq(self.device(), other.device())
|
||||||
.then_some(())
|
.then_some(())
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
DeviceError::WrongDevice(Box::new(WrongDevice {
|
DeviceError::DeviceMismatch(Box::new(DeviceMismatch {
|
||||||
res: self.error_ident(),
|
res: self.error_ident(),
|
||||||
res_device: self.device().error_ident(),
|
res_device: self.device().error_ident(),
|
||||||
target: Some(other.error_ident()),
|
target: Some(other.error_ident()),
|
||||||
@ -175,7 +175,7 @@ pub(crate) trait ParentDevice<A: HalApi>: Resource {
|
|||||||
Arc::ptr_eq(self.device(), device)
|
Arc::ptr_eq(self.device(), device)
|
||||||
.then_some(())
|
.then_some(())
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
DeviceError::WrongDevice(Box::new(WrongDevice {
|
DeviceError::DeviceMismatch(Box::new(DeviceMismatch {
|
||||||
res: self.error_ident(),
|
res: self.error_ident(),
|
||||||
res_device: self.device().error_ident(),
|
res_device: self.device().error_ident(),
|
||||||
target: None,
|
target: None,
|
||||||
|
Loading…
Reference in New Issue
Block a user