@@ -6158,6 +6158,23 @@ enum HanabiPipelineId {
6158
6158
Cached ( CachedComputePipelineId ) ,
6159
6159
}
6160
6160
6161
+ pub ( crate ) enum ComputePipelineError {
6162
+ Queued ,
6163
+ Creating ,
6164
+ Error ,
6165
+ }
6166
+
6167
+ impl From < & CachedPipelineState > for ComputePipelineError {
6168
+ fn from ( value : & CachedPipelineState ) -> Self {
6169
+ match value {
6170
+ CachedPipelineState :: Queued => Self :: Queued ,
6171
+ CachedPipelineState :: Creating ( _) => Self :: Creating ,
6172
+ CachedPipelineState :: Err ( _) => Self :: Error ,
6173
+ _ => panic ! ( "Trying to convert Ok state to error." ) ,
6174
+ }
6175
+ }
6176
+ }
6177
+
6161
6178
pub ( crate ) struct HanabiComputePass < ' a > {
6162
6179
/// Pipeline cache to fetch cached compute pipelines by ID.
6163
6180
pipeline_cache : & ' a PipelineCache ,
@@ -6193,22 +6210,24 @@ impl<'a> HanabiComputePass<'a> {
6193
6210
pub fn set_cached_compute_pipeline (
6194
6211
& mut self ,
6195
6212
pipeline_id : CachedComputePipelineId ,
6196
- ) -> Result < ( ) , NodeRunError > {
6213
+ ) -> Result < ( ) , ComputePipelineError > {
6214
+ trace ! ( "set_cached_compute_pipeline() id={pipeline_id:?}" ) ;
6197
6215
if HanabiPipelineId :: Cached ( pipeline_id) == self . pipeline_id {
6216
+ trace ! ( "-> already set; skipped" ) ;
6198
6217
return Ok ( ( ) ) ;
6199
6218
}
6200
6219
let Some ( pipeline) = self . pipeline_cache . get_compute_pipeline ( pipeline_id) else {
6201
- if let CachedPipelineState :: Err ( err) =
6202
- self . pipeline_cache . get_compute_pipeline_state ( pipeline_id)
6203
- {
6220
+ let state = self . pipeline_cache . get_compute_pipeline_state ( pipeline_id) ;
6221
+ if let CachedPipelineState :: Err ( err) = state {
6204
6222
error ! (
6205
6223
"Failed to find compute pipeline #{}: {:?}" ,
6206
6224
pipeline_id. id( ) ,
6207
6225
err
6208
6226
) ;
6227
+ } else {
6228
+ debug ! ( "Compute pipeline not ready #{}" , pipeline_id. id( ) ) ;
6209
6229
}
6210
- // FIXME - Bevy doesn't allow returning custom errors here...
6211
- return Ok ( ( ) ) ;
6230
+ return Err ( state. into ( ) ) ;
6212
6231
} ;
6213
6232
self . compute_pass . set_pipeline ( pipeline) ;
6214
6233
self . pipeline_id = HanabiPipelineId :: Cached ( pipeline_id) ;
@@ -6493,7 +6512,13 @@ impl Node for VfxSimulateNode {
6493
6512
}
6494
6513
}
6495
6514
6496
- compute_pass. set_cached_compute_pipeline ( effects_meta. active_indirect_pipeline_id ) ?;
6515
+ if compute_pass
6516
+ . set_cached_compute_pipeline ( effects_meta. active_indirect_pipeline_id )
6517
+ . is_err ( )
6518
+ {
6519
+ // FIXME - Bevy doesn't allow returning custom errors here...
6520
+ return Ok ( ( ) ) ;
6521
+ }
6497
6522
6498
6523
//error!("FIXME - effect_metadata_buffer has gaps!!!! this won't work. len() is
6499
6524
// the size exluding gaps!");
@@ -6677,7 +6702,14 @@ impl Node for VfxSimulateNode {
6677
6702
warn ! ( "Missing sort-fill pipeline." ) ;
6678
6703
continue ;
6679
6704
} ;
6680
- compute_pass. set_cached_compute_pipeline ( pipeline_id) ?;
6705
+ if compute_pass
6706
+ . set_cached_compute_pipeline ( pipeline_id)
6707
+ . is_err ( )
6708
+ {
6709
+ compute_pass. pop_debug_group ( ) ;
6710
+ // FIXME - Bevy doesn't allow returning custom errors here...
6711
+ return Ok ( ( ) ) ;
6712
+ }
6681
6713
6682
6714
// Bind group sort_fill@0
6683
6715
let particle_buffer = effect_buffer. particle_buffer ( ) ;
@@ -6726,8 +6758,15 @@ impl Node for VfxSimulateNode {
6726
6758
{
6727
6759
compute_pass. push_debug_group ( "hanabi:sort" ) ;
6728
6760
6729
- compute_pass
6730
- . set_cached_compute_pipeline ( sort_bind_groups. sort_pipeline_id ( ) ) ?;
6761
+ if compute_pass
6762
+ . set_cached_compute_pipeline ( sort_bind_groups. sort_pipeline_id ( ) )
6763
+ . is_err ( )
6764
+ {
6765
+ compute_pass. pop_debug_group ( ) ;
6766
+ // FIXME - Bevy doesn't allow returning custom errors here...
6767
+ return Ok ( ( ) ) ;
6768
+ }
6769
+
6731
6770
compute_pass. set_bind_group ( 0 , sort_bind_groups. sort_bind_group ( ) , & [ ] ) ;
6732
6771
let indirect_offset =
6733
6772
sort_bind_groups. get_sort_indirect_dispatch_byte_offset ( ) as u64 ;
@@ -6744,7 +6783,14 @@ impl Node for VfxSimulateNode {
6744
6783
6745
6784
// Fetch compute pipeline
6746
6785
let pipeline_id = sort_bind_groups. get_sort_copy_pipeline_id ( ) ;
6747
- compute_pass. set_cached_compute_pipeline ( pipeline_id) ?;
6786
+ if compute_pass
6787
+ . set_cached_compute_pipeline ( pipeline_id)
6788
+ . is_err ( )
6789
+ {
6790
+ compute_pass. pop_debug_group ( ) ;
6791
+ // FIXME - Bevy doesn't allow returning custom errors here...
6792
+ return Ok ( ( ) ) ;
6793
+ }
6748
6794
6749
6795
// Bind group sort_copy@0
6750
6796
let indirect_index_buffer = effect_buffer. indirect_index_buffer ( ) ;
0 commit comments