@@ -977,10 +977,18 @@ impl<T: RenderTarget> RenderTargetList<T> {
977
977
gpu_cache : & mut GpuCache ,
978
978
render_tasks : & mut RenderTaskTree ,
979
979
deferred_resolves : & mut Vec < DeferredResolve > ,
980
- ) {
980
+ ) -> DeviceUintSize {
981
+ let mut max_used_size = DeviceUintSize :: zero ( ) ;
982
+
981
983
for target in & mut self . targets {
984
+ let used_rect = target. used_rect ( ) ;
985
+ max_used_size. width = cmp:: max ( max_used_size. width , used_rect. size . width as u32 ) ;
986
+ max_used_size. height = cmp:: max ( max_used_size. height , used_rect. size . height as u32 ) ;
987
+
982
988
target. build ( ctx, gpu_cache, render_tasks, deferred_resolves) ;
983
989
}
990
+
991
+ max_used_size
984
992
}
985
993
986
994
fn add_task (
@@ -1076,8 +1084,7 @@ impl RenderTarget for ColorRenderTarget {
1076
1084
fn used_rect ( & self ) -> DeviceIntRect {
1077
1085
self . allocator
1078
1086
. as_ref ( )
1079
- . expect ( "bug: used_rect called on framebuffer" )
1080
- . used_rect
1087
+ . map_or ( DeviceIntRect :: zero ( ) , |allocator| allocator. used_rect )
1081
1088
}
1082
1089
1083
1090
fn build (
@@ -1302,8 +1309,10 @@ pub struct RenderPass {
1302
1309
pub color_texture : Option < Texture > ,
1303
1310
pub alpha_texture : Option < Texture > ,
1304
1311
dynamic_tasks : FastHashMap < RenderTaskKey , DynamicTaskInfo > ,
1305
- pub max_color_target_size : DeviceUintSize ,
1306
- pub max_alpha_target_size : DeviceUintSize ,
1312
+ pub color_allocator_size : DeviceUintSize ,
1313
+ pub alpha_allocator_size : DeviceUintSize ,
1314
+ pub max_used_color_target_size : DeviceUintSize ,
1315
+ pub max_used_alpha_target_size : DeviceUintSize ,
1307
1316
}
1308
1317
1309
1318
impl RenderPass {
@@ -1316,8 +1325,10 @@ impl RenderPass {
1316
1325
color_texture : None ,
1317
1326
alpha_texture : None ,
1318
1327
dynamic_tasks : FastHashMap :: default ( ) ,
1319
- max_color_target_size : DeviceUintSize :: new ( MIN_TARGET_SIZE , MIN_TARGET_SIZE ) ,
1320
- max_alpha_target_size : DeviceUintSize :: new ( MIN_TARGET_SIZE , MIN_TARGET_SIZE ) ,
1328
+ color_allocator_size : DeviceUintSize :: new ( MIN_TARGET_SIZE , MIN_TARGET_SIZE ) ,
1329
+ alpha_allocator_size : DeviceUintSize :: new ( MIN_TARGET_SIZE , MIN_TARGET_SIZE ) ,
1330
+ max_used_color_target_size : DeviceUintSize :: zero ( ) ,
1331
+ max_used_alpha_target_size : DeviceUintSize :: zero ( ) ,
1321
1332
}
1322
1333
}
1323
1334
@@ -1329,16 +1340,16 @@ impl RenderPass {
1329
1340
) {
1330
1341
match target_kind {
1331
1342
RenderTargetKind :: Color => {
1332
- self . max_color_target_size . width =
1333
- cmp:: max ( self . max_color_target_size . width , size. width as u32 ) ;
1334
- self . max_color_target_size . height =
1335
- cmp:: max ( self . max_color_target_size . height , size. height as u32 ) ;
1343
+ self . color_allocator_size . width =
1344
+ cmp:: max ( self . color_allocator_size . width , size. width as u32 ) ;
1345
+ self . color_allocator_size . height =
1346
+ cmp:: max ( self . color_allocator_size . height , size. height as u32 ) ;
1336
1347
}
1337
1348
RenderTargetKind :: Alpha => {
1338
- self . max_alpha_target_size . width =
1339
- cmp:: max ( self . max_alpha_target_size . width , size. width as u32 ) ;
1340
- self . max_alpha_target_size . height =
1341
- cmp:: max ( self . max_alpha_target_size . height , size. height as u32 ) ;
1349
+ self . alpha_allocator_size . width =
1350
+ cmp:: max ( self . alpha_allocator_size . width , size. width as u32 ) ;
1351
+ self . alpha_allocator_size . height =
1352
+ cmp:: max ( self . alpha_allocator_size . height , size. height as u32 ) ;
1342
1353
}
1343
1354
}
1344
1355
@@ -1396,9 +1407,9 @@ impl RenderPass {
1396
1407
let alloc_size = DeviceUintSize :: new ( size. width as u32 , size. height as u32 ) ;
1397
1408
let ( alloc_origin, target_index) = match target_kind {
1398
1409
RenderTargetKind :: Color => self . color_targets
1399
- . allocate ( alloc_size, self . max_color_target_size ) ,
1410
+ . allocate ( alloc_size, self . color_allocator_size ) ,
1400
1411
RenderTargetKind :: Alpha => self . alpha_targets
1401
- . allocate ( alloc_size, self . max_alpha_target_size ) ,
1412
+ . allocate ( alloc_size, self . alpha_allocator_size ) ,
1402
1413
} ;
1403
1414
1404
1415
let origin = Some ( (
@@ -1446,9 +1457,9 @@ impl RenderPass {
1446
1457
}
1447
1458
}
1448
1459
1449
- self . color_targets
1460
+ self . max_used_color_target_size = self . color_targets
1450
1461
. build ( ctx, gpu_cache, render_tasks, deferred_resolves) ;
1451
- self . alpha_targets
1462
+ self . max_used_alpha_target_size = self . alpha_targets
1452
1463
. build ( ctx, gpu_cache, render_tasks, deferred_resolves) ;
1453
1464
}
1454
1465
}
0 commit comments