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.
This commit is contained in:
Brezak 2024-03-23 02:58:47 +01:00 committed by GitHub
parent 0b5f7b4ff2
commit d80f05cd73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -122,10 +122,9 @@ bitflags::bitflags! {
// MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA.
pub struct SpritePipelineKey: u32 {
const NONE = 0;
const COLORED = 1 << 0;
const HDR = 1 << 1;
const TONEMAP_IN_SHADER = 1 << 2;
const DEBAND_DITHER = 1 << 3;
const HDR = 1 << 0;
const TONEMAP_IN_SHADER = 1 << 1;
const DEBAND_DITHER = 1 << 2;
const MSAA_RESERVED_BITS = Self::MSAA_MASK_BITS << Self::MSAA_SHIFT_BITS;
const TONEMAP_METHOD_RESERVED_BITS = Self::TONEMAP_METHOD_MASK_BITS << Self::TONEMAP_METHOD_SHIFT_BITS;
const TONEMAP_METHOD_NONE = 0 << Self::TONEMAP_METHOD_SHIFT_BITS;
@ -158,15 +157,6 @@ impl SpritePipelineKey {
1 << ((self.bits() >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS)
}
#[inline]
pub const fn from_colored(colored: bool) -> Self {
if colored {
SpritePipelineKey::COLORED
} else {
SpritePipelineKey::NONE
}
}
#[inline]
pub const fn from_hdr(hdr: bool) -> Self {
if hdr {
@ -495,16 +485,7 @@ pub fn queue_sprites(
}
}
let pipeline = pipelines.specialize(
&pipeline_cache,
&sprite_pipeline,
view_key | SpritePipelineKey::from_colored(false),
);
let colored_pipeline = pipelines.specialize(
&pipeline_cache,
&sprite_pipeline,
view_key | SpritePipelineKey::from_colored(true),
);
let pipeline = pipelines.specialize(&pipeline_cache, &sprite_pipeline, view_key);
view_entities.clear();
view_entities.extend(visible_entities.entities.iter().map(|e| e.index() as usize));
@ -524,27 +505,15 @@ pub fn queue_sprites(
let sort_key = FloatOrd(extracted_sprite.transform.translation().z);
// Add the item to the render phase
if extracted_sprite.color != LinearRgba::WHITE {
transparent_phase.add(Transparent2d {
draw_function: draw_sprite_function,
pipeline: colored_pipeline,
entity: *entity,
sort_key,
// batch_range and dynamic_offset will be calculated in prepare_sprites
batch_range: 0..0,
dynamic_offset: None,
});
} else {
transparent_phase.add(Transparent2d {
draw_function: draw_sprite_function,
pipeline,
entity: *entity,
sort_key,
// batch_range and dynamic_offset will be calculated in prepare_sprites
batch_range: 0..0,
dynamic_offset: None,
});
}
transparent_phase.add(Transparent2d {
draw_function: draw_sprite_function,
pipeline,
entity: *entity,
sort_key,
// batch_range and dynamic_offset will be calculated in prepare_sprites
batch_range: 0..0,
dynamic_offset: None,
});
}
}
}