GPUQueue

class

class GPUQueue implements GPUObjectBase

Represents a queue to submit commands to the GPU.

Example

// 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

label

label: string

Methods

submit

submit(commandBuffers: GPUCommandBuffer[]): undefined

onSubmittedWorkDone

onSubmittedWorkDone(): Promise<undefined>

writeBuffer

writeBuffer(buffer: GPUBuffer, bufferOffset: number, data: BufferSource, dataOffset?: number, size?: number): undefined

writeTexture

writeTexture(destination: GPUTexelCopyTextureInfo, data: BufferSource, dataLayout: GPUTexelCopyBufferLayout, size: GPUExtent3D): undefined