Wraps an existing GPUTexture and creates a default view with the matching dimension.
The GPU texture to take ownership of.
View dimensionality (2d, 3d, or cube).
Destroys the underlying GPU texture.
StaticcreateCreates a 1x1 rgba8unorm texture filled with the given color.
The WebGPU device.
Red component, 0-255.
Green component, 0-255.
Blue component, 0-255.
Alpha component, 0-255 (defaults to 255).
A new Texture owning the 1x1 GPU texture.
StaticfromUploads an ImageBitmap as a 2D texture.
The WebGPU device.
Source image (typically from createImageBitmap).
srgb=true selects rgba8unorm-srgb so the GPU linearizes on sample; usage adds extra usage flags on top of the standard binding/copy/render set; mipLevelCount>1 allocates a mip chain and box-downsamples it on the GPU after upload.
A new Texture owning the uploaded 2D image.
StaticfromUploads a pre-decoded (optionally block-compressed) 2D texture, one mip
level at a time. Used for KTX2/Basis textures transcoded by
transcodeKtx2: levels[0] is full resolution, each subsequent entry
a half-size mip. Block-compressed formats compute bytesPerRow from the 4×4
block size; rgba8unorm[-srgb] uses the uncompressed width×4 stride.
The WebGPU device.
format (GPU texture format), pixel width/height, and one byte array per mip level.
A new Texture owning the uploaded image.
StaticfromFetches an image URL and uploads it as a 2D GPU texture.
Use srgb=true for albedo/color maps; keep false for normal/ORM maps.
The WebGPU device.
URL to fetch the image from.
srgb enables rgba8unorm-srgb; resizeWidth/resizeHeight resize the bitmap before upload; usage adds extra usage flags (e.g. COPY_SRC); generateMips allocates and box-downsamples a full mip chain (needed so the texture minifies cleanly instead of aliasing at distance).
A Texture containing the uploaded image.
Owns a
GPUTextureand a defaultGPUTextureViewof the matching dimension.Callers must invoke
destroy()to release the underlying GPU memory.