fix: emit valid. err. on dev. mismatch in queue_write_buffer (#5359)

This commit is contained in:
Erich Gubler 2024-03-07 05:20:42 -05:00 committed by GitHub
parent 5162fd440d
commit 8f1981d5b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,7 +12,7 @@ use crate::{
global::Global, global::Global,
hal_api::HalApi, hal_api::HalApi,
hal_label, hal_label,
id::{self, QueueId}, id::{self, DeviceId, QueueId},
init_tracker::{has_copy_partial_init_tracker_coverage, TextureInitRange}, init_tracker::{has_copy_partial_init_tracker_coverage, TextureInitRange},
resource::{ resource::{
Buffer, BufferAccessError, BufferMapState, DestroyedBuffer, DestroyedTexture, Resource, Buffer, BufferAccessError, BufferMapState, DestroyedBuffer, DestroyedTexture, Resource,
@ -342,6 +342,15 @@ pub struct InvalidQueue;
#[derive(Clone, Debug, Error)] #[derive(Clone, Debug, Error)]
#[non_exhaustive] #[non_exhaustive]
pub enum QueueWriteError { pub enum QueueWriteError {
#[error(
"Device of queue ({:?}) does not match device of write recipient ({:?})",
queue_device_id,
target_device_id
)]
DeviceMismatch {
queue_device_id: DeviceId,
target_device_id: DeviceId,
},
#[error(transparent)] #[error(transparent)]
Queue(#[from] DeviceError), Queue(#[from] DeviceError),
#[error(transparent)] #[error(transparent)]
@ -386,6 +395,14 @@ impl Global {
let hub = A::hub(self); let hub = A::hub(self);
let buffer_device_id = hub
.buffers
.get(buffer_id)
.map_err(|_| TransferError::InvalidBuffer(buffer_id))?
.device
.as_info()
.id();
let queue = hub let queue = hub
.queues .queues
.get(queue_id) .get(queue_id)
@ -393,6 +410,16 @@ impl Global {
let device = queue.device.as_ref().unwrap(); let device = queue.device.as_ref().unwrap();
{
let queue_device_id = device.as_info().id();
if buffer_device_id != queue_device_id {
return Err(QueueWriteError::DeviceMismatch {
queue_device_id,
target_device_id: buffer_device_id,
});
}
}
let data_size = data.len() as wgt::BufferAddress; let data_size = data.len() as wgt::BufferAddress;
#[cfg(feature = "trace")] #[cfg(feature = "trace")]