Skip to content

Commit

Permalink
Auto merge of #3374 - kvark:rt-alloc, r=gw3583
Browse files Browse the repository at this point in the history
Extend the scope of render target allocation strategy acrosss layers

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1509672

Technically consists of 3 parts:
  - cleanup bits, don't affect performance
  - spread the dynamic target allocation bins across the layers. Previously, we had each layer with it's own allocator, and we were only ever trying to allocate from the last one. This scheme was weak against cases where we reach the ideal maximum target size, since guillotine allocation of small bits forced us to spawn more and more layers... reaching almost 150 in the target case. New scheme uses the layers more efficiently, reducing the layers to just 3 (.. 50x reduction :P). Pending [try push](https://treeherder.mozilla.org/#/jobs?repo=try&revision=27464c7d62f0f05a0bc96a7133b55e9706d3d449).
  - when we reach the ideal max size, also round up the requested size to 256. This makes allocations *within a layer* to be more robust against small inputs. With this change, the number of layers drops to just 2 (.. 75x reduction lol), which appears to be minimal for this case. Pending [try push](https://treeherder.mozilla.org/#/jobs?repo=try&revision=1f4593fd68455842a7b12f396d0abbdf887a11a0).

The page scrolls smoothly with those changes, on my GTX TI 1050 at least.

r? @gw3583

Note: the bugzilla issue also suffers from poor batching, I'm going to look at it separately.

<!-- 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/3374)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Nov 30, 2018
2 parents 5b26863 + 3362a5e commit dbaa109
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 296 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ environment:
TARGET: x86_64-pc-windows-msvc

install:
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-1.27.0-${env:TARGET}.msi"
- msiexec /passive /i "rust-1.27.0-%TARGET%.msi" ADDLOCAL=Rustc,Cargo,Std INSTALLDIR=C:\Rust
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-1.30.0-${env:TARGET}.msi"
- msiexec /passive /i "rust-1.30.0-%TARGET%.msi" ADDLOCAL=Rustc,Cargo,Std INSTALLDIR=C:\Rust
- rustc -V
- cargo -V

Expand Down
1 change: 1 addition & 0 deletions webrender/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ optional = true

[dev-dependencies]
mozangle = "0.1"
rand = "0.4"

[target.'cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))'.dependencies]
freetype = { version = "0.4", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion webrender/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ impl AlphaBatchList {
) -> &mut Vec<PrimitiveInstanceData> {
if z_id != self.current_z_id ||
self.current_batch_index == usize::MAX ||
!self.batches[self.current_batch_index].key.is_compatible_with(&key) {
!self.batches[self.current_batch_index].key.is_compatible_with(&key)
{
let mut selected_batch_index = None;

match key.blend_mode {
Expand Down
2 changes: 2 additions & 0 deletions webrender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ extern crate image as image_loader;
extern crate base64;
#[cfg(all(feature = "capture", feature = "png"))]
extern crate png;
#[cfg(test)]
extern crate rand;

pub extern crate webrender_api;

Expand Down
8 changes: 6 additions & 2 deletions webrender/src/render_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ impl RenderTaskTree {
pass_index
};

let pass = &mut passes[pass_index];
pass.add_render_task(id, task.get_dynamic_size(), task.target_kind(), &task.location);
passes[pass_index].add_render_task(
id,
task.get_dynamic_size(),
task.target_kind(),
&task.location,
);
}

pub fn prepare_for_render(&mut self) {
Expand Down
Loading

0 comments on commit dbaa109

Please sign in to comment.