GPU

class

class GPU

The entry point to WebGPU in Ende, accessed via the global navigator.gpu property.

Example

// Basic WebGPU initialization in Ende
const gpu = navigator.gpu;
if (!gpu) {
  console.error("WebGPU not supported in this Ende environment");
  Ende.exit(1);
}

// Request an adapter (physical GPU device)
const adapter = await gpu.requestAdapter();
if (!adapter) {
  console.error("Couldn't request WebGPU adapter");
  Ende.exit(1);
}

// Get the preferred format for canvas rendering
// Useful when working with canvas in browser/Ende environments
const preferredFormat = gpu.getPreferredCanvasFormat();
console.log(`Preferred canvas format: ${preferredFormat}`);

// Create a device with default settings
const device = await adapter.requestDevice();
console.log("WebGPU device created successfully");

Methods

requestAdapter

requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>

getPreferredCanvasFormat

getPreferredCanvasFormat(): GPUTextureFormat