11use std:: num:: NonZeroU32 ;
22
3- use wgpu_test:: { gpu_test, image:: ReadbackBuffers , GpuTestConfiguration , TestParameters } ;
3+ use wgpu_test:: {
4+ gpu_test, image:: ReadbackBuffers , GpuTestConfiguration , TestParameters , TestingContext ,
5+ } ;
46
57#[ gpu_test]
68static PARTIALLY_BOUNDED_ARRAY : GpuTestConfiguration = GpuTestConfiguration :: new ( )
@@ -14,90 +16,92 @@ static PARTIALLY_BOUNDED_ARRAY: GpuTestConfiguration = GpuTestConfiguration::new
1416 )
1517 . limits ( wgpu:: Limits :: downlevel_defaults ( ) ) ,
1618 )
17- . run_async ( |ctx| async move {
18- let device = & ctx. device ;
19+ . run_async ( partially_bounded_arrays) ;
1920
20- let texture_extent = wgpu:: Extent3d {
21- width : 1 ,
22- height : 1 ,
23- depth_or_array_layers : 1 ,
24- } ;
25- let storage_texture = device. create_texture ( & wgpu:: TextureDescriptor {
26- label : None ,
27- size : texture_extent,
28- mip_level_count : 1 ,
29- sample_count : 1 ,
30- dimension : wgpu:: TextureDimension :: D2 ,
31- format : wgpu:: TextureFormat :: Rgba32Float ,
32- usage : wgpu:: TextureUsages :: TEXTURE_BINDING
33- | wgpu:: TextureUsages :: COPY_DST
34- | wgpu:: TextureUsages :: STORAGE_BINDING
35- | wgpu:: TextureUsages :: COPY_SRC ,
36- view_formats : & [ ] ,
37- } ) ;
21+ async fn partially_bounded_arrays ( ctx : TestingContext ) {
22+ let device = & ctx. device ;
3823
39- let texture_view = storage_texture. create_view ( & wgpu:: TextureViewDescriptor :: default ( ) ) ;
24+ let texture_extent = wgpu:: Extent3d {
25+ width : 1 ,
26+ height : 1 ,
27+ depth_or_array_layers : 1 ,
28+ } ;
29+ let storage_texture = device. create_texture ( & wgpu:: TextureDescriptor {
30+ label : None ,
31+ size : texture_extent,
32+ mip_level_count : 1 ,
33+ sample_count : 1 ,
34+ dimension : wgpu:: TextureDimension :: D2 ,
35+ format : wgpu:: TextureFormat :: Rgba32Float ,
36+ usage : wgpu:: TextureUsages :: TEXTURE_BINDING
37+ | wgpu:: TextureUsages :: COPY_DST
38+ | wgpu:: TextureUsages :: STORAGE_BINDING
39+ | wgpu:: TextureUsages :: COPY_SRC ,
40+ view_formats : & [ ] ,
41+ } ) ;
4042
41- let bind_group_layout = device. create_bind_group_layout ( & wgpu:: BindGroupLayoutDescriptor {
42- label : Some ( "bind group layout" ) ,
43- entries : & [ wgpu:: BindGroupLayoutEntry {
44- binding : 0 ,
45- visibility : wgpu:: ShaderStages :: COMPUTE ,
46- ty : wgpu:: BindingType :: StorageTexture {
47- access : wgpu:: StorageTextureAccess :: WriteOnly ,
48- format : wgpu:: TextureFormat :: Rgba32Float ,
49- view_dimension : wgpu:: TextureViewDimension :: D2 ,
50- } ,
43+ let texture_view = storage_texture. create_view ( & wgpu:: TextureViewDescriptor :: default ( ) ) ;
5144
52- count : NonZeroU32 :: new ( 4 ) ,
53- } ] ,
54- } ) ;
45+ let bind_group_layout = device. create_bind_group_layout ( & wgpu:: BindGroupLayoutDescriptor {
46+ label : Some ( "bind group layout" ) ,
47+ entries : & [ wgpu:: BindGroupLayoutEntry {
48+ binding : 0 ,
49+ visibility : wgpu:: ShaderStages :: COMPUTE ,
50+ ty : wgpu:: BindingType :: StorageTexture {
51+ access : wgpu:: StorageTextureAccess :: WriteOnly ,
52+ format : wgpu:: TextureFormat :: Rgba32Float ,
53+ view_dimension : wgpu:: TextureViewDimension :: D2 ,
54+ } ,
5555
56- let cs_module =
57- device. create_shader_module ( wgpu:: include_wgsl!( "partially_bounded_arrays.wgsl" ) ) ;
56+ count : NonZeroU32 :: new ( 4 ) ,
57+ } ] ,
58+ } ) ;
5859
59- let pipeline_layout = device. create_pipeline_layout ( & wgpu:: PipelineLayoutDescriptor {
60- label : Some ( "main" ) ,
61- bind_group_layouts : & [ & bind_group_layout] ,
62- push_constant_ranges : & [ ] ,
63- } ) ;
60+ let cs_module =
61+ device. create_shader_module ( wgpu:: include_wgsl!( "partially_bounded_arrays.wgsl" ) ) ;
6462
65- let compute_pipeline = device. create_compute_pipeline ( & wgpu:: ComputePipelineDescriptor {
66- label : None ,
67- layout : Some ( & pipeline_layout) ,
68- module : & cs_module,
69- entry_point : Some ( "main" ) ,
70- compilation_options : Default :: default ( ) ,
71- cache : None ,
72- } ) ;
63+ let pipeline_layout = device. create_pipeline_layout ( & wgpu:: PipelineLayoutDescriptor {
64+ label : Some ( "main" ) ,
65+ bind_group_layouts : & [ & bind_group_layout] ,
66+ push_constant_ranges : & [ ] ,
67+ } ) ;
7368
74- let bind_group = device. create_bind_group ( & wgpu:: BindGroupDescriptor {
75- entries : & [ wgpu:: BindGroupEntry {
76- binding : 0 ,
77- resource : wgpu:: BindingResource :: TextureViewArray ( & [ & texture_view] ) ,
78- } ] ,
79- layout : & bind_group_layout,
80- label : Some ( "bind group" ) ,
81- } ) ;
69+ let compute_pipeline = device. create_compute_pipeline ( & wgpu:: ComputePipelineDescriptor {
70+ label : None ,
71+ layout : Some ( & pipeline_layout) ,
72+ module : & cs_module,
73+ entry_point : Some ( "main" ) ,
74+ compilation_options : Default :: default ( ) ,
75+ cache : None ,
76+ } ) ;
77+
78+ let bind_group = device. create_bind_group ( & wgpu:: BindGroupDescriptor {
79+ entries : & [ wgpu:: BindGroupEntry {
80+ binding : 0 ,
81+ resource : wgpu:: BindingResource :: TextureViewArray ( & [ & texture_view] ) ,
82+ } ] ,
83+ layout : & bind_group_layout,
84+ label : Some ( "bind group" ) ,
85+ } ) ;
8286
83- let mut encoder =
84- device. create_command_encoder ( & wgpu:: CommandEncoderDescriptor { label : None } ) ;
85- {
86- let mut cpass = encoder. begin_compute_pass ( & wgpu:: ComputePassDescriptor {
87- label : None ,
88- timestamp_writes : None ,
89- } ) ;
90- cpass. set_pipeline ( & compute_pipeline) ;
91- cpass. set_bind_group ( 0 , & bind_group, & [ ] ) ;
92- cpass. dispatch_workgroups ( 1 , 1 , 1 ) ;
93- }
87+ let mut encoder =
88+ device. create_command_encoder ( & wgpu:: CommandEncoderDescriptor { label : None } ) ;
89+ {
90+ let mut cpass = encoder. begin_compute_pass ( & wgpu:: ComputePassDescriptor {
91+ label : None ,
92+ timestamp_writes : None ,
93+ } ) ;
94+ cpass. set_pipeline ( & compute_pipeline) ;
95+ cpass. set_bind_group ( 0 , & bind_group, & [ ] ) ;
96+ cpass. dispatch_workgroups ( 1 , 1 , 1 ) ;
97+ }
9498
95- let readback_buffers = ReadbackBuffers :: new ( & ctx. device , & storage_texture) ;
96- readback_buffers. copy_from ( & ctx. device , & mut encoder, & storage_texture) ;
99+ let readback_buffers = ReadbackBuffers :: new ( & ctx. device , & storage_texture) ;
100+ readback_buffers. copy_from ( & ctx. device , & mut encoder, & storage_texture) ;
97101
98- ctx. queue . submit ( Some ( encoder. finish ( ) ) ) ;
102+ ctx. queue . submit ( Some ( encoder. finish ( ) ) ) ;
99103
100- readback_buffers
101- . assert_buffer_contents ( & ctx, bytemuck:: bytes_of ( & [ 4.0f32 , 3.0 , 2.0 , 1.0 ] ) )
102- . await ;
103- } ) ;
104+ readback_buffers
105+ . assert_buffer_contents ( & ctx, bytemuck:: bytes_of ( & [ 4.0f32 , 3.0 , 2.0 , 1.0 ] ) )
106+ . await ;
107+ }
0 commit comments