Function createTextureWithData
- create
Texture (device, descriptor, data): GPUTextureWith Data Parameters
- device: GPUDevice
The device to create the texture with.
- descriptor: GPUTextureDescriptor
The texture descriptor to create the texture with.
- data: Uint8Array
The data to write to the texture.
Returns GPUTexture
The newly created texture.
Example: Usage
import { createTextureWithData } from "@std/webgpu/texture-with-data";
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter?.requestDevice()!;
createTextureWithData(device, {
format: "bgra8unorm-srgb",
size: {
width: 3,
height: 2,
},
usage: GPUTextureUsage.COPY_SRC,
}, new Uint8Array([1, 1, 1, 1, 1, 1, 1]));- device: GPUDevice
Create a GPUTexture with data.