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

Remove any empty batches to avoid empty draw calls / batch breaks. #2803

Merged
merged 1 commit into from Jun 5, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -319,6 +319,24 @@ impl BatchList {
}
}

// Remove any batches that were added but didn't get any instances
// added to them.
fn remove_unused_batches(&mut self) {
if self.opaque_batch_list
.batches
.last()
.map_or(false, |batch| batch.instances.is_empty()) {
self.opaque_batch_list.batches.pop().unwrap();
}

if self.alpha_batch_list
.batches
.last()
.map_or(false, |batch| batch.instances.is_empty()) {
self.alpha_batch_list.batches.pop().unwrap();
}
}

fn finalize(&mut self) {
self.opaque_batch_list.finalize()
}
@@ -1314,6 +1332,8 @@ impl AlphaBatchBuilder {
batch.push(PrimitiveInstance::from(base_instance));
}
}

self.batch_list.remove_unused_batches();
}
}

@@ -2601,6 +2601,12 @@ impl Renderer {
vertex_array_kind: VertexArrayKind,
stats: &mut RendererStats,
) {
// If we end up with an empty draw call here, that means we have
// probably introduced unnecessary batch breaks during frame
// building - so we should be catching this earlier and removing
// the batch.
debug_assert!(!data.is_empty());

let vao = get_vao(vertex_array_kind, &self.vaos, &self.gpu_glyph_renderer);

self.device.bind_vao(vao);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.