mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 08:13:27 +00:00
chore: [wgpu-tests] use concrete error messages for failures
resolves #5727
This commit is contained in:
parent
abc56417bb
commit
9972d2c18a
@ -373,7 +373,7 @@ fn separate_pipelines_have_incompatible_derived_bgls(ctx: TestingContext) {
|
||||
|| {
|
||||
drop(pass);
|
||||
},
|
||||
None,
|
||||
Some("label at index 0 is not compatible with the corresponding bindgrouplayout"),
|
||||
);
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ fn derived_bgls_incompatible_with_regular_bgls(ctx: TestingContext) {
|
||||
|| {
|
||||
drop(pass);
|
||||
},
|
||||
None,
|
||||
Some("label at index 0 is not compatible with the corresponding bindgrouplayout"),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -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"),
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -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,
|
||||
error_message.is_some(),
|
||||
|| 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, 0, 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, 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, 4, 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;
|
||||
|
@ -298,7 +298,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.
|
||||
@ -312,7 +312,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.
|
||||
@ -334,7 +334,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
||||
view_formats: &[],
|
||||
});
|
||||
},
|
||||
None,
|
||||
Some("device with '' label is invalid"),
|
||||
);
|
||||
|
||||
// Texture clear should fail.
|
||||
@ -352,7 +352,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
||||
},
|
||||
);
|
||||
},
|
||||
None,
|
||||
Some("device with '' label is invalid"),
|
||||
);
|
||||
|
||||
// Creating a compute pass should fail.
|
||||
@ -364,7 +364,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.
|
||||
@ -383,7 +383,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.
|
||||
@ -398,7 +398,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.
|
||||
@ -418,7 +418,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.
|
||||
@ -438,7 +438,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.
|
||||
@ -451,7 +451,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.
|
||||
@ -464,7 +464,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
||||
entries: &[],
|
||||
});
|
||||
},
|
||||
None,
|
||||
Some("device with '' label is invalid"),
|
||||
);
|
||||
|
||||
// Creating a bind group should fail.
|
||||
@ -482,7 +482,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
||||
}],
|
||||
});
|
||||
},
|
||||
None,
|
||||
Some("device with '' label is invalid"),
|
||||
);
|
||||
|
||||
// Creating a pipeline layout should fail.
|
||||
@ -496,7 +496,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.
|
||||
@ -509,7 +509,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.
|
||||
@ -522,7 +522,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.
|
||||
@ -547,7 +547,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
||||
cache: None,
|
||||
});
|
||||
},
|
||||
None,
|
||||
Some("device with '' label is invalid"),
|
||||
);
|
||||
|
||||
// Creating a compute pipeline should fail.
|
||||
@ -564,7 +564,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
||||
cache: None,
|
||||
});
|
||||
},
|
||||
None,
|
||||
Some("device with '' label is invalid"),
|
||||
);
|
||||
|
||||
// Creating a compute pipeline should fail.
|
||||
@ -581,7 +581,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
||||
cache: None,
|
||||
});
|
||||
},
|
||||
None,
|
||||
Some("device with '' label is invalid"),
|
||||
);
|
||||
|
||||
// Buffer map should fail.
|
||||
@ -592,7 +592,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.
|
||||
@ -601,7 +601,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
||||
|| {
|
||||
buffer_for_unmap.unmap();
|
||||
},
|
||||
None,
|
||||
Some("device with '' label is invalid"),
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -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
|
||||
|
@ -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"),
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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"),
|
||||
);
|
||||
});
|
||||
|
@ -46,6 +46,6 @@ static QUEUE_WRITE_TEXTURE_OVERFLOW: GpuTestConfiguration =
|
||||
},
|
||||
);
|
||||
},
|
||||
None,
|
||||
Some("end up overrunning the bounds of the destination texture"),
|
||||
);
|
||||
});
|
||||
|
@ -14,15 +14,24 @@ static BAD_BUFFER: GpuTestConfiguration = GpuTestConfiguration::new().run_sync(|
|
||||
mapped_at_creation: false,
|
||||
})
|
||||
},
|
||||
None,
|
||||
Some("`map` usage can only be combined with the opposite `copy`"),
|
||||
);
|
||||
|
||||
let error = match ctx.adapter_info.backend.to_str() {
|
||||
"vulkan" | "vk" => "bufferid id(0,1,vk) is invalid",
|
||||
"dx12" | "d3d12" => "bufferid id(0,1,d3d12) is invalid",
|
||||
"metal" | "mtl" => "bufferid id(0,1,mtl) is invalid",
|
||||
"opengl" | "gles" | "gl" => "bufferid id(0,1,gl) is invalid",
|
||||
"webgpu" => "bufferid id(0,1,webgpu) is invalid",
|
||||
b => b,
|
||||
};
|
||||
|
||||
fail(
|
||||
&ctx.device,
|
||||
|| buffer.slice(..).map_async(wgpu::MapMode::Write, |_| {}),
|
||||
None,
|
||||
Some(error),
|
||||
);
|
||||
fail(&ctx.device, || buffer.unmap(), None);
|
||||
fail(&ctx.device, || buffer.unmap(), Some(error));
|
||||
valid(&ctx.device, || buffer.destroy());
|
||||
valid(&ctx.device, || buffer.destroy());
|
||||
});
|
||||
@ -47,15 +56,24 @@ static BAD_TEXTURE: GpuTestConfiguration = GpuTestConfiguration::new().run_sync(
|
||||
view_formats: &[],
|
||||
})
|
||||
},
|
||||
None,
|
||||
Some("dimension x is zero"),
|
||||
);
|
||||
|
||||
let error = match ctx.adapter_info.backend.to_str() {
|
||||
"vulkan" | "vk" => "textureid id(0,1,vk) is invalid",
|
||||
"dx12" | "d3d12" => "textureid id(0,1,d3d12) is invalid",
|
||||
"metal" | "mtl" => "textureid id(0,1,mtl) is invalid",
|
||||
"opengl" | "gles" | "gl" => "textureid id(0,1,gl) is invalid",
|
||||
"webgpu" => "textureid id(0,1,webgpu) is invalid",
|
||||
b => b,
|
||||
};
|
||||
|
||||
fail(
|
||||
&ctx.device,
|
||||
|| {
|
||||
let _ = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
},
|
||||
None,
|
||||
Some(error),
|
||||
);
|
||||
valid(&ctx.device, || texture.destroy());
|
||||
valid(&ctx.device, || texture.destroy());
|
||||
|
@ -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"),
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user