pub struct FormatCostEntry {
pub key: Option<FormatCostKey>,
pub cost: Option<f32>,
/* private fields */
}
Expand description
A FormatCostEntry can be used to influence which PixelFormatAndModifier is chosen for a buffer collection, optionally taking BufferUsage into account.
The default cost is f32::MAX, so any specified cost with a non-MAX value will prefer the specified format over any formats that don’t have any FormatCost entry.
Entries which have the same pixel_format, pixel_format_modifier, and required_usage_bits as a previous entry will override that previous entry. For matching purposes, an absent pixel_format_modifier matches LINEAR, and an absent required_buffer_usage_bits matches all-0 usage bits.
Board info sysmem_defaults entries are logically before platform sysmem entries.
Sysmem uses the resulting aggregated list of FormatCostEntry(s) when breaking ties among the set of formats which are supported by all participants of a buffer collection. For each mutually-supported format, entries with non-matching format are ignored, and entries with extra buffer_usage_bits set are ignored. Among the remaining entries, the entry with the most usage bits in common with the aggregated participant usages is selected to determine the cost (if a tie, the later entry wins). Then the format with the lowest cost is chosen. If it’s still a tie (equal cost), the tie is broken arbitrarily but not randomly.
This is not intended as a mechanism to disallow selection of a format that is supported by all participants of a buffer collection. If a participant claims support for a format but fails to handle that format correctly, it should be fixed to handle that format correctly or changed to stop claiming support for that format.
This mechanism is intended to influence format selection toward more efficient formats with better performance, lower memory bandwidth usage, etc, for a given set of usage bits, taking into account quirks that may be unique to a given board or overall platform config.
Fields§
§key: Option<FormatCostKey>
Must be set. If two entries have logically equal key (after field defaults are applied), the later entry will override the earlier entry.
cost: Option<f32>
Must be set. Lower costs win, but see also FormatCostKey fields re. filtering entries by format and usage bits first.
When two entries (each with format supported by all the participants of a buffer collection) have different costs, the lower cost entry (and its format) is chosen.
For non-test scenarios, only use cost values > 0.0 (typically at least 1.0 as of this comment), with 0.0 and negative values reserved for testing.
Trait Implementations§
Source§impl Clone for FormatCostEntry
impl Clone for FormatCostEntry
Source§fn clone(&self) -> FormatCostEntry
fn clone(&self) -> FormatCostEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for FormatCostEntry
impl Debug for FormatCostEntry
Source§impl<D: ResourceDialect> Decode<FormatCostEntry, D> for FormatCostEntry
impl<D: ResourceDialect> Decode<FormatCostEntry, D> for FormatCostEntry
Source§impl Default for FormatCostEntry
impl Default for FormatCostEntry
Source§fn default() -> FormatCostEntry
fn default() -> FormatCostEntry
Source§impl<D: ResourceDialect> Encode<FormatCostEntry, D> for &FormatCostEntry
impl<D: ResourceDialect> Encode<FormatCostEntry, D> for &FormatCostEntry
Source§impl PartialEq for FormatCostEntry
impl PartialEq for FormatCostEntry
Source§impl TypeMarker for FormatCostEntry
impl TypeMarker for FormatCostEntry
Source§type Owned = FormatCostEntry
type Owned = FormatCostEntry
Source§fn inline_align(_context: Context) -> usize
fn inline_align(_context: Context) -> usize
Source§fn inline_size(_context: Context) -> usize
fn inline_size(_context: Context) -> usize
inline_align
.§fn encode_is_copy() -> bool
fn encode_is_copy() -> bool
Self::Owned
matches the FIDL wire
format and encoding requires no validation. When true, we can optimize
encoding arrays and vectors of Self::Owned
to a single memcpy. Read more§fn decode_is_copy() -> bool
fn decode_is_copy() -> bool
Self::Owned
matches the FIDL wire
format and decoding requires no validation. When true, we can optimize
decoding arrays and vectors of Self::Owned
to a single memcpy.Source§impl ValueTypeMarker for FormatCostEntry
impl ValueTypeMarker for FormatCostEntry
Source§type Borrowed<'a> = &'a FormatCostEntry
type Borrowed<'a> = &'a FormatCostEntry
Encode<Self>
type cheaply obtainable from &Self::Owned
. There are three cases: Read moreimpl Persistable for FormatCostEntry
impl StructuralPartialEq for FormatCostEntry
Auto Trait Implementations§
impl Freeze for FormatCostEntry
impl RefUnwindSafe for FormatCostEntry
impl Send for FormatCostEntry
impl Sync for FormatCostEntry
impl Unpin for FormatCostEntry
impl UnwindSafe for FormatCostEntry
Blanket Implementations§
§impl<T> Body for Twhere
T: Persistable,
impl<T> Body for Twhere
T: Persistable,
§type MarkerAtTopLevel = T
type MarkerAtTopLevel = T
§type MarkerInResultUnion = T
type MarkerInResultUnion = T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)