Use Image::default for 1 pixel white texture directly (#7884)

for place holder image, it should use `default` directly.
This commit is contained in:
shuo 2023-03-04 12:29:10 +00:00
parent 6beca13553
commit 0b794c8f1e
4 changed files with 4 additions and 18 deletions

View file

@ -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(),

View file

@ -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()];

View file

@ -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(),

View file

@ -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(),