diff --git a/tests/tests/bind_group_layout_dedup.rs b/tests/tests/bind_group_layout_dedup.rs index e4262ea2155..31703ac5727 100644 --- a/tests/tests/bind_group_layout_dedup.rs +++ b/tests/tests/bind_group_layout_dedup.rs @@ -373,7 +373,7 @@ fn separate_programs_have_incompatible_derived_bgls(ctx: TestingContext) { || { drop(pass); }, - None, + Some("label at index 0 is not compatible with the corresponding bindgrouplayout"), ); } @@ -445,6 +445,6 @@ fn derived_bgls_incompatible_with_regular_bgls(ctx: TestingContext) { || { drop(pass); }, - None, + Some("label at index 0 is not compatible with the corresponding bindgrouplayout"), ) } diff --git a/tests/tests/buffer.rs b/tests/tests/buffer.rs index e2316daadce..53d7c119f70 100644 --- a/tests/tests/buffer.rs +++ b/tests/tests/buffer.rs @@ -230,7 +230,7 @@ static MINIMUM_BUFFER_BINDING_SIZE_LAYOUT: GpuTestConfiguration = GpuTestConfigu cache: None, }); }, - None, + Some("shader global resourcebinding { group: 0, binding: 0 } is not available in the pipeline layout"), ); }); @@ -335,7 +335,7 @@ static MINIMUM_BUFFER_BINDING_SIZE_DISPATCH: GpuTestConfiguration = GpuTestConfi drop(pass); let _ = encoder.finish(); }, - None, + Some("buffer is bound with size 16 where the shader expects 32 in group[0] compact index 0"), ); }); diff --git a/tests/tests/buffer_copy.rs b/tests/tests/buffer_copy.rs index 698097f1b62..88c3425134d 100644 --- a/tests/tests/buffer_copy.rs +++ b/tests/tests/buffer_copy.rs @@ -8,31 +8,62 @@ fn try_copy( ctx: &wgpu_test::TestingContext, offset: BufferAddress, size: BufferAddress, - should_fail: bool, + error_message: Option<&'static str>, ) { let buffer = ctx.device.create_buffer(&BUFFER_DESCRIPTOR); let data = vec![255; size as usize]; + fail_if( &ctx.device, - should_fail, + !matches!(error_message, Option::None), || ctx.queue.write_buffer(&buffer, offset, &data), - None, + error_message, ); } #[gpu_test] static COPY_ALIGNMENT: GpuTestConfiguration = GpuTestConfiguration::new().run_sync(|ctx| { - try_copy(&ctx, 0, 0, false); - try_copy(&ctx, 4, 16 + 1, true); - try_copy(&ctx, 64, 20 + 2, true); - try_copy(&ctx, 256, 44 + 3, true); - try_copy(&ctx, 1024, 8 + 4, false); - - try_copy(&ctx, 0, 4, false); - try_copy(&ctx, 4 + 1, 8, true); - try_copy(&ctx, 64 + 2, 12, true); - try_copy(&ctx, 256 + 3, 16, true); - try_copy(&ctx, 1024 + 4, 4, false); + try_copy(&ctx, 0, 0, Option::None); + try_copy( + &ctx, + 4, + 16 + 1, + Some("copy size 17 does not respect `copy_buffer_alignment`"), + ); + try_copy( + &ctx, + 64, + 20 + 2, + Some("copy size 22 does not respect `copy_buffer_alignment`"), + ); + try_copy( + &ctx, + 256, + 44 + 3, + Some("copy size 47 does not respect `copy_buffer_alignment`"), + ); + try_copy(&ctx, 1024, 8 + 4, None); + + try_copy(&ctx, 0, 4, Option::None); + try_copy( + &ctx, + 4 + 1, + 8, + Some("buffer offset 5 is not aligned to block size or `copy_buffer_alignment`"), + ); + try_copy( + &ctx, + 64 + 2, + 12, + Some("buffer offset 66 is not aligned to block size or `copy_buffer_alignment`"), + ); + try_copy( + &ctx, + 256 + 3, + 16, + Some("buffer offset 259 is not aligned to block size or `copy_buffer_alignment`"), + ); + try_copy(&ctx, 1024 + 4, 4, None); }); const BUFFER_SIZE: BufferAddress = 1234; diff --git a/tests/tests/device.rs b/tests/tests/device.rs index f932faa2f13..2a8b7091e49 100644 --- a/tests/tests/device.rs +++ b/tests/tests/device.rs @@ -296,7 +296,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne ctx.device .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); }, - None, + Some("device with '' label is invalid"), ); // Creating a buffer should fail. @@ -310,7 +310,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne mapped_at_creation: false, }); }, - None, + Some("device with '' label is invalid"), ); // Creating a texture should fail. @@ -332,7 +332,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne view_formats: &[], }); }, - None, + Some("device with '' label is invalid"), ); // Texture clear should fail. @@ -350,7 +350,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne }, ); }, - None, + Some("device with '' label is invalid"), ); // Creating a compute pass should fail. @@ -362,7 +362,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne timestamp_writes: None, }); }, - None, + Some("device with '' label is invalid"), ); // Creating a render pass should fail. @@ -381,7 +381,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne occlusion_query_set: None, }); }, - None, + Some("device with '' label is invalid"), ); // Copying a buffer to a buffer should fail. @@ -396,7 +396,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne 256, ); }, - None, + Some("device with '' label is invalid"), ); // Copying a buffer to a texture should fail. @@ -416,7 +416,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne texture_extent, ); }, - None, + Some("device with '' label is invalid"), ); // Copying a texture to a buffer should fail. @@ -436,7 +436,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne texture_extent, ); }, - None, + Some("device with '' label is invalid"), ); // Copying a texture to a texture should fail. @@ -449,7 +449,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne texture_extent, ); }, - None, + Some("device with '' label is invalid"), ); // Creating a bind group layout should fail. @@ -462,7 +462,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne entries: &[], }); }, - None, + Some("device with '' label is invalid"), ); // Creating a bind group should fail. @@ -480,7 +480,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne }], }); }, - None, + Some("device with '' label is invalid"), ); // Creating a pipeline layout should fail. @@ -494,7 +494,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne push_constant_ranges: &[], }); }, - None, + Some("device with '' label is invalid"), ); // Creating a shader module should fail. @@ -507,7 +507,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed("")), }); }, - None, + Some("device with '' label is invalid"), ); // Creating a shader module spirv should fail. @@ -520,7 +520,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne source: std::borrow::Cow::Borrowed(&[]), }); }, - None, + Some("device with '' label is invalid"), ); // Creating a render pipeline should fail. @@ -545,7 +545,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne cache: None, }); }, - None, + Some("device with '' label is invalid"), ); // Creating a compute pipeline should fail. @@ -562,7 +562,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne cache: None, }); }, - None, + Some("device with '' label is invalid"), ); // Creating a compute pipeline should fail. @@ -579,7 +579,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne cache: None, }); }, - None, + Some("device with '' label is invalid"), ); // Buffer map should fail. @@ -590,7 +590,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne .slice(..) .map_async(wgpu::MapMode::Write, |_| ()); }, - None, + Some("device with '' label is invalid"), ); // Buffer unmap should fail. @@ -599,7 +599,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne || { buffer_for_unmap.unmap(); }, - None, + Some("device with '' label is invalid"), ); }); diff --git a/tests/tests/encoder.rs b/tests/tests/encoder.rs index 337dffc2d0e..2db45296e7a 100644 --- a/tests/tests/encoder.rs +++ b/tests/tests/encoder.rs @@ -68,7 +68,7 @@ static DROP_ENCODER_AFTER_ERROR: GpuTestConfiguration = GpuTestConfiguration::ne renderpass.set_viewport(0.0, 0.0, -1.0, -1.0, 0.0, 1.0); drop(renderpass); }, - None, + Some("viewport has invalid rect"), ); // This is the actual interesting error condition. We've created diff --git a/tests/tests/float32_filterable.rs b/tests/tests/float32_filterable.rs index ee288ac799a..cc1ccd5a2a3 100644 --- a/tests/tests/float32_filterable.rs +++ b/tests/tests/float32_filterable.rs @@ -63,7 +63,7 @@ static FLOAT32_FILTERABLE_WITHOUT_FEATURE: GpuTestConfiguration = GpuTestConfigu || { create_texture_binding(device, wgpu::TextureFormat::R32Float, true); }, - None, + Some("texture binding 0 expects sample type = float { filterable: true }, but given a view with format = r32float"), ); }); diff --git a/tests/tests/life_cycle.rs b/tests/tests/life_cycle.rs index e959743a599..d8d21940c88 100644 --- a/tests/tests/life_cycle.rs +++ b/tests/tests/life_cycle.rs @@ -4,7 +4,7 @@ use wgpu_test::{fail, gpu_test, GpuTestConfiguration}; static BUFFER_DESTROY: GpuTestConfiguration = GpuTestConfiguration::new().run_async(|ctx| async move { let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { - label: None, + label: Some("buffer"), size: 256, usage: wgpu::BufferUsages::MAP_WRITE | wgpu::BufferUsages::COPY_SRC, mapped_at_creation: false, @@ -25,7 +25,7 @@ static BUFFER_DESTROY: GpuTestConfiguration = .slice(..) .map_async(wgpu::MapMode::Write, move |_| {}); }, - None, + Some("buffer with 'buffer' label has been destroyed"), ); buffer.destroy(); diff --git a/tests/tests/nv12_texture/mod.rs b/tests/tests/nv12_texture/mod.rs index 6b5a4e0c6b3..7226ea2d269 100644 --- a/tests/tests/nv12_texture/mod.rs +++ b/tests/tests/nv12_texture/mod.rs @@ -149,7 +149,7 @@ static NV12_TEXTURE_VIEW_PLANE_ON_NON_PLANAR_FORMAT: GpuTestConfiguration = ..Default::default() }); }, - None, + Some("aspect plane0 is not in the source texture format r8unorm"), ); }); @@ -181,7 +181,7 @@ static NV12_TEXTURE_VIEW_PLANE_OUT_OF_BOUNDS: GpuTestConfiguration = GpuTestConf ..Default::default() }); }, - None, + Some("aspect plane2 is not in the source texture format nv12"), ); }); @@ -213,7 +213,7 @@ static NV12_TEXTURE_BAD_FORMAT_VIEW_PLANE: GpuTestConfiguration = GpuTestConfigu ..Default::default() }); }, - None, + Some("unable to view texture nv12 as rg8unorm"), ); }); @@ -241,6 +241,6 @@ static NV12_TEXTURE_BAD_SIZE: GpuTestConfiguration = GpuTestConfiguration::new() view_formats: &[], }); }, - None, + Some("width 255 is not a multiple of nv12's width multiple requirement"), ); }); diff --git a/tests/tests/queue_transfer.rs b/tests/tests/queue_transfer.rs index 79a79e0ecfc..6f816374cbc 100644 --- a/tests/tests/queue_transfer.rs +++ b/tests/tests/queue_transfer.rs @@ -46,6 +46,6 @@ static QUEUE_WRITE_TEXTURE_OVERFLOW: GpuTestConfiguration = }, ); }, - None, + Some("end up overrunning the bounds of the destination texture"), ); }); diff --git a/tests/tests/resource_error.rs b/tests/tests/resource_error.rs index 98b55044a7d..a79ecbbc429 100644 --- a/tests/tests/resource_error.rs +++ b/tests/tests/resource_error.rs @@ -14,15 +14,19 @@ static BAD_BUFFER: GpuTestConfiguration = GpuTestConfiguration::new().run_sync(| mapped_at_creation: false, }) }, - None, + Some("`map` usage can only be combined with the opposite `copy`"), ); fail( &ctx.device, || buffer.slice(..).map_async(wgpu::MapMode::Write, |_| {}), - None, + Some("bufferid id(0,1,vk) is invalid"), + ); + fail( + &ctx.device, + || buffer.unmap(), + Some("bufferid id(0,1,vk) is invalid"), ); - fail(&ctx.device, || buffer.unmap(), None); valid(&ctx.device, || buffer.destroy()); valid(&ctx.device, || buffer.destroy()); }); @@ -47,7 +51,7 @@ static BAD_TEXTURE: GpuTestConfiguration = GpuTestConfiguration::new().run_sync( view_formats: &[], }) }, - None, + Some("dimension x is zero"), ); fail( @@ -55,7 +59,7 @@ static BAD_TEXTURE: GpuTestConfiguration = GpuTestConfiguration::new().run_sync( || { let _ = texture.create_view(&wgpu::TextureViewDescriptor::default()); }, - None, + Some("textureid id(0,1,vk) is invalid"), ); valid(&ctx.device, || texture.destroy()); valid(&ctx.device, || texture.destroy()); diff --git a/tests/tests/transfer.rs b/tests/tests/transfer.rs index e69f9755983..3408fe2e833 100644 --- a/tests/tests/transfer.rs +++ b/tests/tests/transfer.rs @@ -64,6 +64,6 @@ static COPY_OVERFLOW_Z: GpuTestConfiguration = GpuTestConfiguration::new().run_s ); ctx.queue.submit(Some(encoder.finish())); }, - None, + Some("unable to select texture mip level"), ); });