@@ -855,7 +855,7 @@ pub struct LightTilingDescriptor {
855855 /// Size of the [`Stage`]'s depth texture.
856856 pub depth_texture_size : UVec2 ,
857857 /// Configurable tile size.
858- pub tile_size : UVec2 ,
858+ pub tile_size : u32 ,
859859 /// Array pointing to the lighting "tiles".
860860 pub tiles_array : Array < LightTile > ,
861861 /// Minimum illuminance.
@@ -868,7 +868,7 @@ impl Default for LightTilingDescriptor {
868868 fn default ( ) -> Self {
869869 Self {
870870 depth_texture_size : Default :: default ( ) ,
871- tile_size : UVec2 :: splat ( 16 ) ,
871+ tile_size : 16 ,
872872 tiles_array : Default :: default ( ) ,
873873 minimum_illuminance_lux : 0.1 ,
874874 }
@@ -878,7 +878,7 @@ impl Default for LightTilingDescriptor {
878878impl LightTilingDescriptor {
879879 /// Returns the dimensions of the grid of tiles.
880880 pub fn tile_grid_size ( & self ) -> UVec2 {
881- let dims_f32 = self . depth_texture_size . as_vec2 ( ) / self . tile_size . as_vec2 ( ) ;
881+ let dims_f32 = self . depth_texture_size . as_vec2 ( ) / self . tile_size as f32 ;
882882 dims_f32. ceil ( ) . as_uvec2 ( )
883883 }
884884
@@ -908,7 +908,7 @@ pub fn dequantize_depth_u32_to_f32(depth: u32) -> f32 {
908908/// invocation of the light list computation.
909909struct NextLightIndex {
910910 current_step : usize ,
911- tile_size : UVec2 ,
911+ tile_size : u32 ,
912912 lights : Array < Id < Light > > ,
913913 global_id : UVec3 ,
914914}
@@ -930,7 +930,7 @@ impl Iterator for NextLightIndex {
930930impl NextLightIndex {
931931 pub fn new (
932932 global_id : UVec3 ,
933- tile_size : UVec2 ,
933+ tile_size : u32 ,
934934 analytical_lights_array : Array < Id < Light > > ,
935935 ) -> Self {
936936 Self {
@@ -945,8 +945,8 @@ impl NextLightIndex {
945945 // Determine the xy coord of this invocation within the _tile_
946946 let frag_tile_xy = self . global_id . xy ( ) % self . tile_size ;
947947 // Determine the index of this invocation within the _tile_
948- let offset = frag_tile_xy. y * self . tile_size . x + frag_tile_xy. x ;
949- let stride = ( self . tile_size . x * self . tile_size . y ) as usize ;
948+ let offset = frag_tile_xy. y * self . tile_size + frag_tile_xy. x ;
949+ let stride = ( self . tile_size * self . tile_size ) as usize ;
950950 self . current_step * stride + offset as usize
951951 }
952952}
@@ -1335,34 +1335,28 @@ mod test {
13351335 let lights_array = Array :: new ( 0 , 1 ) ;
13361336 // When there's only one light we only need one invocation to check that one light
13371337 // (per tile)
1338- let mut next_light =
1339- NextLightIndex :: new ( UVec3 :: new ( 0 , 0 , 0 ) , UVec2 :: splat ( 16 ) , lights_array) ;
1338+ let mut next_light = NextLightIndex :: new ( UVec3 :: new ( 0 , 0 , 0 ) , 16 , lights_array) ;
13401339 assert_eq ! ( Some ( 0u32 . into( ) ) , next_light. next( ) ) ;
13411340 assert_eq ! ( None , next_light. next( ) ) ;
13421341 // The next invocation won't check anything
1343- let mut next_light =
1344- NextLightIndex :: new ( UVec3 :: new ( 1 , 0 , 0 ) , UVec2 :: splat ( 16 ) , lights_array) ;
1342+ let mut next_light = NextLightIndex :: new ( UVec3 :: new ( 1 , 0 , 0 ) , 16 , lights_array) ;
13451343 assert_eq ! ( None , next_light. next( ) ) ;
13461344 // Neither will the next row
1347- let mut next_light =
1348- NextLightIndex :: new ( UVec3 :: new ( 0 , 1 , 0 ) , UVec2 :: splat ( 16 ) , lights_array) ;
1345+ let mut next_light = NextLightIndex :: new ( UVec3 :: new ( 0 , 1 , 0 ) , 16 , lights_array) ;
13491346 assert_eq ! ( None , next_light. next( ) ) ;
13501347 }
13511348 {
13521349 let lights_array = Array :: new ( 0 , 2 ) ;
13531350 // When there's two lights we need two invocations
1354- let mut next_light =
1355- NextLightIndex :: new ( UVec3 :: new ( 0 , 0 , 0 ) , UVec2 :: splat ( 16 ) , lights_array) ;
1351+ let mut next_light = NextLightIndex :: new ( UVec3 :: new ( 0 , 0 , 0 ) , 16 , lights_array) ;
13561352 assert_eq ! ( Some ( 0u32 . into( ) ) , next_light. next( ) ) ;
13571353 assert_eq ! ( None , next_light. next( ) ) ;
13581354 // The next invocation checks the second light
1359- let mut next_light =
1360- NextLightIndex :: new ( UVec3 :: new ( 1 , 0 , 0 ) , UVec2 :: splat ( 16 ) , lights_array) ;
1355+ let mut next_light = NextLightIndex :: new ( UVec3 :: new ( 1 , 0 , 0 ) , 16 , lights_array) ;
13611356 assert_eq ! ( Some ( 1u32 . into( ) ) , next_light. next( ) ) ;
13621357 assert_eq ! ( None , next_light. next( ) ) ;
13631358 // The next one doesn't check anything
1364- let mut next_light =
1365- NextLightIndex :: new ( UVec3 :: new ( 2 , 0 , 0 ) , UVec2 :: splat ( 16 ) , lights_array) ;
1359+ let mut next_light = NextLightIndex :: new ( UVec3 :: new ( 2 , 0 , 0 ) , 16 , lights_array) ;
13661360 assert_eq ! ( None , next_light. next( ) ) ;
13671361 }
13681362 {
@@ -1371,8 +1365,7 @@ mod test {
13711365 let mut checked_lights = vec ! [ ] ;
13721366 for y in 0 ..16 {
13731367 for x in 0 ..16 {
1374- let mut next_light =
1375- NextLightIndex :: new ( UVec3 :: new ( x, y, 0 ) , UVec2 :: splat ( 16 ) , lights_array) ;
1368+ let mut next_light = NextLightIndex :: new ( UVec3 :: new ( x, y, 0 ) , 16 , lights_array) ;
13761369 let next_index = next_light. next_index ( ) ;
13771370 let checked_light = next_light. next ( ) . unwrap ( ) ;
13781371 assert_eq ! ( next_index, checked_light. index( ) ) ;
0 commit comments