Skip to content

Commit

Permalink
Add minimum sizes to textures to prevent crash (bevyengine#2300)
Browse files Browse the repository at this point in the history
# Objective
- Fixes bevyengine#2299

## Solution
- Ensures that textures are never requested with 0 height/width.
  • Loading branch information
trolleyman authored and ostwilkens committed Jul 27, 2021
1 parent 67ab0af commit eb63a27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ impl Node for WindowTextureNode {
render_resource_context.remove_texture(old_texture);
}

self.descriptor.size.width = window.physical_width();
self.descriptor.size.height = window.physical_height();
self.descriptor.size.width = window.physical_width().max(1);
self.descriptor.size.height = window.physical_height().max(1);
let texture_resource = render_resource_context.create_texture(self.descriptor);
output.set(WINDOW_TEXTURE, RenderResourceId::Texture(texture_resource));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_wgpu/src/wgpu_type_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ impl WgpuFrom<&Window> for wgpu::SwapChainDescriptor {
wgpu::SwapChainDescriptor {
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
format: TextureFormat::default().wgpu_into(),
width: window.physical_width(),
height: window.physical_height(),
width: window.physical_width().max(1),
height: window.physical_height().max(1),
present_mode: if window.vsync() {
wgpu::PresentMode::Fifo
} else {
Expand Down

0 comments on commit eb63a27

Please sign in to comment.