xref: /aosp_15_r20/external/mesa3d/src/nouveau/nil/lib.rs (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 // Copyright © 2024 Collabora, Ltd.
2 // SPDX-License-Identifier: MIT
3 
4 extern crate nil_rs_bindings;
5 extern crate nvidia_headers;
6 
7 mod extent;
8 mod format;
9 mod image;
10 mod modifiers;
11 mod tic;
12 mod tiling;
13 
14 pub trait ILog2Ceil {
ilog2_ceil(self) -> Self15     fn ilog2_ceil(self) -> Self;
16 }
17 
18 impl ILog2Ceil for u32 {
ilog2_ceil(self) -> Self19     fn ilog2_ceil(self) -> Self {
20         if self <= 1 {
21             0
22         } else {
23             (self - 1).ilog2() + 1
24         }
25     }
26 }
27 
28 pub trait Minify<Rhs> {
29     // Required method
minify(self, rhs: Rhs) -> Self30     fn minify(self, rhs: Rhs) -> Self;
31 }
32 
33 impl Minify<u32> for u32 {
minify(self, level: u32) -> u3234     fn minify(self, level: u32) -> u32 {
35         std::cmp::max(1, self >> level)
36     }
37 }
38