зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1642629 - Preallocate the batches and batch rects vectors. r=gw
It would be wasteful to preallocate all batch builders because the majority of them have only a single batch, while typically only one will will have many batches. Thankfully we can acurately guess which pictures will produce many batches by checking whether they have more than one cluster. Differential Revision: https://phabricator.services.mozilla.com/D80469
This commit is contained in:
Родитель
0d9ad4dbe2
Коммит
ca942ccc84
|
@ -237,10 +237,10 @@ pub struct AlphaBatchList {
|
|||
}
|
||||
|
||||
impl AlphaBatchList {
|
||||
fn new(break_advanced_blend_batches: bool) -> Self {
|
||||
fn new(break_advanced_blend_batches: bool, preallocate: usize) -> Self {
|
||||
AlphaBatchList {
|
||||
batches: Vec::new(),
|
||||
batch_rects: Vec::new(),
|
||||
batches: Vec::with_capacity(preallocate),
|
||||
batch_rects: Vec::with_capacity(preallocate),
|
||||
current_z_id: ZBufferId::invalid(),
|
||||
current_batch_index: usize::MAX,
|
||||
break_advanced_blend_batches,
|
||||
|
@ -564,13 +564,14 @@ impl AlphaBatchBuilder {
|
|||
render_task_id: RenderTaskId,
|
||||
render_task_address: RenderTaskAddress,
|
||||
vis_mask: PrimitiveVisibilityMask,
|
||||
preallocate: usize,
|
||||
) -> Self {
|
||||
// The threshold for creating a new batch is
|
||||
// one quarter the screen size.
|
||||
let batch_area_threshold = (screen_size.width * screen_size.height) as f32 / 4.0;
|
||||
|
||||
AlphaBatchBuilder {
|
||||
alpha_batch_list: AlphaBatchList::new(break_advanced_blend_batches),
|
||||
alpha_batch_list: AlphaBatchList::new(break_advanced_blend_batches, preallocate),
|
||||
opaque_batch_list: OpaqueBatchList::new(batch_area_threshold, lookback_count),
|
||||
render_task_id,
|
||||
render_task_address,
|
||||
|
|
|
@ -933,6 +933,7 @@ pub fn build_render_pass(
|
|||
task_id,
|
||||
render_tasks.get_task_address(task_id),
|
||||
vis_mask,
|
||||
0,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -378,6 +378,18 @@ impl RenderTarget for ColorRenderTarget {
|
|||
Some(target_rect)
|
||||
};
|
||||
|
||||
// Typical workloads have a single or a few batch builders with a
|
||||
// large number of batches (regular pictres) and a higher number
|
||||
// of batch builders with only a single or two batches (for example
|
||||
// rendering isolated primitives to compute their shadows).
|
||||
// We can easily guess which category we are in for each picture
|
||||
// by checking whether it has multiple clusters.
|
||||
let prealloc_batch_count = if pic.prim_list.clusters.len() > 1 {
|
||||
128
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
// TODO(gw): The type names of AlphaBatchBuilder and BatchBuilder
|
||||
// are still confusing. Once more of the picture caching
|
||||
// improvement code lands, the AlphaBatchBuilder and
|
||||
|
@ -390,6 +402,7 @@ impl RenderTarget for ColorRenderTarget {
|
|||
*task_id,
|
||||
render_tasks.get_task_address(*task_id),
|
||||
PrimitiveVisibilityMask::all(),
|
||||
prealloc_batch_count,
|
||||
);
|
||||
|
||||
let mut batch_builder = BatchBuilder::new(
|
||||
|
|
Загрузка…
Ссылка в новой задаче