mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
This is a useful shortcut for tests and example code, allowing it to create a noop device without needing to deal with nonexistent fallibility and asynchrony.
24 lines
740 B
Rust
24 lines
740 B
Rust
//! Tests of [`wgpu::Buffer`] and related.
|
|
|
|
/// Ensures that submitting a command buffer referencing an already destroyed buffer
|
|
/// results in an error.
|
|
#[test]
|
|
#[should_panic = "Buffer with '' label has been destroyed"]
|
|
fn destroyed_buffer() {
|
|
let (device, queue) = wgpu::Device::noop(&wgpu::DeviceDescriptor::default());
|
|
let buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
|
label: None,
|
|
size: 1024,
|
|
usage: wgpu::BufferUsages::COPY_DST,
|
|
mapped_at_creation: false,
|
|
});
|
|
|
|
let mut encoder =
|
|
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
|
|
encoder.clear_buffer(&buffer, 0, None);
|
|
|
|
buffer.destroy();
|
|
|
|
queue.submit([encoder.finish()]);
|
|
}
|