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

Render option that disables batching/instancing #1186

Merged
merged 1 commit into from May 1, 2017
Merged
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
19 changes: 16 additions & 3 deletions webrender/src/renderer.rs
Expand Up @@ -532,6 +532,7 @@ pub struct Renderer {
clear_color: ColorF,
debug: DebugRenderer,
render_target_debug: bool,
enable_batcher: bool,
backend_profile_counters: BackendProfileCounters,
profile_counters: RendererProfileCounters,
profiler: Profiler,
Expand Down Expand Up @@ -1061,6 +1062,7 @@ impl Renderer {
notifier: notifier,
debug: debug_renderer,
render_target_debug: render_target_debug,
enable_batcher: options.enable_batcher,
backend_profile_counters: BackendProfileCounters::new(),
profile_counters: RendererProfileCounters::new(),
profiler: Profiler::new(),
Expand Down Expand Up @@ -1437,10 +1439,19 @@ impl Renderer {
self.device.bind_texture(TextureSampler::Dither, id);
}

self.device.update_vao_instances(vao, data, VertexUsageHint::Stream);
self.device.draw_indexed_triangles_instanced_u16(6, data.len() as i32);
if self.enable_batcher {
self.device.update_vao_instances(vao, data, VertexUsageHint::Stream);
self.device.draw_indexed_triangles_instanced_u16(6, data.len() as i32);
self.profile_counters.draw_calls.inc();
} else {
for i in 0 .. data.len() {
self.device.update_vao_instances(vao, &data[i..i+1], VertexUsageHint::Stream);
self.device.draw_triangles_u16(0, 6);
self.profile_counters.draw_calls.inc();
}
}

self.profile_counters.vertices.add(6 * data.len());
self.profile_counters.draw_calls.inc();
}

fn submit_batch(&mut self,
Expand Down Expand Up @@ -2120,6 +2131,7 @@ pub struct RendererOptions {
pub enable_subpixel_aa: bool,
pub clear_framebuffer: bool,
pub clear_color: ColorF,
pub enable_batcher: bool,
pub render_target_debug: bool,
pub max_texture_size: Option<u32>,
pub workers: Option<Arc<Mutex<ThreadPool>>>,
Expand All @@ -2143,6 +2155,7 @@ impl Default for RendererOptions {
enable_subpixel_aa: false,
clear_framebuffer: true,
clear_color: ColorF::new(1.0, 1.0, 1.0, 1.0),
enable_batcher: true,
render_target_debug: false,
max_texture_size: None,
workers: None,
Expand Down
3 changes: 3 additions & 0 deletions wrench/src/args.yaml
Expand Up @@ -50,6 +50,9 @@ args:
- vsync:
long: vsync
help: Enable vsync for OpenGL window
- no_batch:
long: no-batch
help: Disable batching of instanced draw calls

subcommands:
- png:
Expand Down
3 changes: 2 additions & 1 deletion wrench/src/main.rs
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
Expand Up @@ -146,7 +146,8 @@ impl Wrench {
do_rebuild: bool,
subpixel_aa: bool,
debug: bool,
verbose: bool)
verbose: bool,
no_batch: bool)
-> Wrench
{
println!("Shader override path: {:?}", shader_override_path);
Expand All @@ -171,6 +172,7 @@ impl Wrench {
recorder: recorder,
enable_subpixel_aa: subpixel_aa,
debug: debug,
enable_batcher: !no_batch,
max_recorded_profiles: 16,
.. Default::default()
};
Expand Down