Don't ignore unbatchable sorted items. (#13144)
In #12889, I mistakenly started dropping unbatchable sorted items on the floor instead of giving them solitary batches. This caused the objects in the `shader_instancing` demo to stop showing up. This patch fixes the issue by giving those items their own batches as expected. Fixes #13130.
This commit is contained in:
		
							parent
							
								
									abbaa3943e
								
							
						
					
					
						commit
						f1db525f14
					
				| @ -303,7 +303,9 @@ where | |||||||
| 
 | 
 | ||||||
|     /// Metadata that can be used to determine whether an instance can be placed
 |     /// Metadata that can be used to determine whether an instance can be placed
 | ||||||
|     /// into this batch.
 |     /// into this batch.
 | ||||||
|     meta: BatchMeta<F::CompareData>, |     ///
 | ||||||
|  |     /// If `None`, the item inside is unbatchable.
 | ||||||
|  |     meta: Option<BatchMeta<F::CompareData>>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl<F> SortedRenderBatch<F> | impl<F> SortedRenderBatch<F> | ||||||
| @ -405,29 +407,22 @@ pub fn batch_and_prepare_sorted_render_phase<I, GFBD>( | |||||||
| 
 | 
 | ||||||
|             // Unpack that index and metadata. Note that it's possible for index
 |             // Unpack that index and metadata. Note that it's possible for index
 | ||||||
|             // and/or metadata to not be present, which signifies that this
 |             // and/or metadata to not be present, which signifies that this
 | ||||||
|             // entity is unbatchable. In that case, we break the batch here and
 |             // entity is unbatchable. In that case, we break the batch here.
 | ||||||
|             // otherwise ignore the phase item.
 |             let (mut current_input_index, mut current_meta) = (None, None); | ||||||
|             let (current_input_index, current_meta); |             if let Some((input_index, maybe_meta)) = current_batch_input_index { | ||||||
|             match current_batch_input_index { |                 current_input_index = Some(input_index); | ||||||
|                 Some((input_index, Some(current_compare_data))) => { |                 current_meta = | ||||||
|                     current_input_index = Some(input_index); |                     maybe_meta.map(|meta| BatchMeta::new(&phase.items[current_index], meta)); | ||||||
|                     current_meta = Some(BatchMeta::new( |  | ||||||
|                         &phase.items[current_index], |  | ||||||
|                         current_compare_data, |  | ||||||
|                     )); |  | ||||||
|                 } |  | ||||||
|                 _ => { |  | ||||||
|                     current_input_index = None; |  | ||||||
|                     current_meta = None; |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // Determine if this entity can be included in the batch we're
 |             // Determine if this entity can be included in the batch we're
 | ||||||
|             // building up.
 |             // building up.
 | ||||||
|             let can_batch = batch.as_ref().is_some_and(|batch| { |             let can_batch = batch.as_ref().is_some_and(|batch| { | ||||||
|                 current_meta |                 // `None` for metadata indicates that the items are unbatchable.
 | ||||||
|                     .as_ref() |                 match (¤t_meta, &batch.meta) { | ||||||
|                     .is_some_and(|current_meta| batch.meta == *current_meta) |                     (Some(current_meta), Some(batch_meta)) => current_meta == batch_meta, | ||||||
|  |                     (_, _) => false, | ||||||
|  |                 } | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             // Make space in the data buffer for this instance.
 |             // Make space in the data buffer for this instance.
 | ||||||
| @ -442,23 +437,21 @@ pub fn batch_and_prepare_sorted_render_phase<I, GFBD>( | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 // Start a new batch.
 |                 // Start a new batch.
 | ||||||
|                 batch = current_meta.map(|meta| { |                 let indirect_parameters_index = if gpu_culling { | ||||||
|                     let indirect_parameters_index = if gpu_culling { |                     GFBD::get_batch_indirect_parameters_index( | ||||||
|                         GFBD::get_batch_indirect_parameters_index( |                         &system_param_item, | ||||||
|                             &system_param_item, |                         &mut indirect_parameters_buffer, | ||||||
|                             &mut indirect_parameters_buffer, |                         current_entity, | ||||||
|                             current_entity, |                         output_index, | ||||||
|                             output_index, |                     ) | ||||||
|                         ) |                 } else { | ||||||
|                     } else { |                     None | ||||||
|                         None |                 }; | ||||||
|                     }; |                 batch = Some(SortedRenderBatch { | ||||||
|                     SortedRenderBatch { |                     phase_item_start_index: current_index as u32, | ||||||
|                         phase_item_start_index: current_index as u32, |                     instance_start_index: output_index, | ||||||
|                         instance_start_index: output_index, |                     indirect_parameters_index, | ||||||
|                         indirect_parameters_index, |                     meta: current_meta, | ||||||
|                         meta, |  | ||||||
|                     } |  | ||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Patrick Walton
						Patrick Walton