Function write_subtexture_rgba

Source
pub fn write_subtexture_rgba(
    queue: &Queue,
    texture: &Texture,
    origin: Origin3d,
    w: u32,
    h: u32,
    rgba: &[u8],
)
Expand description

Writes a tight RGBA8 rectangle into a texture, padding rows to 256 bytes.

rgba should contain w * h * 4 bytes. Short data is zero-padded only when row repacking is required; an already aligned short slice is passed directly to wgpu and fails validation. Zero width produces a zero row pitch, which is not a valid nonempty texture copy.

§Panics

Panics on arithmetic overflow, allocation failure, or a short source row during the padding copy.

§Examples

use ailloli_ui_render_wgpu::text::glyph_upload::write_subtexture_rgba;
fn upload(queue: &wgpu::Queue, texture: &wgpu::Texture) {
    write_subtexture_rgba(queue, texture, wgpu::Origin3d::ZERO,
        2, 2, &[255; 2 * 2 * 4]);
}