mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[tests] Test destruction of a used resource before submission (#7853)
* [tests] Test destruction of a used resource before submission Fixes #5031 --------- Co-authored-by: Nicolas Silva <nical@fastmail.com>
This commit is contained in:
parent
201b2fba76
commit
d13e9f5ebf
@ -1,4 +1,5 @@
|
|||||||
use wgpu_test::{fail, gpu_test, GpuTestConfiguration};
|
use wgpu::{util::DeviceExt, Backends};
|
||||||
|
use wgpu_test::{fail, gpu_test, FailureCase, GpuTestConfiguration, TestParameters};
|
||||||
|
|
||||||
#[gpu_test]
|
#[gpu_test]
|
||||||
static BUFFER_DESTROY: GpuTestConfiguration =
|
static BUFFER_DESTROY: GpuTestConfiguration =
|
||||||
@ -99,3 +100,107 @@ static TEXTURE_DESTROY: GpuTestConfiguration =
|
|||||||
|
|
||||||
texture.destroy();
|
texture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Test that destroying a buffer between command buffer recording and
|
||||||
|
// submission fails gracefully.
|
||||||
|
#[gpu_test]
|
||||||
|
static BUFFER_DESTROY_BEFORE_SUBMIT: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||||
|
.parameters(
|
||||||
|
// https://github.com/gfx-rs/wgpu/issues/7854
|
||||||
|
TestParameters::default().skip(FailureCase::backend_adapter(Backends::VULKAN, "llvmpipe")),
|
||||||
|
)
|
||||||
|
.run_sync(|ctx| {
|
||||||
|
let buffer_source = ctx
|
||||||
|
.device
|
||||||
|
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||||
|
label: None,
|
||||||
|
contents: &[0u8; 4],
|
||||||
|
usage: wgpu::BufferUsages::COPY_SRC,
|
||||||
|
});
|
||||||
|
let buffer_dest = ctx.device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
|
label: None,
|
||||||
|
size: 4,
|
||||||
|
usage: wgpu::BufferUsages::COPY_DST,
|
||||||
|
mapped_at_creation: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut encoder = ctx
|
||||||
|
.device
|
||||||
|
.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
|
||||||
|
encoder.copy_buffer_to_buffer(&buffer_source, 0, &buffer_dest, 0, 4);
|
||||||
|
|
||||||
|
buffer_source.destroy();
|
||||||
|
buffer_dest.destroy();
|
||||||
|
|
||||||
|
let cmd_buffer = encoder.finish();
|
||||||
|
|
||||||
|
fail(
|
||||||
|
&ctx.device,
|
||||||
|
|| ctx.queue.submit([cmd_buffer]),
|
||||||
|
Some("Buffer with '' label has been destroyed"),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test that destroying a texture between command buffer recording and
|
||||||
|
// submission fails gracefully.
|
||||||
|
#[gpu_test]
|
||||||
|
static TEXTURE_DESTROY_BEFORE_SUBMIT: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||||
|
.parameters(
|
||||||
|
// https://github.com/gfx-rs/wgpu/issues/7854
|
||||||
|
TestParameters::default().skip(FailureCase::backend_adapter(Backends::VULKAN, "llvmpipe")),
|
||||||
|
)
|
||||||
|
.run_sync(|ctx| {
|
||||||
|
let descriptor = wgpu::TextureDescriptor {
|
||||||
|
label: None,
|
||||||
|
size: wgpu::Extent3d {
|
||||||
|
width: 128,
|
||||||
|
height: 128,
|
||||||
|
depth_or_array_layers: 1,
|
||||||
|
},
|
||||||
|
mip_level_count: 1,
|
||||||
|
sample_count: 1, // multisampling is not supported for clear
|
||||||
|
dimension: wgpu::TextureDimension::D2,
|
||||||
|
format: wgpu::TextureFormat::Rgba8Snorm,
|
||||||
|
usage: wgpu::TextureUsages::COPY_DST
|
||||||
|
| wgpu::TextureUsages::COPY_SRC
|
||||||
|
| wgpu::TextureUsages::TEXTURE_BINDING,
|
||||||
|
view_formats: &[],
|
||||||
|
};
|
||||||
|
|
||||||
|
let texture_1 = ctx.device.create_texture(&descriptor);
|
||||||
|
let texture_2 = ctx.device.create_texture(&descriptor);
|
||||||
|
|
||||||
|
let mut encoder = ctx
|
||||||
|
.device
|
||||||
|
.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
|
||||||
|
encoder.copy_texture_to_texture(
|
||||||
|
wgpu::TexelCopyTextureInfo {
|
||||||
|
texture: &texture_1,
|
||||||
|
mip_level: 0,
|
||||||
|
origin: wgpu::Origin3d::ZERO,
|
||||||
|
aspect: wgpu::TextureAspect::All,
|
||||||
|
},
|
||||||
|
wgpu::TexelCopyTextureInfo {
|
||||||
|
texture: &texture_2,
|
||||||
|
mip_level: 0,
|
||||||
|
origin: wgpu::Origin3d::ZERO,
|
||||||
|
aspect: wgpu::TextureAspect::All,
|
||||||
|
},
|
||||||
|
wgpu::Extent3d {
|
||||||
|
width: 128,
|
||||||
|
height: 128,
|
||||||
|
depth_or_array_layers: 1,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
texture_1.destroy();
|
||||||
|
texture_2.destroy();
|
||||||
|
|
||||||
|
let cmd_buffer = encoder.finish();
|
||||||
|
|
||||||
|
fail(
|
||||||
|
&ctx.device,
|
||||||
|
|| ctx.queue.submit([cmd_buffer]),
|
||||||
|
Some("Texture with '' label has been destroyed"),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user