@@ -6,7 +6,7 @@ use crate::scaffold::shader::WgslComputeShader;
6
6
use anyhow:: Context ;
7
7
use bytemuck:: Pod ;
8
8
use futures:: executor:: block_on;
9
- use std:: { borrow:: Cow , fs :: File , io :: Write , sync:: Arc } ;
9
+ use std:: { borrow:: Cow , sync:: Arc } ;
10
10
use wgpu:: { PipelineCompilationOptions , util:: DeviceExt } ;
11
11
12
12
pub type BufferConfig = backend:: BufferConfig ;
@@ -217,8 +217,7 @@ where
217
217
/// Runs the compute shader with no input and writes the output to a file.
218
218
pub fn run_test ( self , config : & Config ) -> anyhow:: Result < ( ) > {
219
219
let output = self . run ( ) ?;
220
- let mut f = File :: create ( & config. output_path ) ?;
221
- f. write_all ( & output) ?;
220
+ config. write_result ( & output) ?;
222
221
Ok ( ( ) )
223
222
}
224
223
@@ -228,8 +227,7 @@ where
228
227
I : Sized + Pod ,
229
228
{
230
229
let output = self . run_with_input ( input) ?;
231
- let mut f = File :: create ( & config. output_path ) ?;
232
- f. write_all ( & output) ?;
230
+ config. write_result ( & output) ?;
233
231
Ok ( ( ) )
234
232
}
235
233
}
@@ -565,8 +563,7 @@ where
565
563
// Write the first storage buffer output to the file.
566
564
for ( output, buffer_config) in outputs. iter ( ) . zip ( & buffers) {
567
565
if matches ! ( buffer_config. usage, BufferUsage :: Storage ) && !output. is_empty ( ) {
568
- let mut f = File :: create ( & config. output_path ) ?;
569
- f. write_all ( output) ?;
566
+ config. write_result ( output) ?;
570
567
return Ok ( ( ) ) ;
571
568
}
572
569
}
@@ -775,8 +772,7 @@ where
775
772
// Write first storage buffer output to file.
776
773
for ( data, buffer_config) in results. iter ( ) . zip ( & buffers) {
777
774
if buffer_config. usage == BufferUsage :: Storage && !data. is_empty ( ) {
778
- let mut f = File :: create ( & config. output_path ) ?;
779
- f. write_all ( data) ?;
775
+ config. write_result ( data) ?;
780
776
return Ok ( ( ) ) ;
781
777
}
782
778
}
0 commit comments