createTextureWithData
import { createTextureWithData } from "jsr:@ende/webgpu";function
function createTextureWithData(device: GPUDevice, descriptor: GPUTextureDescriptor, data: Uint8Array_): GPUTextureCreate a GPUTexture with data.
device: GPUDeviceThe device to create the texture with.
descriptor: GPUTextureDescriptorThe texture descriptor to create the texture with.
data: Uint8Array_The data to write to the texture.
Returns
The newly created texture.
Example: Usage
import { createTextureWithData } from "@ende/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]));