Discard draws when the instance/vertex/index count is zero (#5137)

This commit is contained in:
Nicolas Silva 2024-01-25 09:06:29 +01:00 committed by GitHub
parent efb35d4fa1
commit d47534ed9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 15 deletions

View File

@ -514,9 +514,12 @@ impl RenderBundleEncoder {
})
.map_pass_err(scope);
}
commands.extend(state.flush_vertices());
commands.extend(state.flush_binds(used_bind_groups, base.dynamic_offsets));
commands.push(command);
if instance_count > 0 && vertex_count > 0 {
commands.extend(state.flush_vertices());
commands.extend(state.flush_binds(used_bind_groups, base.dynamic_offsets));
commands.push(command);
}
}
RenderCommand::DrawIndexed {
index_count,
@ -556,10 +559,13 @@ impl RenderBundleEncoder {
})
.map_pass_err(scope);
}
commands.extend(state.flush_index());
commands.extend(state.flush_vertices());
commands.extend(state.flush_binds(used_bind_groups, base.dynamic_offsets));
commands.push(command);
if instance_count > 0 && index_count > 0 {
commands.extend(state.flush_index());
commands.extend(state.flush_vertices());
commands.extend(state.flush_binds(used_bind_groups, base.dynamic_offsets));
commands.push(command);
}
}
RenderCommand::MultiDrawIndirect {
buffer_id,

View File

@ -1931,7 +1931,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
unsafe {
raw.draw(first_vertex, vertex_count, first_instance, instance_count);
if instance_count > 0 && vertex_count > 0 {
raw.draw(
first_vertex,
vertex_count,
first_instance,
instance_count,
);
}
}
}
RenderCommand::DrawIndexed {
@ -1972,13 +1979,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
unsafe {
raw.draw_indexed(
first_index,
index_count,
base_vertex,
first_instance,
instance_count,
);
if instance_count > 0 && index_count > 0 {
raw.draw_indexed(
first_index,
index_count,
base_vertex,
first_instance,
instance_count,
);
}
}
}
RenderCommand::MultiDrawIndirect {