mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
introduce Device.check_is_valid
This commit is contained in:
@@ -1510,10 +1510,12 @@ pub struct RenderBundleError {
|
||||
}
|
||||
|
||||
impl RenderBundleError {
|
||||
pub(crate) const INVALID_DEVICE: Self = RenderBundleError {
|
||||
scope: PassErrorScope::Bundle,
|
||||
inner: RenderBundleErrorInner::Device(DeviceError::Invalid),
|
||||
};
|
||||
pub fn from_device_error(e: DeviceError) -> Self {
|
||||
Self {
|
||||
scope: PassErrorScope::Bundle,
|
||||
inner: e.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl PrettyError for RenderBundleError {
|
||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::{
|
||||
get_lowest_common_denom,
|
||||
global::Global,
|
||||
hal_api::HalApi,
|
||||
id::{BufferId, CommandEncoderId, DeviceId, TextureId},
|
||||
id::{BufferId, CommandEncoderId, TextureId},
|
||||
init_tracker::{MemoryInitKind, TextureInitRange},
|
||||
resource::{ParentDevice, Resource, Texture, TextureClearMode},
|
||||
snatch::SnatchGuard,
|
||||
@@ -26,8 +26,6 @@ use wgt::{math::align_to, BufferAddress, BufferUsages, ImageSubresourceRange, Te
|
||||
pub enum ClearError {
|
||||
#[error("To use clear_texture the CLEAR_TEXTURE feature needs to be enabled")]
|
||||
MissingClearTextureFeature,
|
||||
#[error("Device {0:?} is invalid")]
|
||||
InvalidDevice(DeviceId),
|
||||
#[error("Buffer {0:?} is invalid or destroyed")]
|
||||
InvalidBuffer(BufferId),
|
||||
#[error("Texture {0:?} is invalid or destroyed")]
|
||||
@@ -238,9 +236,7 @@ impl Global {
|
||||
}
|
||||
|
||||
let device = &cmd_buf.device;
|
||||
if !device.is_valid() {
|
||||
return Err(ClearError::InvalidDevice(cmd_buf.device.as_info().id()));
|
||||
}
|
||||
device.check_is_valid()?;
|
||||
let (encoder, tracker) = cmd_buf_data.open_encoder_and_tracker()?;
|
||||
|
||||
let snatch_guard = device.snatchable_lock.read();
|
||||
|
||||
@@ -161,8 +161,6 @@ pub enum ComputePassErrorInner {
|
||||
InvalidParentEncoder,
|
||||
#[error("Bind group at index {0:?} is invalid")]
|
||||
InvalidBindGroup(u32),
|
||||
#[error("Device {0:?} is invalid")]
|
||||
InvalidDevice(id::DeviceId),
|
||||
#[error("Bind group index {index} is greater than the device's requested `max_bind_group` limit {max}")]
|
||||
BindGroupIndexOutOfRange { index: u32, max: u32 },
|
||||
#[error("Compute pipeline {0:?} is invalid")]
|
||||
@@ -452,12 +450,7 @@ impl Global {
|
||||
let pass_scope = PassErrorScope::Pass(Some(cmd_buf.as_info().id()));
|
||||
|
||||
let device = &cmd_buf.device;
|
||||
if !device.is_valid() {
|
||||
return Err(ComputePassErrorInner::InvalidDevice(
|
||||
cmd_buf.device.as_info().id(),
|
||||
))
|
||||
.map_pass_err(pass_scope);
|
||||
}
|
||||
device.check_is_valid().map_pass_err(pass_scope)?;
|
||||
|
||||
let mut cmd_buf_data = cmd_buf.data.lock();
|
||||
let cmd_buf_data = cmd_buf_data.as_mut().unwrap();
|
||||
|
||||
@@ -1368,9 +1368,7 @@ impl Global {
|
||||
});
|
||||
}
|
||||
|
||||
if !device.is_valid() {
|
||||
return Err(DeviceError::Lost).map_pass_err(pass_scope);
|
||||
}
|
||||
device.check_is_valid().map_pass_err(pass_scope)?;
|
||||
|
||||
let encoder = &mut cmd_buf_data.encoder;
|
||||
let status = &mut cmd_buf_data.status;
|
||||
|
||||
@@ -8,12 +8,12 @@ use crate::{
|
||||
error::{ErrorFormatter, PrettyError},
|
||||
global::Global,
|
||||
hal_api::HalApi,
|
||||
id::{BufferId, CommandEncoderId, DeviceId, TextureId},
|
||||
id::{BufferId, CommandEncoderId, TextureId},
|
||||
init_tracker::{
|
||||
has_copy_partial_init_tracker_coverage, MemoryInitKind, TextureInitRange,
|
||||
TextureInitTrackerAction,
|
||||
},
|
||||
resource::{ParentDevice, Resource, Texture, TextureErrorDimension},
|
||||
resource::{ParentDevice, Texture, TextureErrorDimension},
|
||||
snatch::SnatchGuard,
|
||||
track::{TextureSelector, Tracker},
|
||||
};
|
||||
@@ -41,8 +41,6 @@ pub enum CopySide {
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[non_exhaustive]
|
||||
pub enum TransferError {
|
||||
#[error("Device {0:?} is invalid")]
|
||||
InvalidDevice(DeviceId),
|
||||
#[error("Buffer {0:?} is invalid or destroyed")]
|
||||
InvalidBuffer(BufferId),
|
||||
#[error("Texture {0:?} is invalid or destroyed")]
|
||||
@@ -579,9 +577,7 @@ impl Global {
|
||||
let cmd_buf_data = cmd_buf_data.as_mut().unwrap();
|
||||
|
||||
let device = &cmd_buf.device;
|
||||
if !device.is_valid() {
|
||||
return Err(TransferError::InvalidDevice(cmd_buf.device.as_info().id()).into());
|
||||
}
|
||||
device.check_is_valid()?;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref mut list) = cmd_buf_data.commands {
|
||||
@@ -746,9 +742,7 @@ impl Global {
|
||||
|
||||
let cmd_buf = CommandBuffer::get_encoder(hub, command_encoder_id)?;
|
||||
let device = &cmd_buf.device;
|
||||
if !device.is_valid() {
|
||||
return Err(TransferError::InvalidDevice(cmd_buf.device.as_info().id()).into());
|
||||
}
|
||||
device.check_is_valid()?;
|
||||
|
||||
let mut cmd_buf_data = cmd_buf.data.lock();
|
||||
let cmd_buf_data = cmd_buf_data.as_mut().unwrap();
|
||||
@@ -913,9 +907,7 @@ impl Global {
|
||||
|
||||
let cmd_buf = CommandBuffer::get_encoder(hub, command_encoder_id)?;
|
||||
let device = &cmd_buf.device;
|
||||
if !device.is_valid() {
|
||||
return Err(TransferError::InvalidDevice(cmd_buf.device.as_info().id()).into());
|
||||
}
|
||||
device.check_is_valid()?;
|
||||
|
||||
let mut cmd_buf_data = cmd_buf.data.lock();
|
||||
let cmd_buf_data = cmd_buf_data.as_mut().unwrap();
|
||||
@@ -1092,9 +1084,7 @@ impl Global {
|
||||
|
||||
let cmd_buf = CommandBuffer::get_encoder(hub, command_encoder_id)?;
|
||||
let device = &cmd_buf.device;
|
||||
if !device.is_valid() {
|
||||
return Err(TransferError::InvalidDevice(cmd_buf.device.as_info().id()).into());
|
||||
}
|
||||
device.check_is_valid()?;
|
||||
|
||||
let snatch_guard = device.snatchable_lock.read();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user