nak: Factor out prev_multiple_of

Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33306>
This commit is contained in:
Mel Henning 2025-12-10 15:30:52 -05:00 committed by Marge Bot
parent 645fff5dae
commit f64d2c8557

View file

@ -9412,13 +9412,13 @@ impl ShaderModel for ShaderModelInfo {
} }
} }
pub const fn prev_multiple_of(x: u32, y: u32) -> u32 {
(x / y) * y
}
/// For compute shaders, large values of local_size impose an additional limit /// For compute shaders, large values of local_size impose an additional limit
/// on the number of GPRs per thread /// on the number of GPRs per thread
pub fn gpr_limit_from_local_size(local_size: &[u16; 3]) -> u32 { pub fn gpr_limit_from_local_size(local_size: &[u16; 3]) -> u32 {
fn prev_multiple_of(x: u32, y: u32) -> u32 {
(x / y) * y
}
let local_size = local_size[0] * local_size[1] * local_size[2]; let local_size = local_size[0] * local_size[1] * local_size[2];
// Warps are allocated in multiples of 4 // Warps are allocated in multiples of 4
// Multiply that by 32 threads/warp // Multiply that by 32 threads/warp
@ -9432,10 +9432,6 @@ pub fn gpr_limit_from_local_size(local_size: &[u16; 3]) -> u32 {
} }
pub fn max_warps_per_sm(sm: &ShaderModelInfo, gprs: u32) -> u32 { pub fn max_warps_per_sm(sm: &ShaderModelInfo, gprs: u32) -> u32 {
fn prev_multiple_of(x: u32, y: u32) -> u32 {
(x / y) * y
}
// TODO: Take local_size and shared mem limit into account for compute // TODO: Take local_size and shared mem limit into account for compute
let total_regs: u32 = 65536; let total_regs: u32 = 65536;
// GPRs are allocated in multiples of 8 // GPRs are allocated in multiples of 8