Skip to content

Commit

Permalink
fix Default implementation of Image so that size and data match (#…
Browse files Browse the repository at this point in the history
…2833)

Before using this image resulted in an `Error in Queue::write_texture: copy of 0..4 would end up overrunning the bounds of the Source buffer of size 0`
  • Loading branch information
jakobhellermann committed Sep 16, 2021
1 parent 52fd626 commit 1e03a97
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pipelined/bevy_render2/src/texture/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
render_asset::RenderAsset,
render_resource::{Sampler, Texture, TextureView},
renderer::{RenderDevice, RenderQueue},
texture::BevyDefault,
};
use bevy_reflect::TypeUuid;
use thiserror::Error;
Expand All @@ -25,15 +26,17 @@ pub struct Image {

impl Default for Image {
fn default() -> Self {
let format = wgpu::TextureFormat::bevy_default();
let data = vec![1; format.pixel_size() as usize];
Image {
data: Default::default(),
data,
texture_descriptor: wgpu::TextureDescriptor {
size: wgpu::Extent3d {
width: 1,
height: 1,
depth_or_array_layers: 1,
},
format: wgpu::TextureFormat::Rgba8UnormSrgb,
format,
dimension: wgpu::TextureDimension::D2,
label: None,
mip_level_count: 1,
Expand Down

0 comments on commit 1e03a97

Please sign in to comment.