Remove the entity index from the UI phase's sort key (#18273)

# Objective

The sort key for the transparent UI phase is a (float32, u32) pair
consisting of the stack index and the render entity's index.
I guess the render entity index was intended to break ties but it's not
needed as the sort is stable. It also assumes the indices of the render
entities are generated sequentially, which isn't guaranteed.

Fixes the issues with the text wrap example seen in #18266

## Solution

Change the sort key to just use the stack index alone.
This commit is contained in:
ickshonpe 2025-03-12 17:11:02 +00:00 committed by GitHub
parent ec822c8c3b
commit 26ea38e4a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 17 deletions

View File

@ -365,10 +365,8 @@ pub fn queue_shadows(
draw_function, draw_function,
pipeline, pipeline,
entity: (entity, extracted_shadow.main_entity), entity: (entity, extracted_shadow.main_entity),
sort_key: ( sort_key: FloatOrd(extracted_shadow.stack_index as f32 + stack_z_offsets::BOX_SHADOW),
FloatOrd(extracted_shadow.stack_index as f32 + stack_z_offsets::BOX_SHADOW),
entity.index(),
),
batch_range: 0..0, batch_range: 0..0,
extra_index: PhaseItemExtraIndex::None, extra_index: PhaseItemExtraIndex::None,
index, index,

View File

@ -981,10 +981,7 @@ pub fn queue_uinodes(
draw_function, draw_function,
pipeline, pipeline,
entity: (entity, extracted_uinode.main_entity), entity: (entity, extracted_uinode.main_entity),
sort_key: ( sort_key: FloatOrd(extracted_uinode.stack_index as f32 + stack_z_offsets::NODE),
FloatOrd(extracted_uinode.stack_index as f32 + stack_z_offsets::NODE),
entity.index(),
),
index, index,
// batch_range will be calculated in prepare_uinodes // batch_range will be calculated in prepare_uinodes
batch_range: 0..0, batch_range: 0..0,

View File

@ -106,7 +106,7 @@ impl Node for UiPassNode {
} }
pub struct TransparentUi { pub struct TransparentUi {
pub sort_key: (FloatOrd, u32), pub sort_key: FloatOrd,
pub entity: (Entity, MainEntity), pub entity: (Entity, MainEntity),
pub pipeline: CachedRenderPipelineId, pub pipeline: CachedRenderPipelineId,
pub draw_function: DrawFunctionId, pub draw_function: DrawFunctionId,
@ -153,7 +153,7 @@ impl PhaseItem for TransparentUi {
} }
impl SortedPhaseItem for TransparentUi { impl SortedPhaseItem for TransparentUi {
type SortKey = (FloatOrd, u32); type SortKey = FloatOrd;
#[inline] #[inline]
fn sort_key(&self) -> Self::SortKey { fn sort_key(&self) -> Self::SortKey {

View File

@ -665,10 +665,7 @@ pub fn queue_ui_material_nodes<M: UiMaterial>(
draw_function, draw_function,
pipeline, pipeline,
entity: (extracted_uinode.render_entity, extracted_uinode.main_entity), entity: (extracted_uinode.render_entity, extracted_uinode.main_entity),
sort_key: ( sort_key: FloatOrd(extracted_uinode.stack_index as f32 + stack_z_offsets::MATERIAL),
FloatOrd(extracted_uinode.stack_index as f32 + stack_z_offsets::MATERIAL),
extracted_uinode.render_entity.index(),
),
batch_range: 0..0, batch_range: 0..0,
extra_index: PhaseItemExtraIndex::None, extra_index: PhaseItemExtraIndex::None,
index, index,

View File

@ -372,9 +372,8 @@ pub fn queue_ui_slices(
draw_function, draw_function,
pipeline, pipeline,
entity: (extracted_slicer.render_entity, extracted_slicer.main_entity), entity: (extracted_slicer.render_entity, extracted_slicer.main_entity),
sort_key: ( sort_key: FloatOrd(
FloatOrd(extracted_slicer.stack_index as f32 + stack_z_offsets::TEXTURE_SLICE), extracted_slicer.stack_index as f32 + stack_z_offsets::TEXTURE_SLICE,
extracted_slicer.render_entity.index(),
), ),
batch_range: 0..0, batch_range: 0..0,
extra_index: PhaseItemExtraIndex::None, extra_index: PhaseItemExtraIndex::None,