Repository: bevyengine/bevy
File: crates/bevy_pbr/src/render/mesh.rs (Rust)

Code before:
            clustered_forward_buffer_binding_type,
            mesh_layouts: MeshLayouts::new(&render_device, &render_adapter),
            shader,
            per_object_buffer_batch_size: GpuArrayBuffer::<MeshUniform>::batch_size(
                &render_device.limits(),
            ),
            binding_arrays_are_usable: binding_arrays_are_usable(&render_device, &render_adapter),
            clustered_decals_are_usable: decal::clustered::clustered_decals_are_usable(
                &render_device,
                &render_adapter,
            ),
            skins_use_uniform_buffers: skins_use_uniform_buffers(&render_device.limits()),
        }
    }
}

impl MeshPipeline {
    pub fn get_view_layout(
        &self,
        layout_key: MeshPipelineViewLayoutKey,
    ) -> &MeshPipelineViewLayout {
        self.view_layouts.get_view_layout(layout_key)
    }
}

/// A 1x1x1 'all 1.0' texture to use as a dummy texture to use in place of optional [`crate::pbr_material::StandardMaterial`] textures
pub fn build_dummy_white_gpu_image(
    render_device: Res<RenderDevice>,
    default_sampler: Res<DefaultImageSampler>,
    render_queue: Res<RenderQueue>,
) -> GpuImage {
    let image = Image::default();
    let texture = render_device.create_texture(&image.texture_descriptor);
    let sampler = match image.sampler {
        ImageSampler::Default => (**default_sampler).clone(),
        ImageSampler::Descriptor(ref descriptor) => {
            render_device.create_sampler(&descriptor.as_wgpu())
        }
    };

    if let Ok(format_size) = image.texture_descriptor.format.pixel_size() {
        render_queue.write_texture(
            texture.as_image_copy(),
            image.data.as_ref().expect("Image was created without data"),
            TexelCopyBufferLayout {
                offset: 0,
                bytes_per_row: Some(image.width() * format_size as u32),
                rows_per_image: None,
            },
            image.texture_descriptor.size,
        );

Review comment (suggestion):
```suggestion
/// A 1x1x1 'all 1.0' texture to use as a dummy texture in place of optional [`crate::pbr_material::StandardMaterial`] textures
```

Code after:
            clustered_forward_buffer_binding_type,
            mesh_layouts: MeshLayouts::new(&render_device, &render_adapter),
            shader,
            per_object_buffer_batch_size: GpuArrayBuffer::<MeshUniform>::batch_size(
                &render_device.limits(),
            ),
            binding_arrays_are_usable: binding_arrays_are_usable(&render_device, &render_adapter),
            clustered_decals_are_usable: decal::clustered::clustered_decals_are_usable(
                &render_device,
                &render_adapter,
            ),
            skins_use_uniform_buffers: skins_use_uniform_buffers(&render_device.limits()),
        }
    }
}

impl MeshPipeline {
    pub fn get_view_layout(
        &self,
        layout_key: MeshPipelineViewLayoutKey,
    ) -> &MeshPipelineViewLayout {
        self.view_layouts.get_view_layout(layout_key)
    }
}

/// A 1x1x1 'all 1.0' texture to use as a dummy texture in place of optional [`crate::pbr_material::StandardMaterial`] textures
pub fn build_dummy_white_gpu_image(
    render_device: Res<RenderDevice>,
    default_sampler: Res<DefaultImageSampler>,
    render_queue: Res<RenderQueue>,
) -> GpuImage {
    let image = Image::default();
    let texture = render_device.create_texture(&image.texture_descriptor);
    let sampler = match image.sampler {
        ImageSampler::Default => (**default_sampler).clone(),
        ImageSampler::Descriptor(ref descriptor) => {
            render_device.create_sampler(&descriptor.as_wgpu())
        }
    };

    if let Ok(format_size) = image.texture_descriptor.format.pixel_size() {
        render_queue.write_texture(
            texture.as_image_copy(),
            image.data.as_ref().expect("Image was created without data"),
            TexelCopyBufferLayout {
                offset: 0,
                bytes_per_row: Some(image.width() * format_size as u32),
                rows_per_image: None,
            },
            image.texture_descriptor.size,
        );