@@ -14,7 +14,7 @@ use wgc::{
1414 binding_model:: BindingResource ,
1515 command:: { ArcCommand , ArcReferences , BasePass , Command , PointerReferences } ,
1616 device:: trace:: { self , DataKind , DataLoader } ,
17- id:: PointerId ,
17+ id:: { Marker , PointerId } ,
1818} ;
1919
2020pub struct Player {
@@ -88,6 +88,28 @@ impl Default for Player {
8888 }
8989}
9090
91+ fn process_result < T : Marker , U > (
92+ op : & str ,
93+ map : & mut HashMap < PointerId < T > , U > ,
94+ id : Option < PointerId < T > > ,
95+ value : Result < U , impl std:: error:: Error > ,
96+ ) {
97+ match ( id, value) {
98+ ( Some ( id) , Ok ( value) ) => {
99+ map. insert ( id, value) ;
100+ }
101+ ( Some ( _) , Err ( err) ) => {
102+ panic ! ( "{op} succeeded when recording, but failed on playback: {err}" ) ;
103+ }
104+ ( None , Ok ( _) ) => {
105+ panic ! ( "{op} failed when recording, but succeeded on playback" ) ;
106+ }
107+ ( None , Err ( err) ) => {
108+ panic ! ( "{op} failed when recording, and failed on playback: {err}" ) ;
109+ }
110+ }
111+ }
112+
91113impl Player {
92114 pub fn process (
93115 & mut self ,
@@ -323,10 +345,13 @@ impl Player {
323345 }
324346 Action :: CreateComputePipeline { id, desc } => {
325347 let resolved_desc = self . resolve_compute_pipeline_descriptor ( desc) ;
326- let pipeline = device
327- . create_compute_pipeline ( resolved_desc)
328- . expect ( "create_compute_pipeline error" ) ;
329- self . compute_pipelines . insert ( id, pipeline) ;
348+ let pipeline = device. create_compute_pipeline ( resolved_desc) ;
349+ process_result (
350+ "create_compute_pipeline" ,
351+ & mut self . compute_pipelines ,
352+ id,
353+ pipeline,
354+ ) ;
330355 }
331356 Action :: DestroyComputePipeline ( id) => {
332357 self . compute_pipelines
@@ -338,10 +363,13 @@ impl Player {
338363 // pipeline descriptor that can represent either a conventional
339364 // pipeline or a mesh shading pipeline.
340365 let resolved_desc = self . resolve_render_pipeline_descriptor ( desc) ;
341- let pipeline = device
342- . create_render_pipeline ( resolved_desc)
343- . expect ( "create_render_pipeline error" ) ;
344- self . render_pipelines . insert ( id, pipeline) ;
366+ let pipeline = device. create_render_pipeline ( resolved_desc) ;
367+ process_result (
368+ "create_render_pipeline" ,
369+ & mut self . render_pipelines ,
370+ id,
371+ pipeline,
372+ ) ;
345373 }
346374 Action :: DestroyRenderPipeline ( id) => {
347375 self . render_pipelines
0 commit comments