pub struct TextureWriteDescriptor {
pub data: Vec<u8>,
pub bytes_per_row: u32,
pub rows_per_image: u32,
pub mip_level: u32,
pub texture: JsValue,
pub origin: Option<JsValue>,
pub flip_y: bool,
}Expand description
Descriptor for queue.writeTexture(destination, data, dataLayout, size).
WebGPU’s writeTexture lets you upload CPU-side pixel data directly to a
texture without staging through a buffer. Use it for: ImGui font atlases,
procedural noise textures, sprite sheets, ImageBitmap pixels, etc.
The copy covers the remaining logical mip extent from origin; dimensions
are read from the destination texture, independently of source byte strides.
Fields§
§data: Vec<u8>The pixel data to upload. Bytes are laid out according to
bytes_per_row / rows_per_image.
bytes_per_row: u32Bytes between source block rows, including padding. No 256-byte
alignment is required by queue.writeTexture. 0 omits the stride,
which is valid only when WebGPU can infer it for a single block row.
rows_per_image: u32Source block rows between images, including padding. 0 omits this
optional field; a positive stride is required for multiple images.
mip_level: u32Destination mip level to write into.
texture: JsValueDestination texture to write into.
origin: Option<JsValue>Origin within the destination texture. None → (0, 0, 0).
flip_y: boolRetained for compatibility. Raw-byte write_texture uploads do not
transform source rows; callers must flip their bytes when necessary.
Implementations§
Source§impl TextureWriteDescriptor
2D-upload convenience constructor for TextureWriteDescriptor.
impl TextureWriteDescriptor
2D-upload convenience constructor for TextureWriteDescriptor.
Sourcepub fn for_2d(data: Vec<u8>, bytes_per_row: u32, texture: JsValue) -> Self
pub fn for_2d(data: Vec<u8>, bytes_per_row: u32, texture: JsValue) -> Self
Convenience constructor for the common 2D upload case.
The base mip extent comes from the destination GPUTexture.
The row stride is measured in bytes and need not be 256-byte aligned.
rows_per_image remains zero so the optional field is omitted.
§Arguments
Vec<u8>- The source pixel bytes in the destination texture format.u32- The byte stride between source rows, including padding.JsValue- The destinationGPUTexturehandle.
§Returns
Self- A base-mip upload descriptor with the origin at zero.