Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An option to force no batching #1185

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 3 additions & 14 deletions webrender/src/frame_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,7 @@ pub struct FrameBuilderConfig {
pub enable_scrollbars: bool,
pub enable_subpixel_aa: bool,
pub debug: bool,
}

impl FrameBuilderConfig {
pub fn new(enable_scrollbars: bool,
enable_subpixel_aa: bool,
debug: bool)
-> FrameBuilderConfig {
FrameBuilderConfig {
enable_scrollbars: enable_scrollbars,
enable_subpixel_aa: enable_subpixel_aa,
debug: debug,
}
}
pub force_cut_batches: bool,
}

pub struct FrameBuilder {
Expand Down Expand Up @@ -1305,7 +1293,8 @@ impl FrameBuilder {
for index in 0..required_pass_count {
passes.push(RenderPass::new(index as isize,
index == required_pass_count-1,
cache_size));
cache_size,
self.config.force_cut_batches));
}

main_render_task.assign_to_passes(passes.len() - 1, &mut passes);
Expand Down
11 changes: 8 additions & 3 deletions webrender/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,12 @@ impl Renderer {
RendererKind::OSMesa => GLContextHandleWrapper::current_osmesa_handle(),
};

let config = FrameBuilderConfig::new(options.enable_scrollbars,
options.enable_subpixel_aa,
options.debug);
let config = FrameBuilderConfig {
enable_scrollbars: options.enable_scrollbars,
enable_subpixel_aa: options.enable_subpixel_aa,
debug: options.debug,
force_cut_batches: options.force_cut_batches,
};

