mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-21 23:18:24 +02:00
kraid: Add an SSAValue::bytes() helper
This is just bits() divided by 8 but it's a bit more efficient and we want bytes often enough that we might as well have the helper. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42344>
This commit is contained in:
parent
8bc99ecb19
commit
f4be78358c
1 changed files with 7 additions and 1 deletions
|
|
@ -37,6 +37,11 @@ impl SSAValue {
|
|||
pub fn bits(&self) -> u8 {
|
||||
8 << (self.packed.get() >> 30)
|
||||
}
|
||||
|
||||
/// Returns the number of bytes in this SSA value
|
||||
pub fn bytes(&self) -> u8 {
|
||||
1 << (self.packed.get() >> 30)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoBitIndex for SSAValue {
|
||||
|
|
@ -109,7 +114,7 @@ impl SSARef {
|
|||
|
||||
pub fn bytes(&self) -> u8 {
|
||||
if self.comps() == 1 {
|
||||
self[0].bits() / 8
|
||||
self[0].bytes()
|
||||
} else {
|
||||
for ssa in self {
|
||||
debug_assert_eq!(ssa.bits(), 32);
|
||||
|
|
@ -300,6 +305,7 @@ mod tests {
|
|||
let ssa = SSAValue::new(42, bits);
|
||||
assert_eq!(ssa.idx(), 42);
|
||||
assert_eq!(ssa.bits(), bits);
|
||||
assert_eq!(ssa.bytes(), bits / 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue