|
1 | 1 | //! Tests for buffer copy validation.
|
2 | 2 |
|
| 3 | +use wgpu::PollType; |
3 | 4 | use wgpu_test::{fail, gpu_test, GpuTestConfiguration};
|
4 | 5 |
|
| 6 | +#[gpu_test] |
| 7 | +static QUEUE_WRITE_TEXTURE_THEN_DESTROY: GpuTestConfiguration = GpuTestConfiguration::new() |
| 8 | + .run_sync(|ctx| { |
| 9 | + let texture = ctx.device.create_texture(&wgpu::TextureDescriptor { |
| 10 | + label: None, |
| 11 | + size: wgpu::Extent3d { |
| 12 | + width: 64, |
| 13 | + height: 32, |
| 14 | + depth_or_array_layers: 1, |
| 15 | + }, |
| 16 | + mip_level_count: 1, |
| 17 | + sample_count: 1, |
| 18 | + dimension: wgpu::TextureDimension::D2, |
| 19 | + format: wgpu::TextureFormat::Rgba32Float, |
| 20 | + usage: wgpu::TextureUsages::COPY_DST, |
| 21 | + view_formats: &[], |
| 22 | + }); |
| 23 | + |
| 24 | + let data = vec![255; 1024]; |
| 25 | + |
| 26 | + ctx.queue.write_texture( |
| 27 | + wgpu::TexelCopyTextureInfo { |
| 28 | + texture: &texture, |
| 29 | + mip_level: 0, |
| 30 | + origin: wgpu::Origin3d { x: 0, y: 0, z: 0 }, |
| 31 | + aspect: wgpu::TextureAspect::All, |
| 32 | + }, |
| 33 | + &data, |
| 34 | + wgpu::TexelCopyBufferLayout { |
| 35 | + offset: 0, |
| 36 | + bytes_per_row: Some(1024), |
| 37 | + rows_per_image: Some(32), |
| 38 | + }, |
| 39 | + wgpu::Extent3d { |
| 40 | + width: 64, |
| 41 | + height: 1, |
| 42 | + depth_or_array_layers: 1, |
| 43 | + }, |
| 44 | + ); |
| 45 | + |
| 46 | + // Unlike textures used in a command buffer, which must not be destroyed prior to calling |
| 47 | + // submit, it is permissible to destroy a texture used in an immediate queue operation |
| 48 | + // before calling submit. |
| 49 | + texture.destroy(); |
| 50 | + |
| 51 | + ctx.queue.submit([]); |
| 52 | + ctx.device.poll(PollType::wait()).unwrap(); |
| 53 | + }); |
| 54 | + |
5 | 55 | #[gpu_test]
|
6 | 56 | static QUEUE_WRITE_TEXTURE_OVERFLOW: GpuTestConfiguration =
|
7 | 57 | GpuTestConfiguration::new().run_sync(|ctx| {
|
|
0 commit comments