@@ -855,7 +855,7 @@ pub struct LightTilingDescriptor {
855
855
/// Size of the [`Stage`]'s depth texture.
856
856
pub depth_texture_size : UVec2 ,
857
857
/// Configurable tile size.
858
- pub tile_size : UVec2 ,
858
+ pub tile_size : u32 ,
859
859
/// Array pointing to the lighting "tiles".
860
860
pub tiles_array : Array < LightTile > ,
861
861
/// Minimum illuminance.
@@ -868,7 +868,7 @@ impl Default for LightTilingDescriptor {
868
868
fn default ( ) -> Self {
869
869
Self {
870
870
depth_texture_size : Default :: default ( ) ,
871
- tile_size : UVec2 :: splat ( 16 ) ,
871
+ tile_size : 16 ,
872
872
tiles_array : Default :: default ( ) ,
873
873
minimum_illuminance_lux : 0.1 ,
874
874
}
@@ -878,7 +878,7 @@ impl Default for LightTilingDescriptor {
878
878
impl LightTilingDescriptor {
879
879
/// Returns the dimensions of the grid of tiles.
880
880
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 ;
882
882
dims_f32. ceil ( ) . as_uvec2 ( )
883
883
}
884
884
@@ -908,7 +908,7 @@ pub fn dequantize_depth_u32_to_f32(depth: u32) -> f32 {
908
908
/// invocation of the light list computation.
909
909
struct NextLightIndex {
910
910
current_step : usize ,
911
- tile_size : UVec2 ,
911
+ tile_size : u32 ,
912
912
lights : Array < Id < Light > > ,
913
913
global_id : UVec3 ,
914
914
}
@@ -930,7 +930,7 @@ impl Iterator for NextLightIndex {
930
930
impl NextLightIndex {
931
931
pub fn new (
932
932
global_id : UVec3 ,
933
- tile_size : UVec2 ,
933
+ tile_size : u32 ,
934
934
analytical_lights_array : Array < Id < Light > > ,
935
935
) -> Self {
936
936
Self {
@@ -945,8 +945,8 @@ impl NextLightIndex {
945
945
// Determine the xy coord of this invocation within the _tile_
946
946
let frag_tile_xy = self . global_id . xy ( ) % self . tile_size ;
947
947
// 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 ;
950
950
self . current_step * stride + offset as usize
951
951
}
952
952
}
@@ -1335,34 +1335,28 @@ mod test {
1335
1335
let lights_array = Array :: new ( 0 , 1 ) ;
1336
1336
// When there's only one light we only need one invocation to check that one light
1337
1337
// (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) ;
1340
1339
assert_eq ! ( Some ( 0u32 . into( ) ) , next_light. next( ) ) ;
1341
1340
assert_eq ! ( None , next_light. next( ) ) ;
1342
1341
// 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) ;
1345
1343
assert_eq ! ( None , next_light. next( ) ) ;
1346
1344
// 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) ;
1349
1346
assert_eq ! ( None , next_light. next( ) ) ;
1350
1347
}
1351
1348
{
1352
1349
let lights_array = Array :: new ( 0 , 2 ) ;
1353
1350
// 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) ;
1356
1352
assert_eq ! ( Some ( 0u32 . into( ) ) , next_light. next( ) ) ;
1357
1353
assert_eq ! ( None , next_light. next( ) ) ;
1358
1354
// 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) ;
1361
1356
assert_eq ! ( Some ( 1u32 . into( ) ) , next_light. next( ) ) ;
1362
1357
assert_eq ! ( None , next_light. next( ) ) ;
1363
1358
// 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) ;
1366
1360
assert_eq ! ( None , next_light. next( ) ) ;
1367
1361
}
1368
1362
{
@@ -1371,8 +1365,7 @@ mod test {
1371
1365
let mut checked_lights = vec ! [ ] ;
1372
1366
for y in 0 ..16 {
1373
1367
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) ;
1376
1369
let next_index = next_light. next_index ( ) ;
1377
1370
let checked_light = next_light. next ( ) . unwrap ( ) ;
1378
1371
assert_eq ! ( next_index, checked_light. index( ) ) ;
0 commit comments