class GPUQueue
implements GPUObjectBase
Represents a queue to submit commands to the GPU.
Examples #
#
// Get a queue from the device (each device has a default queue)
const queue = device.queue;
// Write data to a buffer
const buffer = device.createBuffer({
size: data.byteLength,
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE
});
queue.writeBuffer(buffer, 0, data);
// Submit command buffers to the GPU for execution
const commandBuffer = commandEncoder.finish();
queue.submit([commandBuffer]);
// Wait for all submitted operations to complete
await queue.onSubmittedWorkDone();
// Example: Write data to a texture
const texture = device.createTexture({
size: { width: 256, height: 256 },
format: "rgba8unorm",
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
});
const data = new Uint8Array(256 * 256 * 4); // RGBA data
// Fill data with your texture content...
queue.writeTexture(
{ texture },
data,
{ bytesPerRow: 256 * 4 },
{ width: 256, height: 256 }
);
Properties #
Methods #
#onSubmittedWorkDone(): Promise<undefined>
#submit(commandBuffers: GPUCommandBuffer[]): undefined
#writeBuffer(): undefined
#writeTexture(destination: GPUTexelCopyTextureInfo,data: BufferSource,dataLayout: GPUTexelCopyBufferLayout,size: GPUExtent3D,): undefined