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.
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 per row of the source data. Must be a multiple of 256.
rows_per_image: u32Number of rows per image. 0 for 2D textures without mip chains.
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: boolWhether to flip the source data vertically before writing.
true is essential when uploading from <img> / <canvas> whose
rows are top-to-bottom but WebGPU textures are bottom-to-top.
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.
data- packed pixel bytes (format-dependent).bytes_per_row- row stride ofdata, must be a multiple of 256.texture- the destinationGpuTexturehandle.
§Arguments
Vec<u8>- AVec<u8>parameter.u32- A 32-bit unsigned integer (u32).JsValue- AJsValueparameter.