mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-04-16 05:56:37 +00:00
Add validation tests ensuring destroyed textures and buffers cause submission to fail (#7181)
This commit is contained in:
parent
b5e32cec58
commit
7e42040fa5
@ -2,6 +2,28 @@
|
||||
|
||||
use core::num::NonZero;
|
||||
|
||||
/// 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) = crate::request_noop_device();
|
||||
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()]);
|
||||
}
|
||||
|
||||
mod buffer_slice {
|
||||
use super::*;
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
mod buffer;
|
||||
mod texture;
|
||||
|
56
tests/validation_tests/api/texture.rs
Normal file
56
tests/validation_tests/api/texture.rs
Normal file
@ -0,0 +1,56 @@
|
||||
//! Tests of [`wgpu::Texture`] and related.
|
||||
|
||||
/// Ensures that submitting a command buffer referencing an already destroyed texture
|
||||
/// results in an error.
|
||||
#[test]
|
||||
#[should_panic = "Texture with 'dst' label has been destroyed"]
|
||||
fn destroyed_texture() {
|
||||
let (device, queue) = crate::request_noop_device();
|
||||
let size = wgpu::Extent3d {
|
||||
width: 256,
|
||||
height: 256,
|
||||
depth_or_array_layers: 1,
|
||||
};
|
||||
let texture_src = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("src"),
|
||||
size,
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: wgpu::TextureFormat::Rgba8Unorm,
|
||||
usage: wgpu::TextureUsages::COPY_SRC,
|
||||
view_formats: &[],
|
||||
});
|
||||
let texture_dst = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("dst"),
|
||||
size,
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: wgpu::TextureFormat::Rgba8Unorm,
|
||||
usage: wgpu::TextureUsages::COPY_DST,
|
||||
view_formats: &[],
|
||||
});
|
||||
|
||||
let mut encoder =
|
||||
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
|
||||
encoder.copy_texture_to_texture(
|
||||
wgpu::TexelCopyTextureInfo {
|
||||
texture: &texture_src,
|
||||
mip_level: 0,
|
||||
origin: wgpu::Origin3d::ZERO,
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
},
|
||||
wgpu::TexelCopyTextureInfo {
|
||||
texture: &texture_dst,
|
||||
mip_level: 0,
|
||||
origin: wgpu::Origin3d::ZERO,
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
},
|
||||
size,
|
||||
);
|
||||
|
||||
texture_dst.destroy();
|
||||
|
||||
queue.submit([encoder.finish()]);
|
||||
}
|
Loading…
Reference in New Issue
Block a user