Skip to content

Commit

Permalink
Use Image::default for 1 pixel white texture directly (bevyengine#7884)
Browse files Browse the repository at this point in the history
for place holder image, it should use `default` directly.
  • Loading branch information
shuoli84 authored and Shfty committed Mar 19, 2023
1 parent a5d7dc0 commit 6be3d97
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
7 changes: 1 addition & 6 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,7 @@ impl FromWorld for MeshPipeline {

// A 1x1x1 'all 1.0' texture to use as a dummy texture to use in place of optional StandardMaterial textures
let dummy_white_gpu_image = {
let image = Image::new_fill(
Extent3d::default(),
TextureDimension::D2,
&[255u8; 4],
TextureFormat::bevy_default(),
);
let image = Image::default();
let texture = render_device.create_texture(&image.texture_descriptor);
let sampler = match image.sampler_descriptor {
ImageSampler::Default => (**default_sampler).clone(),
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_render/src/texture/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ impl ImageSampler {
pub struct DefaultImageSampler(pub(crate) Sampler);

impl Default for Image {
/// default is a 1x1x1 all '1.0' texture
fn default() -> Self {
let format = wgpu::TextureFormat::bevy_default();
let data = vec![255; format.pixel_size()];
Expand Down
7 changes: 1 addition & 6 deletions crates/bevy_sprite/src/mesh2d/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,7 @@ impl FromWorld for Mesh2dPipeline {
});
// A 1x1x1 'all 1.0' texture to use as a dummy texture to use in place of optional StandardMaterial textures
let dummy_white_gpu_image = {
let image = Image::new_fill(
Extent3d::default(),
TextureDimension::D2,
&[255u8; 4],
TextureFormat::bevy_default(),
);
let image = Image::default();
let texture = render_device.create_texture(&image.texture_descriptor);
let sampler = match image.sampler_descriptor {
ImageSampler::Default => (**default_sampler).clone(),
Expand Down
7 changes: 1 addition & 6 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ impl FromWorld for SpritePipeline {
label: Some("sprite_material_layout"),
});
let dummy_white_gpu_image = {
let image = Image::new_fill(
Extent3d::default(),
TextureDimension::D2,
&[255u8; 4],
TextureFormat::bevy_default(),
);
let image = Image::default();
let texture = render_device.create_texture(&image.texture_descriptor);
let sampler = match image.sampler_descriptor {
ImageSampler::Default => (**default_sampler).clone(),
Expand Down

0 comments on commit 6be3d97

Please sign in to comment.