From f64d2c8557eeef61a2fdddba40b16367f05ded94 Mon Sep 17 00:00:00 2001 From: Mel Henning Date: Wed, 10 Dec 2025 15:30:52 -0500 Subject: [PATCH] nak: Factor out prev_multiple_of Reviewed-by: Mary Guillemard Part-of: --- src/nouveau/compiler/nak/ir.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index f97e34a5e44..1d136038dd1 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -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 /// on the number of GPRs per thread 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]; // Warps are allocated in multiples of 4 // 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 { - fn prev_multiple_of(x: u32, y: u32) -> u32 { - (x / y) * y - } - // TODO: Take local_size and shared mem limit into account for compute let total_regs: u32 = 65536; // GPRs are allocated in multiples of 8