Skip to content

Commit d80f05c

Browse files
authored
Remove needless color specializaion for SpritePipeline (#12559)
# Objective Remove color specialization from `SpritePipeline` after it became useless in #9597 ## Solution Removed the `COLORED` flag from the pipeline key and removed the specializing the pipeline over it. --- ## Changelog ### Removed - `SpritePipelineKey` no longer contains the `COLORED` flag. The flag has had no effect on how the pipeline operates for a while. ## Migration Guide - The raw values for the `HDR`, `TONEMAP_IN_SHADER` and `DEBAND_DITHER` flags have changed, so if you were constructing the pipeline key from raw `u32`s you'll have to account for that.
1 parent 0b5f7b4 commit d80f05c

File tree

1 file changed

+13
-44
lines changed
  • crates/bevy_sprite/src/render

1 file changed

+13
-44
lines changed

crates/bevy_sprite/src/render/mod.rs

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,9 @@ bitflags::bitflags! {
122122
// MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA.
123123
pub struct SpritePipelineKey: u32 {
124124
const NONE = 0;
125-
const COLORED = 1 << 0;
126-
const HDR = 1 << 1;
127-
const TONEMAP_IN_SHADER = 1 << 2;
128-
const DEBAND_DITHER = 1 << 3;
125+
const HDR = 1 << 0;
126+
const TONEMAP_IN_SHADER = 1 << 1;
127+
const DEBAND_DITHER = 1 << 2;
129128
const MSAA_RESERVED_BITS = Self::MSAA_MASK_BITS << Self::MSAA_SHIFT_BITS;
130129
const TONEMAP_METHOD_RESERVED_BITS = Self::TONEMAP_METHOD_MASK_BITS << Self::TONEMAP_METHOD_SHIFT_BITS;
131130
const TONEMAP_METHOD_NONE = 0 << Self::TONEMAP_METHOD_SHIFT_BITS;
@@ -158,15 +157,6 @@ impl SpritePipelineKey {
158157
1 << ((self.bits() >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS)
159158
}
160159

161-
#[inline]
162-
pub const fn from_colored(colored: bool) -> Self {
163-
if colored {
164-
SpritePipelineKey::COLORED
165-
} else {
166-
SpritePipelineKey::NONE
167-
}
168-
}
169-
170160
#[inline]
171161
pub const fn from_hdr(hdr: bool) -> Self {
172162
if hdr {
@@ -495,16 +485,7 @@ pub fn queue_sprites(
495485
}
496486
}
497487

498-
let pipeline = pipelines.specialize(
499-
&pipeline_cache,
500-
&sprite_pipeline,
501-
view_key | SpritePipelineKey::from_colored(false),
502-
);
503-
let colored_pipeline = pipelines.specialize(
504-
&pipeline_cache,
505-
&sprite_pipeline,
506-
view_key | SpritePipelineKey::from_colored(true),
507-
);
488+
let pipeline = pipelines.specialize(&pipeline_cache, &sprite_pipeline, view_key);
508489

509490
view_entities.clear();
510491
view_entities.extend(visible_entities.entities.iter().map(|e| e.index() as usize));
@@ -524,27 +505,15 @@ pub fn queue_sprites(
524505
let sort_key = FloatOrd(extracted_sprite.transform.translation().z);
525506

526507
// Add the item to the render phase
527-
if extracted_sprite.color != LinearRgba::WHITE {
528-
transparent_phase.add(Transparent2d {
529-
draw_function: draw_sprite_function,
530-
pipeline: colored_pipeline,
531-
entity: *entity,
532-
sort_key,
533-
// batch_range and dynamic_offset will be calculated in prepare_sprites
534-
batch_range: 0..0,
535-
dynamic_offset: None,
536-
});
537-
} else {
538-
transparent_phase.add(Transparent2d {
539-
draw_function: draw_sprite_function,
540-
pipeline,
541-
entity: *entity,
542-
sort_key,
543-
// batch_range and dynamic_offset will be calculated in prepare_sprites
544-
batch_range: 0..0,
545-
dynamic_offset: None,
546-
});
547-
}
508+
transparent_phase.add(Transparent2d {
509+
draw_function: draw_sprite_function,
510+
pipeline,
511+
entity: *entity,
512+
sort_key,
513+
// batch_range and dynamic_offset will be calculated in prepare_sprites
514+
batch_range: 0..0,
515+
dynamic_offset: None,
516+
});
548517
}
549518
}
550519
}

0 commit comments

Comments
 (0)