-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
don't try to draw empty meshes in wgpu #2782
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Little nitpick.
wgpu/src/lib.rs
Outdated
if !mesh.indices().is_empty() { | ||
let (layer, transformation) = self.layers.current_mut(); | ||
layer.draw_mesh(mesh, transformation); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if !mesh.indices().is_empty() { | |
let (layer, transformation) = self.layers.current_mut(); | |
layer.draw_mesh(mesh, transformation); | |
} | |
if mesh.indices().is_empty() { | |
return; | |
} | |
let (layer, transformation) = self.layers.current_mut(); | |
layer.draw_mesh(mesh, transformation); |
Thinking about it a bit more. I think this is a check that should happen in user code. We consider empty meshes invalid. The same way trying to draw an empty quad is invalid too. Or tessellating an empty path. Or a mesh with a number of indices that is not a multiple of 3. Instead of checking every mesh, if your code can produce empty meshes, you should filter them out right there. In any case, we can add a |
Sure, a debug assert also sounds reasonable. At least that would make the issue more easily debuggable |
A mesh with empty indices doesn't have anything to draw, so skip drawing it.
Giving tiny-skia empty meshes to draw works fine, however the wgpu renderer crashes horribly. This prevents that crash.
closes #2774