11/// Returns the bitmask of slots covered by a `set_immediates(offset, size_bytes)` call.
2- pub ( crate ) fn slots_for_range ( offset : u32 , size_bytes : u32 ) -> u16 {
3- // u32 upcast to avoid overflow panic on n = 16
4- let bits_below = |n : u32 | ( ( 1u32 << n. min ( 16 ) ) - 1 ) as u16 ;
2+ pub ( crate ) fn slots_for_range ( offset : u32 , size_bytes : u32 ) -> u64 {
3+ // u128 upcast to avoid overflow panic on n = 64
4+ let bits_below = |n : u32 | ( ( 1u128 << n. min ( 64 ) ) - 1 ) as u64 ;
55 let lo = offset / 4 ;
66 let hi = ( offset + size_bytes) . div_ceil ( 4 ) ;
77 bits_below ( hi) - bits_below ( lo)
@@ -13,10 +13,10 @@ pub(crate) fn slots_for_range(offset: u32, size_bytes: u32) -> u16 {
1313/// For structs, gaps between members are padding and those slots need not be set.
1414/// For scalars, vectors, and matrices, all slots in the span are required
1515/// (the spec only defines padding exemptions at the struct-member level).
16- pub ( crate ) fn slots_for_type ( ty : & naga:: TypeInner , gctx : naga:: proc:: GlobalCtx ) -> u16 {
16+ pub ( crate ) fn slots_for_type ( ty : & naga:: TypeInner , gctx : naga:: proc:: GlobalCtx ) -> u64 {
1717 match * ty {
1818 naga:: TypeInner :: Struct { ref members, .. } => {
19- let mut mask: u16 = 0 ;
19+ let mut mask: u64 = 0 ;
2020 for member in members {
2121 let member_size = gctx. types [ member. ty ] . inner . size ( gctx) ;
2222 mask |= slots_for_range ( member. offset , member_size) ;
@@ -41,7 +41,7 @@ fn immediate_type(module: &naga::Module) -> Option<&naga::TypeInner> {
4141
4242/// Returns the required immediate slot bitmask for a naga module.
4343/// Zero if the module has no `var<immediate>`.
44- pub ( crate ) fn slots_for_module ( module : & naga:: Module ) -> u16 {
44+ pub ( crate ) fn slots_for_module ( module : & naga:: Module ) -> u64 {
4545 immediate_type ( module) . map_or ( 0 , |ty| slots_for_type ( ty, module. to_ctx ( ) ) )
4646}
4747
@@ -56,7 +56,7 @@ pub(crate) fn size_for_module(module: &naga::Module) -> u32 {
5656mod tests {
5757 use super :: slots_for_module;
5858
59- fn immediate_slots ( wgsl : & str ) -> u16 {
59+ fn immediate_slots ( wgsl : & str ) -> u64 {
6060 slots_for_module ( & naga:: front:: wgsl:: parse_str ( wgsl) . unwrap ( ) )
6161 }
6262
0 commit comments