Skip to content

Commit

Permalink
Optimized away empty drawcalls. Still slow
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatekii committed Jul 28, 2019
1 parent a9d4883 commit 853ac84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/drawing/drawable_tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl DrawableTile {
render_pass.set_index_buffer(&self.index_buffer, 0);
render_pass.set_vertex_buffers(&[(&self.vertex_buffer, 0)]);
for (id, range) in &self.features {
if feature_id == *id && layer_collection.is_visible(*id) {
if feature_id == *id && range.len() > 0 && layer_collection.is_visible(*id) {
if outline {
if layer_collection.has_outline(*id) {
let range_start = tile_id << 1;
Expand Down
5 changes: 4 additions & 1 deletion src/drawing/painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ impl Painter {
&self.tile_transform_buffer
);
let num_tiles = self.loaded_tiles.len();
let mut first = true;
dbg!(layer_collection.iter_features().count());
if layer_collection.iter_features().count() > 0 && num_tiles > 0 {
let frame = self.swap_chain.get_next_texture();
{
Expand All @@ -730,7 +732,7 @@ impl Painter {
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
attachment: if CONFIG.renderer.msaa_samples > 1 { &self.multisampled_framebuffer } else { &frame.view },
resolve_target: if CONFIG.renderer.msaa_samples > 1 { Some(&frame.view) } else { None },
load_op: wgpu::LoadOp::Load,
load_op: if first { wgpu::LoadOp::Clear } else { wgpu::LoadOp::Load },
store_op: wgpu::StoreOp::Store,
clear_color: wgpu::Color::WHITE,
}],
Expand All @@ -754,6 +756,7 @@ impl Painter {
for (i, drawable_tile) in self.loaded_tiles.values_mut().enumerate() {
drawable_tile.paint(&mut render_pass, &layer_collection, i as u32, feature.id, true);
}
first = false;
}
}
self.device.get_queue().submit(&[encoder.finish()]);
Expand Down

0 comments on commit 853ac84

Please sign in to comment.