Skip to content

Commit e702d1c

Browse files
andyleisersonjimblandy
authored andcommitted
Deferred error reporting for transfer commands
1 parent 8cdbcc1 commit e702d1c

File tree

4 files changed

+580
-585
lines changed

4 files changed

+580
-585
lines changed

deno_webgpu/error.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use wgpu_core::binding_model::GetBindGroupLayoutError;
1717
use wgpu_core::command::ClearError;
1818
use wgpu_core::command::CommandEncoderError;
1919
use wgpu_core::command::ComputePassError;
20-
use wgpu_core::command::CopyError;
2120
use wgpu_core::command::CreateRenderBundleError;
2221
use wgpu_core::command::EncoderStateError;
2322
use wgpu_core::command::QueryError;
@@ -273,12 +272,6 @@ impl From<CreateRenderBundleError> for GPUError {
273272
}
274273
}
275274

276-
impl From<CopyError> for GPUError {
277-
fn from(err: CopyError) -> Self {
278-
GPUError::Validation(fmt_err(&err))
279-
}
280-
}
281-
282275
impl From<CommandEncoderError> for GPUError {
283276
fn from(err: CommandEncoderError) -> Self {
284277
GPUError::Validation(fmt_err(&err))

tests/tests/wgpu-gpu/device.rs

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -380,70 +380,66 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
380380
);
381381

382382
// Copying a buffer to a buffer should fail.
383+
encoder_for_buffer_buffer_copy.copy_buffer_to_buffer(
384+
&buffer_source,
385+
0,
386+
&buffer_dest,
387+
0,
388+
256,
389+
);
383390
fail(
384391
&ctx.device,
385-
|| {
386-
encoder_for_buffer_buffer_copy.copy_buffer_to_buffer(
387-
&buffer_source,
388-
0,
389-
&buffer_dest,
390-
0,
391-
256,
392-
);
393-
},
392+
|| encoder_for_buffer_buffer_copy.finish(),
394393
Some("device with '' label is invalid"),
395394
);
396395

397396
// Copying a buffer to a texture should fail.
397+
encoder_for_buffer_texture_copy.copy_buffer_to_texture(
398+
wgpu::TexelCopyBufferInfo {
399+
buffer: &buffer_source,
400+
layout: wgpu::TexelCopyBufferLayout {
401+
offset: 0,
402+
bytes_per_row: Some(4),
403+
rows_per_image: None,
404+
},
405+
},
406+
texture_for_write.as_image_copy(),
407+
texture_extent,
408+
);
398409
fail(
399410
&ctx.device,
400-
|| {
401-
encoder_for_buffer_texture_copy.copy_buffer_to_texture(
402-
wgpu::TexelCopyBufferInfo {
403-
buffer: &buffer_source,
404-
layout: wgpu::TexelCopyBufferLayout {
405-
offset: 0,
406-
bytes_per_row: Some(4),
407-
rows_per_image: None,
408-
},
409-
},
410-
texture_for_write.as_image_copy(),
411-
texture_extent,
412-
);
413-
},
411+
|| encoder_for_buffer_texture_copy.finish(),
414412
Some("device with '' label is invalid"),
415413
);
416414

417415
// Copying a texture to a buffer should fail.
416+
encoder_for_texture_buffer_copy.copy_texture_to_buffer(
417+
texture_for_read.as_image_copy(),
418+
wgpu::TexelCopyBufferInfo {
419+
buffer: &buffer_source,
420+
layout: wgpu::TexelCopyBufferLayout {
421+
offset: 0,
422+
bytes_per_row: Some(4),
423+
rows_per_image: None,
424+
},
425+
},
426+
texture_extent,
427+
);
418428
fail(
419429
&ctx.device,
420-
|| {
421-
encoder_for_texture_buffer_copy.copy_texture_to_buffer(
422-
texture_for_read.as_image_copy(),
423-
wgpu::TexelCopyBufferInfo {
424-
buffer: &buffer_source,
425-
layout: wgpu::TexelCopyBufferLayout {
426-
offset: 0,
427-
bytes_per_row: Some(4),
428-
rows_per_image: None,
429-
},
430-
},
431-
texture_extent,
432-
);
433-
},
430+
|| encoder_for_texture_buffer_copy.finish(),
434431
Some("device with '' label is invalid"),
435432
);
436433

437434
// Copying a texture to a texture should fail.
435+
encoder_for_texture_texture_copy.copy_texture_to_texture(
436+
texture_for_read.as_image_copy(),
437+
texture_for_write.as_image_copy(),
438+
texture_extent,
439+
);
438440
fail(
439441
&ctx.device,
440-
|| {
441-
encoder_for_texture_texture_copy.copy_texture_to_texture(
442-
texture_for_read.as_image_copy(),
443-
texture_for_write.as_image_copy(),
444-
texture_extent,
445-
);
446-
},
442+
|| encoder_for_texture_texture_copy.finish(),
447443
Some("device with '' label is invalid"),
448444
);
449445

wgpu-core/src/command/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@ pub use timestamp_writes::PassTimestampWrites;
3030

3131
use self::memory_init::CommandBufferTextureMemoryActions;
3232

33+
use crate::command::transition_resources::TransitionResourcesError;
3334
use crate::device::queue::TempResource;
3435
use crate::device::{Device, DeviceError, MissingFeatures};
3536
use crate::lock::{rank, Mutex};
3637
use crate::snatch::SnatchGuard;
3738

3839
use crate::init_tracker::BufferInitTrackerAction;
3940
use crate::ray_tracing::AsAction;
40-
use crate::resource::{Fallible, InvalidResourceError, Labeled, ParentDevice as _, QuerySet};
41+
use crate::resource::{
42+
DestroyedResourceError, Fallible, InvalidResourceError, Labeled, ParentDevice as _, QuerySet,
43+
};
4144
use crate::storage::Storage;
42-
use crate::track::{DeviceTracker, Tracker, UsageScope};
45+
use crate::track::{DeviceTracker, ResourceUsageCompatibilityError, Tracker, UsageScope};
4346
use crate::{api_log, global::Global, id, resource_log, Label};
4447
use crate::{hal_label, LabelHelpers};
4548

@@ -886,7 +889,17 @@ pub enum CommandEncoderError {
886889
#[error(transparent)]
887890
InvalidResource(#[from] InvalidResourceError),
888891
#[error(transparent)]
892+
DestroyedResource(#[from] DestroyedResourceError),
893+
#[error(transparent)]
894+
ResourceUsage(#[from] ResourceUsageCompatibilityError),
895+
#[error(transparent)]
889896
MissingFeatures(#[from] MissingFeatures),
897+
#[error(transparent)]
898+
Transfer(#[from] TransferError),
899+
#[error(transparent)]
900+
Clear(#[from] ClearError),
901+
#[error(transparent)]
902+
TransitionResources(#[from] TransitionResourcesError),
890903
#[error(
891904
"begin and end indices of pass timestamp writes are both set to {idx}, which is not allowed"
892905
)]

0 commit comments

Comments
 (0)