let (device_pixel_ratio, enable_aa) = (options.device_pixel_ratio, options.enable_aa);
let render_target_debug = options.render_target_debug;
Expand Down Expand Up @@ -2122,6 +2125,7 @@ pub struct RendererOptions {
pub clear_color: ColorF,
pub render_target_debug: bool,
pub max_texture_size: Option<u32>,
pub force_cut_batches: bool,
pub workers: Option<Arc<Mutex<ThreadPool>>>,
pub blob_image_renderer: Option<Box<BlobImageRenderer>>,
pub recorder: Option<Box<ApiRecordingReceiver>>,
Expand All @@ -2145,6 +2149,7 @@ impl Default for RendererOptions {
clear_color: ColorF::new(1.0, 1.0, 1.0, 1.0),
render_target_debug: false,
max_texture_size: None,
force_cut_batches: false,
workers: None,
blob_image_renderer: None,
recorder: None,
Expand Down
35 changes: 21 additions & 14 deletions webrender/src/tiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,15 @@ struct AlphaBatchTask {
pub struct BatchList {
pub alpha_batches: Vec<PrimitiveBatch>,
pub opaque_batches: Vec<PrimitiveBatch>,
force_cut: bool,
}

impl BatchList {
fn new() -> BatchList {
fn new(force_cut: bool) -> BatchList {
BatchList {
alpha_batches: Vec::new(),
opaque_batches: Vec::new(),
force_cut: force_cut,
}
}

Expand Down Expand Up @@ -272,7 +274,7 @@ impl BatchList {
}
}

if selected_batch_index.is_none() {
if self.force_cut || selected_batch_index.is_none() {
let new_batch = PrimitiveBatch::new(key.clone());
selected_batch_index = Some(batches.len());
batches.push(new_batch);
Expand Down Expand Up @@ -594,10 +596,10 @@ impl AlphaRenderItem {
}

impl AlphaBatcher {
fn new() -> AlphaBatcher {
fn new(force_cut: bool) -> AlphaBatcher {
AlphaBatcher {
tasks: Vec::new(),
batch_list: BatchList::new(),
batch_list: BatchList::new(force_cut),
}
}

Expand Down Expand Up @@ -752,7 +754,7 @@ impl TextureAllocator {
}

pub trait RenderTarget {
fn new(size: DeviceUintSize) -> Self;
fn new(size: DeviceUintSize, force_cut: bool) -> Self;
fn allocate(&mut self, size: DeviceUintSize) -> Option<DeviceUintPoint>;
fn build(&mut self,
_ctx: &RenderTargetContext,
Expand All @@ -775,18 +777,22 @@ pub enum RenderTargetKind {
pub struct RenderTargetList<T> {
target_size: DeviceUintSize,
pub targets: Vec<T>,
force_cut_batches: bool,
}

impl<T: RenderTarget> RenderTargetList<T> {
fn new(target_size: DeviceUintSize, create_initial_target: bool) -> RenderTargetList<T> {
fn new(target_size: DeviceUintSize,
create_initial_target: bool,
force_cut_batches: bool) -> RenderTargetList<T> {
let mut targets = Vec::new();
if create_initial_target {
targets.push(T::new(target_size));
targets.push(T::new(target_size, force_cut_batches));
}

RenderTargetList {
targets: targets,
target_size: target_size,
force_cut_batches: force_cut_batches,
}
}

Expand Down Expand Up @@ -820,7 +826,7 @@ impl<T: RenderTarget> RenderTargetList<T> {
let origin = match existing_origin {
Some(origin) => origin,
None => {
let mut new_target = T::new(self.target_size);
let mut new_target = T::new(self.target_size, self.force_cut_batches);
let origin = new_target.allocate(alloc_size)
.expect(&format!("Each render task must allocate <= size of one target! ({:?})", alloc_size));
self.targets.push(new_target);
Expand Down Expand Up @@ -858,9 +864,9 @@ impl RenderTarget for ColorRenderTarget {
self.allocator.allocate(&size)
}

fn new(size: DeviceUintSize) -> ColorRenderTarget {
fn new(size: DeviceUintSize, force_cut: bool) -> ColorRenderTarget {
ColorRenderTarget {
alpha_batcher: AlphaBatcher::new(),
alpha_batcher: AlphaBatcher::new(force_cut),
box_shadow_cache_prims: Vec::new(),
text_run_cache_prims: Vec::new(),
text_run_textures: BatchTextures::no_texture(),
Expand Down Expand Up @@ -996,7 +1002,7 @@ impl RenderTarget for AlphaRenderTarget {
self.allocator.allocate(&size)
}

fn new(size: DeviceUintSize) -> AlphaRenderTarget {
fn new(size: DeviceUintSize, _force_cut: bool) -> AlphaRenderTarget {
AlphaRenderTarget {
clip_batcher: ClipBatcher::new(),
allocator: TextureAllocator::new(size),
Expand Down Expand Up @@ -1047,12 +1053,13 @@ pub struct RenderPass {
}

impl RenderPass {
pub fn new(pass_index: isize, is_framebuffer: bool, size: DeviceUintSize) -> RenderPass {
pub fn new(pass_index: isize, is_framebuffer: bool, size: DeviceUintSize,
force_cut_batches: bool) -> RenderPass {
RenderPass {
pass_index: RenderPassIndex(pass_index),
is_framebuffer: is_framebuffer,
color_targets: RenderTargetList::new(size, is_framebuffer),
alpha_targets: RenderTargetList::new(size, false),
color_targets: RenderTargetList::new(size, is_framebuffer, force_cut_batches),
alpha_targets: RenderTargetList::new(size, false, force_cut_batches),
tasks: vec![],
color_texture_id: None,
alpha_texture_id: None,
Expand Down
4 changes: 4 additions & 0 deletions wrench/src/args.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ args:
- vsync:
long: vsync
help: Enable vsync for OpenGL window
- no_batch:
short: b
long: no-batch
help: Disable instanced batching

subcommands:
- png:
Expand Down
3 changes: 2 additions & 1 deletion wrench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ fn main() {
args.is_present("rebuild"),
args.is_present("subpixel_aa"),
args.is_present("debug"),
args.is_present("verbose"));
args.is_present("verbose"),
args.is_present("no_batch"));

let mut thing =
if let Some(subargs) = args.subcommand_matches("show") {
Expand Down
4 changes: 3 additions & 1 deletion wrench/src/wrench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ impl Wrench {
do_rebuild: bool,
subpixel_aa: bool,
debug: bool,
verbose: bool)
verbose: bool,
force_batch_cut: bool)
-> Wrench
{
println!("Shader override path: {:?}", shader_override_path);
Expand All @@ -172,6 +173,7 @@ impl Wrench {
enable_subpixel_aa: subpixel_aa,
debug: debug,
max_recorded_profiles: 16,
force_cut_batches: force_batch_cut,
.. Default::default()
};

Expand Down