pub fn encode_load_texture_from_image_buffer<P, Container>(
    device: &wgpu::Device,
    encoder: &mut wgpu::CommandEncoder,
    usage: wgpu::TextureUsage,
    buffer: &image::ImageBuffer<P, Container>,
) -> wgpu::Texture
where
    P: 'static + Pixel,
    Container: std::ops::Deref<Target = [P::Subpixel]>,
{
    // Create the texture.
    let texture = wgpu::TextureBuilder::from_image_view(buffer)
        .usage(wgpu::TextureBuilder::REQUIRED_IMAGE_TEXTURE_USAGE | usage)
        .build(device);

    // Upload the pixel data.
    let subpixel_data: &[P::Subpixel] = std::ops::Deref::deref(buffer);
    let buffer = device
        .create_buffer_mapped(subpixel_data.len(), wgpu::BufferUsage::COPY_SRC)
        .fill_from_slice(subpixel_data);

    // Submit command for copying pixel data to the texture.
    let buffer_copy_view = texture.default_buffer_copy_view(&buffer);
    let texture_copy_view = texture.default_copy_view();
    let extent = texture.extent();
    encoder.copy_buffer_to_texture(buffer_copy_view, texture_copy_view, extent);

    texture
}
/// Encode the necessary commands to load a texture directly from an image buffer.
///
/// NOTE: The returned texture will remain empty until the given `encoder` has its command buffer
/// submitted to the given `device`'s queue.
///
/// No format or size conversions are performed - the given buffer is loaded directly into GPU
/// memory.
///
/// Pixel type compatibility is ensured via the `Pixel` trait.
Encode the necessary commands to load a texture directly from an image buffer.
NOTE: The returned texture will remain empty until the given `encoder` has its command buffer
submitted to the given `device`'s queue.

No format or size conversions are performed - the given buffer is loaded directly into GPU
memory.

Pixel type compatibility is ensured via the `Pixel` trait.
Encode the necessary commands to load a texture directly from an image buffer . NOTE : The returned texture will remain empty until the given ` encoder ` has its command buffer submitted to the given ` device ` ' s queue . No format or size conversions are performed - the given buffer is loaded directly into GPU memory . Pixel type compatibility is ensured via the ` Pixel ` trait .
pub fn encode_load_texture_from_image_buffer<P, Container>(
    device: &wgpu::Device,
    encoder: &mut wgpu::CommandEncoder,
    usage: wgpu::TextureUsage,
    buffer: &image::ImageBuffer<P, Container>,
) -> wgpu::Texture
where
    P: 'static + Pixel,
    Container: std::ops::Deref<Target = [P::Subpixel]>,
{
    // Create the texture.
    let texture = wgpu::TextureBuilder::from_image_view(buffer)
        .usage(wgpu::TextureBuilder::REQUIRED_IMAGE_TEXTURE_USAGE | usage)
        .build(device);
    // Upload the pixel data.
    let subpixel_data: &[P::Subpixel] = std::ops::Deref::deref(buffer);
    let buffer = device
        .create_buffer_mapped(subpixel_data.len(), wgpu::BufferUsage::COPY_SRC)
        .fill_from_slice(subpixel_data);
    // Submit command for copying pixel data to the texture.
    let buffer_copy_view = texture.default_buffer_copy_view(&buffer);
    let texture_copy_view = texture.default_copy_view();
    let extent = texture.extent();
    encoder.copy_buffer_to_texture(buffer_copy_view, texture_copy_view, extent);
    texture
}
pub fn encode_load_texture_from_image_buffer < P , Container > ( device : & wgpu :: Device , encoder : & mut wgpu :: CommandEncoder , usage : wgpu :: TextureUsage , buffer : & image :: ImageBuffer < P , Container > , ) -> wgpu :: Texture where P : ' static + Pixel , Container : std :: ops :: Deref < Target = [ P :: Subpixel ] > , { // Create the texture. let texture = wgpu :: TextureBuilder :: from_image_view ( buffer ) . usage ( wgpu :: TextureBuilder :: REQUIRED_IMAGE_TEXTURE_USAGE | usage ) . build ( device ) ; // Upload the pixel data. let subpixel_data : & [ P :: Subpixel ] = std :: ops :: Deref :: deref ( buffer ) ; let buffer = device . create_buffer_mapped ( subpixel_data . len ( ) , wgpu :: BufferUsage :: COPY_SRC ) . fill_from_slice ( subpixel_data ) ; // Submit command for copying pixel data to the texture. let buffer_copy_view = texture . default_buffer_copy_view ( & buffer ) ; let texture_copy_view = texture . default_copy_view ( ) ; let extent = texture . extent ( ) ; encoder . copy_buffer_to_texture ( buffer_copy_view , texture_copy_view , extent ) ; texture }
Encode the necessary commands to load a texture directly from an image buffer.
Encode the necessary commands to load a texture directly from an image buffer .
device
&wgpu::Device
encoder
&mut wgpu::CommandEncoder
usage
wgpu::TextureUsage
buffer
&image::ImageBuffer<P, Container>
device
&wgpu::Device
encoder
&mut wgpu::CommandEncoder
usage
wgpu::TextureUsage
buffer
&image::ImageBuffer<P, Container>