Skip to content

Commit 66e02ff

Browse files
author
bors-servo
authored
Auto merge of #1782 - kvark:rt-size, r=glennw
Temporary revert of #1758 (Initialize render targets to the required size) This reverts commit 3a5b792 due to Gecko failures in #1758 (comment) r? @glennw <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1782) <!-- Reviewable:end -->
2 parents ba51d8d + be1095a commit 66e02ff

File tree

5 files changed

+31
-42
lines changed

5 files changed

+31
-42
lines changed

webrender/src/renderer.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,12 +3040,12 @@ impl Renderer {
30403040
let alpha_target_count = pass.required_target_count(RenderTargetKind::Alpha);
30413041

30423042
if let Some(texture) = pass.color_texture.as_mut() {
3043-
debug_assert!(pass.max_used_color_target_size.width > 0);
3044-
debug_assert!(pass.max_used_color_target_size.height > 0);
3043+
debug_assert!(pass.max_color_target_size.width > 0);
3044+
debug_assert!(pass.max_color_target_size.height > 0);
30453045
self.device.init_texture(
30463046
texture,
3047-
pass.max_used_color_target_size.width,
3048-
pass.max_used_color_target_size.height,
3047+
pass.max_color_target_size.width,
3048+
pass.max_color_target_size.height,
30493049
ImageFormat::BGRA8,
30503050
TextureFilter::Linear,
30513051
RenderTargetMode::RenderTarget,
@@ -3054,12 +3054,12 @@ impl Renderer {
30543054
);
30553055
}
30563056
if let Some(texture) = pass.alpha_texture.as_mut() {
3057-
debug_assert!(pass.max_used_alpha_target_size.width > 0);
3058-
debug_assert!(pass.max_used_alpha_target_size.height > 0);
3057+
debug_assert!(pass.max_alpha_target_size.width > 0);
3058+
debug_assert!(pass.max_alpha_target_size.height > 0);
30593059
self.device.init_texture(
30603060
texture,
3061-
pass.max_used_alpha_target_size.width,
3062-
pass.max_used_alpha_target_size.height,
3061+
pass.max_alpha_target_size.width,
3062+
pass.max_alpha_target_size.height,
30633063
ImageFormat::A8,
30643064
TextureFilter::Nearest,
30653065
RenderTargetMode::RenderTarget,
@@ -3125,17 +3125,17 @@ impl Renderer {
31253125
for (target_index, target) in pass.alpha_targets.targets.iter().enumerate() {
31263126
let projection = Transform3D::ortho(
31273127
0.0,
3128-
pass.max_used_alpha_target_size.width as f32,
3128+
pass.max_alpha_target_size.width as f32,
31293129
0.0,
3130-
pass.max_used_alpha_target_size.height as f32,
3130+
pass.max_alpha_target_size.height as f32,
31313131
ORTHO_NEAR_PLANE,
31323132
ORTHO_FAR_PLANE,
31333133
);
31343134

31353135
self.draw_alpha_target(
31363136
(pass.alpha_texture.as_ref().unwrap(), target_index as i32),
31373137
target,
3138-
pass.max_used_alpha_target_size,
3138+
pass.max_alpha_target_size,
31393139
&projection,
31403140
);
31413141
}
@@ -3165,7 +3165,7 @@ impl Renderer {
31653165
ORTHO_FAR_PLANE,
31663166
)
31673167
} else {
3168-
size = pass.max_used_color_target_size;
3168+
size = pass.max_color_target_size;
31693169
clear_color = Some([0.0, 0.0, 0.0, 0.0]);
31703170
projection = Transform3D::ortho(
31713171
0.0,

webrender/src/tiling.rs

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -977,18 +977,10 @@ impl<T: RenderTarget> RenderTargetList<T> {
977977
gpu_cache: &mut GpuCache,
978978
render_tasks: &mut RenderTaskTree,
979979
deferred_resolves: &mut Vec<DeferredResolve>,
980-
) -> DeviceUintSize {
981-
let mut max_used_size = DeviceUintSize::zero();
982-
980+
) {
983981
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-
988982
target.build(ctx, gpu_cache, render_tasks, deferred_resolves);
989983
}
990-
991-
max_used_size
992984
}
993985

994986
fn add_task(
@@ -1084,7 +1076,8 @@ impl RenderTarget for ColorRenderTarget {
10841076
fn used_rect(&self) -> DeviceIntRect {
10851077
self.allocator
10861078
.as_ref()
1087-
.map_or(DeviceIntRect::zero(), |allocator| allocator.used_rect)
1079+
.expect("bug: used_rect called on framebuffer")
1080+
.used_rect
10881081
}
10891082

10901083
fn build(
@@ -1309,10 +1302,8 @@ pub struct RenderPass {
13091302
pub color_texture: Option<Texture>,
13101303
pub alpha_texture: Option<Texture>,
13111304
dynamic_tasks: FastHashMap<RenderTaskKey, DynamicTaskInfo>,
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,
1305+
pub max_color_target_size: DeviceUintSize,
1306+
pub max_alpha_target_size: DeviceUintSize,
13161307
}
13171308

13181309
impl RenderPass {
@@ -1325,10 +1316,8 @@ impl RenderPass {
13251316
color_texture: None,
13261317
alpha_texture: None,
13271318
dynamic_tasks: FastHashMap::default(),
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(),
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),
13321321
}
13331322
}
13341323

@@ -1340,16 +1329,16 @@ impl RenderPass {
13401329
) {
13411330
match target_kind {
13421331
RenderTargetKind::Color => {
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);
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);
13471336
}
13481337
RenderTargetKind::Alpha => {
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);
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);
13531342
}
13541343
}
13551344

@@ -1407,9 +1396,9 @@ impl RenderPass {
14071396
let alloc_size = DeviceUintSize::new(size.width as u32, size.height as u32);
14081397
let (alloc_origin, target_index) = match target_kind {
14091398
RenderTargetKind::Color => self.color_targets
1410-
.allocate(alloc_size, self.color_allocator_size),
1399+
.allocate(alloc_size, self.max_color_target_size),
14111400
RenderTargetKind::Alpha => self.alpha_targets
1412-
.allocate(alloc_size, self.alpha_allocator_size),
1401+
.allocate(alloc_size, self.max_alpha_target_size),
14131402
};
14141403

14151404
let origin = Some((
@@ -1457,9 +1446,9 @@ impl RenderPass {
14571446
}
14581447
}
14591448

1460-
self.max_used_color_target_size = self.color_targets
1449+
self.color_targets
14611450
.build(ctx, gpu_cache, render_tasks, deferred_resolves);
1462-
self.max_used_alpha_target_size =self.alpha_targets
1451+
self.alpha_targets
14631452
.build(ctx, gpu_cache, render_tasks, deferred_resolves);
14641453
}
14651454
}
3 Bytes
Loading
Loading
0 Bytes
Loading

0 commit comments

Comments
 (0)